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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Fnutt
Posts: 4
Joined: Thu Jan 17, 2008 1:29 pm

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

Post 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?
Last edited by Fnutt on Tue Jan 22, 2008 1:33 pm, edited 1 time in total.
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: converting from html to pdf in shell or php

Post 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.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Fnutt
Posts: 4
Joined: Thu Jan 17, 2008 1:29 pm

Re: converting from html to pdf in shell or php

Post 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.
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: converting from html to pdf in shell or php

Post by TerryE »

Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
Fnutt
Posts: 4
Joined: Thu Jan 17, 2008 1:29 pm

Re: converting from html to pdf in shell or php

Post by Fnutt »

Ok, thank you all for the great pointers, now I have gotten it to work using the guide, thank you so much =)
Post Reply