firefox to render to ps or pdf file

Asked by John Gruber

I have a web page which is heavy on the css. When I attempt to use html2ps the postscript looks terrible. It has the text, but none of the style sheet formating. It prints out fine in firefox. The content change is frequent so manually printing would have to be done 24 times a day.

Q. Is there any way to use firefox to render my page (without launching the GUI on the server.. or sending the GUI to a fake X session) and send it the command to Print? I can print to PS or through the PDF printer. Both work fine manually.

I can live with the memory hit, but I can not live with manually printing many times a day.

Thanks smart people!

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu mozilla-firefox Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Simos Xenitellis  (simosx) said :
#1

You can actually use OpenOffice.org for this job.

First try

    soffice <your URL>

to see if the page renders nicely.

If it does, then you can run OpenOffice.org from the command line with the option to print to file, something like
   soffice -p -invisible -headless http://www.google.com/

In practice it is a bit more difficult than this and you need to delve into the oooforum.org.
Have a look at
http://www.oooforum.org/forum/viewtopic.phtml?p=13525

Typical search arguments include "openoffice headless print".
If you manage to find the exact steps of the solution, I would appreciate if you could mention it here (perhaps a link to your blog).

Good luck!

Revision history for this message
John Gruber (john-gruber) said :
#2

sorry to say.. the page looks awful in Writer. Writer does not respect the table width/height given in px. This page is a really complicated chart. Without the table styles being respected... it's unreadable.

Thanks for the suggestion!

John

Revision history for this message
Simos Xenitellis  (simosx) said :
#3

I see.

Another option would be to use a tool like dogtail,
http://people.redhat.com/zcerza/dogtail/
that can command GUI applications to perform tasks. In this way you can start Firefox, get it to load the page, then print it.
However are you going to do this in the background? You can use something like Xvfb,
http://en.wikipedia.org/wiki/Xvfb
that will bring up an X server in memory, and then you can run the dogtail script.

Again, if you achieve this, it would be great to document and post here.

Can you help with this problem?

Provide an answer of your own, or ask John Gruber for more information if necessary.

To post a message you must log in.