1

I am currently building a web application in angular 5. In my app, I will be reading in attachments from the database and I need a way to send the file to the printer to physically print them.

These attachments can be any file type (jpg, pdf, xlsx, doc, etc.) Any help would be greatly appreciated, thank you!

1 Answers1

1

For PDFs and images you can try opening a new window and then using window.print.

<a class="btn btn-success" href="#" onclick="window.open('URL_TO_POST','POPUP WINDOW TITLE HERE','width=650,height=800').print()">Print</a>

For docx files you can try this solution. This will open your document file in Google Docs, then you will be able to print. That link also has some js libraries.

As for excel, you will probably have to convert to a PDF first. Or just let the users download the file and print it themselves.