Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On a production web server I have to produce letters based on a template I got in MS-Word binary format. I use PHP and for the search and replace task I found PHPWord, which can handle Docx files, so I converted the template to OpenXML on my local workstation. Unfortunately the output also is Docx.

The goal is to produce a single PDF for the user to download so she can print out a bunch of letters at once very easily.

Now I need to find a way to either:

  • Search and replace text in a PDF file
  • Convert Docx to PDF without loss of formatting
  • Edit the original Doc template without loss of formatting and without using COM
  • Convert Docx to Doc without loss of formatting (which seems nearly impossible for the template looks good in word but technically how the formatting is done is a big pile of...) so I could convert it using wvPDF

What I don't want to use besides OpenOffice.org are web services. I'm aware of PHPLiveDocx but I don't want to depend on an external service for performance, availability, security reasons. Also buying a piece of software isn't an option in this case (can't influence that).

Running on a public facing web server I don't want to pull OpenOffice.org - not even headless, as it will pull around 160MB of compressed(!) binaries and best practice is not no load binaries you don't really need on a public facing server. Though it's a last resort to use oo.o I want to make sure I have ruled out any other options there may have been.

The host OS is CentOS 5.5.

Where can I go from here?

Regards, luxifer

share|improve this question
    
Can you edit your question and integrate your updates into the question? It would make it easier to read, see here, thanks: meta.askubuntu.com/questions/908/… –  Jorge Castro Feb 1 '11 at 0:14
    
no problem... should be clarified now :-) –  luxifer Feb 1 '11 at 7:50
1  
If you're using CentOS, why is this on AskUbuntu rather than Unix and Linux SE? –  frabjous Feb 1 '11 at 19:17
    
because our new web servers will run ubuntu plus in my experience the ubuntu community tends to be more exerted in finding a good answer... –  luxifer Feb 2 '11 at 7:12
    
A year late and a buck short for your purposes, but it looks like the unoconv package for Ubuntu 12.04.2 LTS no longer has any requied openoffice.org dependencies. –  chucksmash Mar 28 '13 at 18:02

4 Answers 4

up vote 8 down vote accepted

To my knowledge there is no application that can do this without some dependency from Libre Office.

However you don't need to install the whole office suite when only performing commandline conversions.

You can try if the tool unoconv Install unoconv meets your needs. It has python and python-uno as a dependency. The latter will also install libreoffice-core as a dependency but not the whole office suite.

share|improve this answer
    
it depends on python-uno, which depends on openoffice.org-core :( –  luxifer Jan 31 '11 at 12:58
    
that's the black magic of dependencies ;) sorry to hear. –  Takkat Jan 31 '11 at 13:15
2  
You haven't explained why you don't want to install openoffice.org. Obviously, you wouldn't want to install the GUI components, but are you so prejudiced against it that you can't allow a headless install? –  Ryan Thompson Jan 31 '11 at 22:15
2  
even headless will pull around 160mb of data including java and that's its compressed size! it's just good practice not to pull loads of executable code on a production server if you have an alternative (which I'm seeking :-))... so pulling openoffice is kind of like a last resort for me –  luxifer Feb 1 '11 at 7:29
    
I finally gave up on the topic... It just seems impossible. I gave in on using OpenOffice and Odt files as templates. At least it works and it wouldn't be economic to hunt for another solution after trying all this... sigh thanks to all of you offering solutions! –  luxifer Feb 4 '11 at 7:24

AbiWord will convert between any formats it knows from the command line, which includes all those you mention. E.g,. to convert odt to pdf:

abiword --to=pdf filename.odt

to convert .docx to .doc:

abiword --to=doc filename.docx

(If you want to search it it, just convert to something plain-text based like HTML or RTF or even TXT and search in there; convert back if need be.)

But what exactly are the obvious reasons not to install OpenOffice so you can use its libraries with, e.g., unoconv?

share|improve this answer
    
I'll try that one... obviously abiworld will pull gui dependencies I don't need or want, too, but not as many as openoffice... I think I'll look in custom compiling both of them today to see if it could be stripped down a bit more –  luxifer Feb 1 '11 at 7:30
    
Unless you're really hurting for disk space, I don't see what the big deal is for installing GUI dependencies. You don't need to use them or load them, so they shouldn't slow down your system. –  frabjous Feb 1 '11 at 19:16

You could try AbiWord server side example given in this link http://www.advogato.org/person/msevior/diary.html?start=65

share|improve this answer
    
that looks promising at the first glance... I'll look into that one, too, today –  luxifer Feb 1 '11 at 7:54
    
just downloaded the latest stable sources and there's no abicommand plugin... it's listed in the plugin matrix page at the abiword wiki though... still, I have yet to figure why it's missing and where to get it :-) Until that i'll give it a try without that plugin –  luxifer Feb 1 '11 at 9:02
    
still I cannot find the abicommand plugin in the current source... do I have to get it from somewhere else? the abiwiki isn't exactly clear about this –  luxifer Feb 2 '11 at 8:48

Try with PyODConverter (see here)

share|improve this answer
1  
it's using openoffice.org to do the trick, so unfortunately this is not for me :( –  luxifer Jan 31 '11 at 10:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.