简体   繁体   中英

print XML or TXT file from browser with javascript

Is there any way for print a XML or TXT file from browser? I have a thermal printer and I want to send one of this format from browser with 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.

For exemple you can open your xml file in a new window and then use window.print().

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

I hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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