LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 04-03-2011, 12:35 AM   #1
pierquesti
Member
 
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34

Rep: Reputation: 15
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
 
Old 04-03-2011, 02:15 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Why don't you just do the conversion within the office suite? Libre/Open Office has a converter to pdf.
 
Old 04-03-2011, 03:26 AM   #3
pierquesti
Member
 
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34

Original Poster
Rep: Reputation: 15
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 ;-)
 
Old 04-03-2011, 03:44 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 04-03-2011, 04:23 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
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.
 
Old 04-03-2011, 04:56 AM   #6
pierquesti
Member
 
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34

Original Poster
Rep: Reputation: 15
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.
 
Old 04-03-2011, 05:58 AM   #7
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
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.
 
Old 04-03-2011, 07:45 PM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
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
 
Old 04-04-2011, 02:13 AM   #9
pierquesti
Member
 
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34

Original Poster
Rep: Reputation: 15
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.
 
Old 04-05-2011, 02:07 AM   #10
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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
 
Old 04-05-2011, 03:13 AM   #11
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by AnanthaP View Post
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
 
Old 04-05-2011, 05:48 AM   #12
pierquesti
Member
 
Registered: Feb 2006
Location: Toscana, Italy.
Distribution: Mint 10, Ubuntu 11.04
Posts: 34

Original Poster
Rep: Reputation: 15
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.
 
Old 04-05-2011, 07:09 AM   #13
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Hi

You can run command line apps with PHP. See for example:

http://www.php.net/manual/en/book.exec.php
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PDF to DOC Converter? vivek.sonny.abraham Linux - Software 20 11-30-2011 03:36 PM
pdf OR odt Strange Print Problems johnkelly.110 Linux - Newbie 4 09-15-2010 01:41 AM
to pdf converter deco81 Linux - Software 6 08-18-2010 07:20 PM
Convert ODT to PDF CartmanYO Linux - Software 10 12-13-2009 08:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration