Printing pdf from within webpage

problem


some sites embed PDF documents in a page and provide printing through javascript that should open/ trigger os print dialog


the printing dialog that opens is defekt on different levels: it is different from the OS dialog, it does not display multiple pages, the output is wrong, as page title is added to the output.



I am not sure where to go to for help. The issue is known and can be found in some stack overflow questions, like:


iPad: How to print a pdf in an iframe in javascript - Stack Overflow


javascript - Force print dialog in mobile Safari for multi page PDF - Stack Overflow


The iPad is the best tablet around and the one I am always suggesting to my customers. Not being able to properly do something as easy as printing an PDF from an javascript application is a huge show-stopper.


brgds,


Papick G. Taboada

Posted on Oct 15, 2017 12:16 PM

Reply
3 replies

Oct 17, 2017 3:49 AM in response to rccharles

Hi,


I don't see why iframes should not be used. It is a common approach when you have to display a PDF and send it to the printer from the webbrowser.


Safari is broken in this case, as it handles the PDF as a webpage.


The site in case is behind a paywall, but it took me 10min to create a test page for you


http://stage.lemniscus.de/pdf_print_test.html


The page is quite straight forward, as it just "prints" the content of the iframe.


var iframe = document.getElementsByTagName('iframe')[0];


iframe.contentWindow.focus();

iframe.contentWindow.print();



This issue has been around for a while now.


brgds,


Papick

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Printing pdf from within webpage

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.