Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert PDF to DOCX on linux

I try to convert pdf file to word, excel and powerpoint. I already tried a lot of command like these:

soffice -env:UserInstallation=file:///$HOME/.libreoffice-headless/ --convert-to docx:"Microsoft Word 2007/2010/2013 XML" file.pdf
/usr/bin/soffice --headless --invisible --convert-to docx file.pdf
soffice --infilter="writer_pdf_import" --convert-to doc file.pdf

/usr/bin/libreoffice --headless --invisible --convert-to doc file.pdf
/usr/bin/soffice --headless --convert-to docx:"Microsoft Word 2007/2010/2013 XML" file.pdf

abiword --to=doc file.pdf
unoconv -f doc file.pdf
lowriter --invisible --convert-to doc 'file.pdf'

Always got this error message from soffice/libreoffice/unoconv:

:1: parser error : Document is empty
%PDF-1.7

And this one for abiword

Unable to init server: Could not connect: Connection refused

** (abiword:6477): WARNING **: clutter failed 0, get a life.
Unable to init server: Could not connect: Connection refused

With every command but abiword. I got a doc file with bad character inside. But never get a proper file.

I try to create a file converter so I only want command line method. Don't want to use someone API.

Thank you

like image 913
Splinteer Avatar asked Oct 17 '18 11:10

Splinteer


People also ask

How do I convert PDF to DOCX?

Follow these easy steps to turn a PDF into a Microsoft Word document: Click the Select a file button above or drag and drop a PDF into the drop zone. Select the PDF you want to convert to the DOCX file format. Watch Acrobat automatically convert the file from PDF to Word document.

Can LibreOffice convert PDF to ODT?

Libre Office Writer does not convert . pdf files to . odt. The feature is very much in demand in the form of a process that does not require programming skills.


1 Answers

Managed to do it with soffice. I had to install this package: libreoffice-pdfimport And don't forget to use --infilter="writer_pdf_import"

like image 166
Splinteer Avatar answered Sep 20 '22 06:09

Splinteer