Page 1 of 1

[Solved] converting from html to pdf in shell or php

Posted: Thu Jan 17, 2008 2:17 pm
by Fnutt
Hi, I am trying to convert html to pdf in linux redhat el 4 and tested a script called html2ps followed by ps2pdf. Unfortunately it seem that the html2ps ignores the <br> tag, nor does it support Arial font. So now I wonder if I can use open office to do it instead (read that there might be a possibility to do that somewhere). So now I got a few questions:

Is it possible to make a script open and save files via open office?
Can I do that even though I'm running in a shell (no graphical environment available)?
How would be the easiest way to achieve this?

I don't mind using perl, bash, or php (actually I prefer doing it in php but I'm far from sure that's possible).

The plan is that I will download a html-webpage a few times per day, then I want to take that webpage and convert to pdf in order to put it on an ftp-server.

Any suggestions or questions?

Re: converting from html to pdf in shell or php

Posted: Fri Jan 18, 2008 12:53 am
by hol.sten
Fnutt wrote:Can I do that even though I'm running in a shell (no graphical environment available)?
With OOo 2.3 you can get it working on Linux without a graphical environment: http://www.oooforum.org/forum/viewtopic.phtml?t=67044
Or you use xvfb (a virtual frame buffer) and let OOo run with that: http://www.oooforum.org/forum/viewtopic.phtml?t=11890
Fnutt wrote:The plan is that I will download a html-webpage a few times per day, then I want to take that webpage and convert to pdf in order to put it on an ftp-server.

Any suggestions or questions?
Does you HTML contain CSS? If so, keep in mind that OOo cannot handle CSS. Try to open your webpage with OOo Writer/Web to see how your HTML code looks inside OOo.

Re: converting from html to pdf in shell or php

Posted: Fri Jan 18, 2008 2:05 pm
by Fnutt
hol.sten wrote:With OOo 2.3 you can get it working on Linux without a graphical environment: http://www.oooforum.org/forum/viewtopic.phtml?t=67044
Or you use xvfb (a virtual frame buffer) and let OOo run with that: http://www.oooforum.org/forum/viewtopic.phtml?t=11890
That seem like what I'm looking for, now I 'only' have to learn how to do macros (I think).
hol.sten wrote:Does you HTML contain CSS? If so, keep in mind that OOo cannot handle CSS. Try to open your webpage with OOo Writer/Web to see how your HTML code looks inside OOo.
The html-files that I plan to convert are as far as I know clean html that open office seem to handle quite nicely.

Thank you so much for pointing me in the right direction. I'll work on this during the weekend and hope I can come up with something good.

Re: converting from html to pdf in shell or php

Posted: Fri Jan 18, 2008 4:27 pm
by TerryE

Re: converting from html to pdf in shell or php

Posted: Tue Jan 22, 2008 1:32 pm
by Fnutt
Ok, thank you all for the great pointers, now I have gotten it to work using the guide, thank you so much =)