1

I'm using OS X and I see on chrome that I can Save as PDF in the print window if I set the destination to "Save as PDF". Does this functionality exist in Windows?

Is there any way I can take advantage of this and have it save to PDF with just a click of a button? How can I open up the print page and save that as a PDF? Can I set the default destination to "Save as PDF" and then programmatically click the "Save" button?

Edit: I have tried to use jsPDF but was unable to pull the CSS.

Paul An
  • 19
  • 1
  • 5
  • 3
    Possible duplicate of [Javascript call programmatically the "Save as PDF" feature of Chrome dialog print](http://stackoverflow.com/questions/22096749/javascript-call-programmatically-the-save-as-pdf-feature-of-chrome-dialog-prin) – dwarring Jan 12 '17 at 22:25

3 Answers3

1

there is also an option to print PDF on Windows 10. This javascript code opens a print dialog:

window.print();
tomasantunes
  • 814
  • 2
  • 11
  • 23
  • 3
    I can get the print window to pop up on both Mac and Windows, but how can I set the default print destination to "Save as PDF?" From here how can I use javascript to click "Save?" – Paul An Jan 12 '17 at 22:46
0

I have used PhantomJS before to render PDFs from webpages programmatically. You'd have to write a PhantomJS script to accomplish that but they have helpful examples documented.

Not22
  • 305
  • 1
  • 4
  • 7
  • Important: PhantomJS development is suspended until further notice (more details). https://github.com/ariya/phantomjs/issues/15344 – Mulli Sep 11 '22 at 06:53
-1

jsPDF is a good tool for this.

This question is a possible duplicate of Download a div in a HTML page as pdf using javascript, which provides a demo and sample usage for jsPDF.

Community
  • 1
  • 1
bbailes
  • 371
  • 1
  • 9
  • 1
    Please don't write an answer pointing to a duplicate. Instead, click the flag link under the question and select the duplicate reason. – Heretic Monkey Jan 12 '17 at 22:50