[Solved] Batch conversion of .docx to PDF

Discuss the word processor
Post Reply
Kmp
Posts: 4
Joined: Wed Apr 22, 2009 5:12 pm

[Solved] Batch conversion of .docx to PDF

Post by Kmp »

Welcome beginner. What is your question or comment?
Please try to briefly and clearly tell us: What you want, What you tried, and What happened.
-----------------------------------------------------------------------------------------------------------
Hello, I would like to ask if anyone knew of a way to batch convert many hundreds of .docx files to PDF. Since the Openoffice software already has a Export as PDF, but this is graphical and requires me to open every document.
Last edited by TheGurkha on Thu Apr 23, 2009 7:38 pm, edited 2 times in total.
Reason: Tagged [Solved].
OOo 3.0.X on Ubuntu 8.x
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: Batch conversion of .docx to PDF

Post by squenson »

How do you plan to open .docx with Writer? AFAIK, this is not yet supported. May be you should instead a virtual pdf printer (http://www.cutepdf.com)
LibreOffice 4.2.3.3. on Ubuntu 14.04
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Batch conversion of .docx to PDF

Post by Villeroy »

http://www.oooninja.com/2008/02/batch-c ... -with.html
oooninja wrote:PDF printer method

If you just want to generate PDF files, you don't need a Python script, a Basic macro, Java code, or any other kind of programming. Just install a PDF printer such as PDFCreator (Windows) or CUPS-PDF. Then, use the -pt command with the the first argument as the printer name and the second argument as the source document.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Cambirder
Volunteer
Posts: 647
Joined: Thu Nov 22, 2007 1:01 am

Re: Batch conversion of .docx to PDF

Post by Cambirder »

How do you plan to open .docx with Writer? AFAIK, this is not yet supported.
Yes it is, support was added in 3.0, although you can't save in that format.
OOo 3.3 on Windows 7 & 3.2.1 on Mint 10
Kmp
Posts: 4
Joined: Wed Apr 22, 2009 5:12 pm

Re: Batch conversion of .docx to PDF

Post by Kmp »

I found a way to batch convert my .docx documents to .pdf. The program is called JODConverter, and you can get it from http://www.artofsolving.com/ . The site have excellent guides but I am just going to write what I did.
First downloaded the jodconverter-2.2.2.zip and extracted it to the desktop.

the program use openoffice for the conversion, so you have to start openoffice as a service. Open the terminal and enter.

Code: Select all

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
This is what the command looked like when I converted.

Code: Select all

java -jar /home/user/Desktop/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar -f pdf /home/user/Desktop/folder/*.docx
To convert, you have to point to the needed jodconverter-cli-2.2.2.jar. It is in the archive we downloaded, so for me it was.

Code: Select all

/home/user/Desktop/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar
.
then to specify what output file you want to use, use

Code: Select all

-f filetype
could be -f odt or -f pdf. Afterwards you specify where the files you want to convert are

Code: Select all

/home/user/Desktop/folder/*.docx
To select all files types with docx. use *.docx .

That was it, and I can actually convert my docx files now. Thanks Villeroy for the link above, which led me to the JODConverter site.
Last edited by Kmp on Thu Apr 23, 2009 7:38 pm, edited 1 time in total.
OOo 3.0.X on Ubuntu 8.x
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: Batch conversion of .docx to PDF

Post by TheGurkha »

Thanks for the detailed feeback.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
lokeshmf
Posts: 18
Joined: Mon May 03, 2010 9:53 am

Re: [Solved] Batch conversion of .docx to PDF

Post by lokeshmf »

Hi kmp,

I am able to convert docx files to PDF using the commands below..

soffice -headless -accept="socket,host=localhost,port=8100;urp;" -nofirststartwizard

java -jar C:/jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar -f pdf C:/*.doc

but I am facing allignment problems and other like index is not coming and some table formats , pics are not coming in the PDF document.

Can u help me on this?
OpenOffice 3.2
Windows 2000
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] Batch conversion of .docx to PDF

Post by RoryOF »

Install a pdf printer on Windows MS Office and try that instead.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
lokeshmf
Posts: 18
Joined: Mon May 03, 2010 9:53 am

Re: [Solved] Batch conversion of .docx to PDF

Post by lokeshmf »

Can't we do it using open office?
OpenOffice 3.2
Windows 2000
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] Batch conversion of .docx to PDF

Post by RoryOF »

You have just found out how limited is OOo's support for docx files.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Kmp
Posts: 4
Joined: Wed Apr 22, 2009 5:12 pm

Re: [Solved] Batch conversion of .docx to PDF

Post by Kmp »

Like said before, the problem is AFAIK with openoffice not being apple to convert .docx filetypes properly, therefore there's nothing I can do. If you want there is another option that RoryOF suggested, being that you will have to download pdfcreator, which is a pdf printer, and print the files using MS office, or any other suite that can read the files properly. If you have many, you can right click the files and print them all at once, just be sure to que them with some time in between prints, because if you print them all at once, the computer may begin to act slow.
OOo 3.0.X on Ubuntu 8.x
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: [Solved] Batch conversion of .docx to PDF

Post by TheGurkha »

What about Zamzar? They ought to be able to do it.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
Kmp
Posts: 4
Joined: Wed Apr 22, 2009 5:12 pm

Re: [Solved] Batch conversion of .docx to PDF

Post by Kmp »

Just tried their service, and it works great. Converted a .docx file, with tables and images and it went through clean. Thank you for the link.
OOo 3.0.X on Ubuntu 8.x
lokeshmf
Posts: 18
Joined: Mon May 03, 2010 9:53 am

Re: [Solved] Batch conversion of .docx to PDF

Post by lokeshmf »

We need to convert docx to PDF using java and open office.

And more over we are not allowed to use any other converters or PDF printers.
OpenOffice 3.2
Windows 2000
DPell
Posts: 2
Joined: Sat Nov 03, 2012 6:42 am

Re: [Solved] Batch conversion of .docx to PDF

Post by DPell »

Actually the same site, artofsolving, has another alternative tool to the java-based JOD that is Python based -- pyodconverter -- [http://www.artofsolving.com/opensource/pyodconverter]. It works with OpenOffice and LibreOffice and looks like it may still be an active project [https://github.com/mirkonasato/pyodconverter]. I was happy to see a Python and LibreOffice based option as these are my preferred tools / products. LibreO has better support of doc standards and interoperability.
LibreOffice 3.6.3
Windows Vista and 7
DPell
Posts: 2
Joined: Sat Nov 03, 2012 6:42 am

Re: [Solved] Batch conversion of .docx to PDF

Post by DPell »

Additionall information for PyODConverter (from the ReadMe):

PyODConverter (for Python OpenDocument Converter) is a Python script that automates office document conversions from the command line using LibreOffice or OpenOffice.org.

The script was written as a simpler alternative to JODConverter for command line usage.
Usage

PyODConverter requires LibreOffice/OpenOffice.org to be running as a service and listening on port (by default) 2002; this can be achieved e.g. by starting it from the command line as

$ soffice "-accept=socket,port=2002;urp;"

The script expects exactly 2 parameters: an input and an output file names. The document formats are inferred from the file extensions.

Since it uses the Python/UNO bridge, the script requires the UNO modules to be already present in your Python installation. Most of the time this means you need to use the Python version installed with OpenOffice.org, e.g. on Windows

> "C:\Program Files\OpenOffice.org 3.1\program\python" DocumentConverter.py test.odt test.pdf

or on Linux

$ /opt/openoffice.org3.1/program/python DocumentConverter.py test.odt test.pdf

If you want to write your own scripts in Python, PyODConverter can also act as a Python module, exporting a DocumentConverter class with a very simple API.
LibreOffice 3.6.3
Windows Vista and 7
Post Reply