Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-03-2011, 12:35 AM
|
#1
|
Member
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34
Rep:
|
odt to pdf php-converter
Hallo.
My problem is to convert an odt file to pdf using php.
I wrote an article in odt and I'd want to download it in pdf from my site.
Excuse my bad english..., but I think you know those articles that has your name in the footer (for example).
I know "fpdf", but it doesn't convert from odt. Someone says to convert from odt to html then to pdf... but some others says NO!
Well, do you know a way? (may be also different from odt to pdf, e.g. from latex to pdf...;-)
Thanks in advance!
Pier
|
|
|
04-03-2011, 02:15 AM
|
#2
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
Why don't you just do the conversion within the office suite? Libre/Open Office has a converter to pdf.
|
|
|
04-03-2011, 03:26 AM
|
#3
|
Member
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34
Original Poster
Rep:
|
Hi graemef,
as I said
Quote:
Excuse my bad english..., but I think you know those articles that has your name in the footer (for example).
|
I'm looking for a way to create dinamically pdf from a static source (my article) when a customer buy it from my ecommerce.
I don't know if is clear my issue...
Thanks a lot ;-)
|
|
|
04-03-2011, 03:44 AM
|
#4
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
You said that the article is in odt format (by which I am assuming open document text)
This document would be created by a program (possibly open office) and then saved in that format.
My suggestion is rather than save in that format (or in addition if you like) export it to pdf.
If that isn't helpful then I think that you need to explain why you need to do it dynamically rather than just once.
|
|
|
04-03-2011, 04:23 AM
|
#5
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
I think that graemef makes a good point. You can easily export your document in Libre Office to pdf and then save that on your web site.
Since the files saved are zipped xml files, I imagine that you could use xlst to process the odt file to a pdf, or run Libre Office in the headless node and use the API. But saving the document in PDF in the first place would make a lot more sense, since the pdf is what you want to deliver, you only need to convert it once.
|
|
|
04-03-2011, 04:56 AM
|
#6
|
Member
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34
Original Poster
Rep:
|
to graemef:
yes I mean open document text.
Quote:
If that isn't helpful then I think that you need to explain why you need to do it dynamically rather than just once.
|
Just because I'd want to write the customer's name on footer. That's the reason I mean "dinamically", it depends on online transaction (purchase, checkout, I don't know how I can say in the best way :-)
to jschiwal:
Quote:
Since the files saved are zipped xml files, I imagine that you could use xlst to process the odt file to a pdf, or run Libre Office in the headless node and use the API.
|
That seem to be on my direction: xlst to pdf, but is there a php converter?
Quote:
But saving the document in PDF in the first place would make a lot more sense, since the pdf is what you want to deliver, you only need to convert it once.
|
Now I think is clear that I don't want to convert once but every purchase due to changing customer's name.
Thanks again.
Pier.
|
|
|
04-03-2011, 05:58 AM
|
#7
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466
|
Hi
I think an easier way to do this would be to first export it as PDF, and then use pdftk to add the footer as background. The background pdf can be made with for example fpdf.
|
|
|
04-03-2011, 07:45 PM
|
#8
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
I found a php library handling open document files but it did something totally different.
There may be an Apache code project that provides an xslt to provide a pdf fpo object, but I wasn't able to find that.
If the source were LaTeX, TeX or Docbook, it would be easy to modify the source in a script and then produce a pdf using pdflatex or pdftex.
I think that Open Office Writer has a LaTeX export feature. I don't know how well the final results would be however. I looked in Libre Office Write and this feature doesn't exist.
One option is to modify the footer in a script (from the odt expanded source); recompress; and run openoffice in the background to load and export to pdf.
There are xml to LaTex and xml to TeX converters as well. You could use them instead of openoffice.
There is a writer2latex project on sourceforge. http://writer2latex.sourceforge.net/index.html
|
|
|
04-04-2011, 02:13 AM
|
#9
|
Member
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34
Original Poster
Rep:
|
Ok, now I have to try your contributions!
1. from Guttorm:
Quote:
...first export it as PDF, and then use pdftk to add the footer as background. The background pdf can be made with for example fpdf...
|
2. from jschiwal:
Quote:
...If the source were LaTeX, TeX or Docbook, it would be easy to modify the source in a script and then produce a pdf using pdflatex or pdftex...
|
Theese are good solutions that I have to study... May be I'll need your help again if somethings goes wrong ;-)
See you, Pier.
|
|
|
04-05-2011, 02:07 AM
|
#10
|
Member
Registered: Jul 2004
Location: Chennai, India
Posts: 952
|
The problem with saving inb pdf is that it is final. You cant edit the saved (pdf) file using OO/libre.
I usually keep my basic data in ODT / ODS and save as pdf when I want to distribute. You can put header/footer information - with current information like data/time etc.
OK
|
|
|
04-05-2011, 03:13 AM
|
#11
|
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379
Rep: 
|
Quote:
Originally Posted by AnanthaP
The problem with saving inb pdf is that it is final. You cant edit the saved (pdf) file using OO/libre.
|
But as Guttorm pointed out there are other tools that will do the job for you. Such as pdftk
|
|
|
04-05-2011, 05:48 AM
|
#12
|
Member
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34
Original Poster
Rep:
|
Hi, I'm back...
I'm tring the pdftk solution. This is a command line app. My problem is to be able to produce the final pdf via web (php). Is it possible to join this application with the php? I mean invoking programs outside the php server... (pdflatex is the same).
Bye.
|
|
|
04-05-2011, 07:09 AM
|
#13
|
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466
|
Hi
You can run command line apps with PHP. See for example:
http://www.php.net/manual/en/book.exec.php
|
|
|
All times are GMT -5. The time now is 08:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|