Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I print to destination "Save as PDF" from a command line with Chrome or Chromium? I'd like to be able to automatically convert html files to PDF with Chrome's built-in functionality.

share|improve this question
    
@golimar It is not a virtual printer. Chrome has a built-in option to export to pdf. – ipavlic May 8 '13 at 19:23
    
I don't see any built-in Chrome switches for saving as PDF. – Karan May 10 '13 at 1:07
    
@Karan When you go to Print there should be a Save to PDF destination available for you to choose. It's also clearly stated on Google's support page: support.google.com/chrome/bin/… – ipavlic May 10 '13 at 8:56
1  
Perhaps my previous comment wasn't clear. You wanted to know how to do this from the command line, and what I wanted to say was that Chrome/Chromium seem to have no command-line switches/params to do this, although I know you can do it from the UI. You'll need to find some way of triggering the Save As option, perhaps by sending mouse clicks or key strokes. – Karan May 10 '13 at 14:36
up vote 6 down vote accepted

Instead of calling up an entire web-browser, why not use the HTML rendering engine only to do the work? Use wkhtmltopdf to perform the conversion.

wktohtml

You can also convert an existing website to PDF

$ wkhtmltopdf http://google.com google.pdf

Note: technically Google Chrome's rendering engine is Blink, which is a fork of Webkit. There is >90% of common code between Blink and Webkit, so you should get a similar result.

share|improve this answer
    
Note from having tried this and getting subtle things missing or broken: wkhtmltopdf's source contains QtWebkit patches that enable important features such as clickable links. Your distribution's package is likely to be missing such features if it lists your distribution's usual qtwebkit package as a dependency. Installing wkhtmltopdf from source takes 3.7GiB of disk and some hours. – Anko Sep 18 '15 at 10:41
    
-1 This answer does not correspond to the question, wkhtmltox is a great tool but it does not perform as well as chrome or firefox on exporting to PDF. – Carlos C Soto Jun 16 at 0:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.