[clug] Automating firefox

Andrew Janke a.janke at gmail.com
Mon Jan 14 00:14:00 GMT 2008


> I have a need in my web application to generate some pdfs from html
> pages. I looked around the net and found lots of little scripts but
> none produces anywhere near the quality that I need. I want to get a
> near true replication o f the web page which means that it needs to
> parse css properly, insert images etc. Unfortunately the users use
> Internet exploder which is really crap for printing.
>
> I looked on the net and this http://www.princexml.com/purchase/ looks
> good but its prohibitively expensive (almost $5k - wow). Its output is
> not too bad but not quite perfect still as it tried to create pdf
> forms from html forms (so it doent look exactly like the web page).
>
> Ideally I would like to be able to call firefox from the command line
> to print as a one off job (giving it a url as an arg). I dont think
> its supported. Next I could try running it in a virtual X server and
> programmatically clicking buttons on it - does anyone have any idea
> how to do this? This is similar to GDI automation under windows - im
> sure there is a way to do it under linux, i vaguely recall tridge
> talking about it a while back in a clug meeting but I cant find any
> leads...

There is a thing called firefox-remote that will at least open a page
IIRC but it doesnt do all you want.

To get the extra keypress's you could take the X11 route ala this:

   http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html

And just send a Ctrl-P, TAB, Space, etc etc.  Then instead of
converting the PS to PDF just use the CUPS PDF driver.


a


More information about the linux mailing list