简体   繁体   English

使用javascript从浏览器打印XML或TXT文件

[英]print XML or TXT file from browser with javascript

Is there any way for print a XML or TXT file from browser? 有什么方法可以从浏览器打印XML或TXT文件吗? I have a thermal printer and I want to send one of this format from browser with javascript. 我有一台热敏打印机,我想从浏览器中使用javascript发送这种格式的一种。 Usually, the browser dirty the file and the printer doesn't recognize the format. 通常,浏览器会弄脏文件,而打印机无法识别该格式。

Many thanks in advance, 提前谢谢了,

I'm not sure about what you want but we can use the window.print() function to open the print dialog for the user. 我不确定您想要什么,但是我们可以使用window.print()函数为用户打开打印对话框。

For exemple you can open your xml file in a new window and then use window.print(). 例如,您可以在新窗口中打开xml文件,然后使用window.print()。

window.open(file.txt);
window.print();

I hope it helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM