Reputation: 1272
I am trying to offer users the option to save the current webpage as a PDF using Chrome natively, no other browser support is required and introducing a 3rd party system is not a practical option.
Currently I have to manually instruct the user where the "Open PDF in Preview" link is within the print dialogue and only offer the following button:
<a href="#" onclick="event.preventDefault(); window.print();">
PDF Preview
</a>
I would like to jump the user straight to the PDF preview dialogue for them to save, the following will of course not work, but is more similar to what I would like to achieve.
<a href="#" onclick="event.preventDefault(); window.print('pdf');">
PDF Preview
</a>
Upvotes: 1
Views: 2713
Reputation: 1272
It is not possible to do this.
Chrome currently meets the HTML standard as "print" generically means obtaining the page in some physical way, be that a traditional printed document or a PDF. How it chooses to do this is up to the browser vendor.
Additionally Chrome users can select their default action for printing to be PDF or a printer on their network.
From that I would infer that it's unlikely Chrome would let the web application override the user preference.
Sources
Upvotes: 2