8

I want to automate printing. From URL in text file, the webpage is printed. I have tried using wget and the results are very inferior than when printed via browser. Somehow FF and Chromium both manage to convert webpages to "printability" format by redacting sidebars and such. Also, wget fetched webpages have no images. How do I make my prints look readable?

I am thinking of writing dumb macro for mouse and keyboard movements to manually do it using web browser, but CLI is better, less error prone.

There used to be an extension, but it is not maintained anymore and does not install on FF33.

Are there any ways to do it?

  • The web page may use media queries, which tell the browser to use different CSS depending on whether it's being displayed or printed. – Barmar Nov 18 '14 at 2:20
6

Printing via CLI

One method would be to use html2ps.

$ html2ps http://example.com/file.html | lpr

-or-

$ html2ps http://example.com/file.html | lp -d someprinter

Saving to PDF

As an added bonus if you just want to keep it as a PDF file you can use ps2pdf like so:

$ html2ps http://example.com/file.html | ps2pdf - somfile.pdf

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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