Convert PDF file to XLSX using liberoffice command line - node.js

I'm using the below command which is intended to convert PDF files to XLSX format
soffice --infilter="writer_pdf_import" --convert-to xlsx:"Calc MS Excel 2007 XML" excel.pdf --outdir test.xlsx
But I'm getting an error message which states Application Error. I need to know what is wrong with my command and solution to convert PDF files to XLSX.

Related

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
Managed to do it with soffice.
I had to install this package: libreoffice-pdfimport
And don't forget to use --infilter="writer_pdf_import"
Linux has a few apps that can import a pdf as an image: LibreOffice, Okular, Calibre.
But if you want editable text, then you need to install the pdf toolkit pdftk, then run the conversion utility pdf2txt. The terminal command is:
pdf2txt input.pdf output.txt
Thereafter, import the txt file into a wordpro, and complete the final editing/formatting.

Converting xls to semicolon delimited csv with soffice commandline

I'm trying to convert xls files in a directory to csv format using soffice.
soffice --headless --convert-to csv *
It is giving comma separated version(obviously). Now I want to get semi-colon delimited csv.
I thought of replacing commas with semi-colons using vim command.
:%s/,/;/g
But it's not correct, as it replaces commas which are kept intentionally in original content. It has to delimit while converting from xls to csv.
How to get semi-colon delimited csv with soffice command line?
Finally, I got an answer. Adding output_filter_options worked like a charm.
--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files
This wiki link helped. Here is what I did,
soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":59,34,0,1,1 *.xls
NOTE: It works with libre office 4.3 or higher version.

How to convert BCP exported .xls file to actual Excel format file?

I have a batch file with the statement below. The export works fine and results are in the file Corp.xls. However, when I try to open this file, I get a warning 'The file you are trying to open is in a different format that that specified by the file extenion ..........
When I open the file and try to 'Save As', I find that it is in Text-tab delimted format.
Is there any way to convert such a file to excel without having to open the file - i.e from the batch file ?
Note: The batch file is very comples. Given below is just a modified snippet.
BCP "exec DBname.dbo.sp_abc '201503' " queryout "\\ABC\3_MAR\Corp.xls" -T -c -S SCC-SLDB

Unocov and libreoffice command line .svg conversion error

I'm trying to convert .png to .svg files using unoconv. The command line tool seems to work well with other formats, but is giving me the following error for conversion to svg files specifically:
$ unoconv -f svg ./sample.png
Unable to store document to file:///sample.svg (ErrCode 3088)
I've successfully used the tool with other formats, and the unoconv page even indicates that the .svg ouput format is supported.
I thought the issue might have something to do with the libreoffice used by unoconv, so I tried using the libreoffice command line tool directly. I used both of the following commands with no success:
./soffice --headless --invisible --convert-to svg --outdir ./result ./sample.png
./soffice --headless --invisible --convert-to svg:"impress_svg_Export" --outdir ./result ./sample.png
Both commands resulted in Error: Please reverify input parameters..., although the first command worked perfectly for when jpeg was used rather than svg.

Libreoffice in command line mode: Multiline cells are lost during Excel conversion to pdf

I'm trying to convert an Excel file that contains multiline cells to PDF. The cells are all on one line in the generated PDF.
Here is the command I use :
soffice --headless --convert-to pdf:writer_pdf_Export "test.xlsx" --outdir "tmp/"
Can someone help me ?

Resources