JS函数打印doc文件?

时间:2015-08-10 17:50:33

标签: javascript jquery html printing

我正在尝试使用js函数打印位于我的服务器中的doc文件。 起初,我认为这将是一件容易的事,但经过大量的研究后,我找不到办法。

我试过这个,但结果是一个页面,里面有url。

$('#printItems').on('click', '.toPrint', function(e){
        console.log("Printing...");
        e.preventDefault();
        doc = $(this).attr( "href" );
        var w = window.open(doc);
        w.document.write(doc);
        w.print();
    });

提前致谢。

更新

我知道google doc可以选择这样做。它是否将文件转换为PDF并使用pdf.js?

1 个答案:

答案 0 :(得分:0)

我认为没有正确的方法可以使用javascript直接写入文件。 您可以使用其他编程语言,如java,c。它们提供直接访问以创建文件和读/写它们