开发者

How to Generate PDF file from .docx from linux server?

开发者 https://www.devze.com 2023-02-04 05:18 出处:网络
We use on our production server: Ubuntu 10 server edition. We need to create a document that includes text , images andtables in the contentand images in header and footer.

We use on our production server: Ubuntu 10 server edition. We need to create a document that includes text , images and tables in the content and images in header and footer. Now we use http://phpword.codeplex.com/ to create it and it does a great job generating docx files but we need the pdf version of that file. How can we convert the docx to pdf ? Or any other library to generate pdf files that allows images in heade开发者_开发知识库r /footer ? Using windows components is not a solution. Using openOffice maybe? can it be used on an ubuntu server edition ? any other convertor for docx to pdf in linux - server environment ?


If your documents include images using OpenOffice is definitely a good solution. Check out PyODConverter if you want to try this out.

If it's simple text you might want to consider using a simpler solution like PHPDocx, unoconv, AbiWord or LiveDocx.

I've used OOo in the past for this (and still use to convert Odt files to Pdf) and it works great. :) I only got one problem with it, but has already been resolved. You can check that out here: Docx to pdf using openoffice headless way too slow

EDIT:

I've created a bash script "/etc/init.d/openoffice" to start openoffice with the correct options. The file contents are the following:

#!/bin/bash
# openoffice.org headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice

OOo_HOME=/usr/lib/openoffice
SOFFICE_PATH=$OOo_HOME/program/soffice

if [ "$1" == "start" ]; then
 echo "Starting OpenOffice headless server"
 $SOFFICE_PATH --headless --accept="pipe,name=beubi_OOffice;urp;StarOffice.ServiceManager" --invisible --norestore --nodefault --nolockcheck --nofirstwizard
 exit
fi

if [ "$1" == "stop" ]; then
 echo "Stopping OpenOffice headless server."
 killall -9 soffice.bin && killall -9 soffice
 exit
fi

echo "Usage: $0 {start|stop}"
exit 1

Then just set execute permission on it and you should be ready to go.


You could try docx4j (Java). It can generate pdfs, and images in headers shouldn't be a problem.

Update May 2016

For the last year or so, we've been offering a high quality commercial docx to PDF converter which runs on Linux (and Solaris for that matter); try it at http://converter-eval.plutext.com/ where you can also download an installer.

0

精彩评论

暂无评论...
验证码 换一张
取 消