Ask Your Question

# Revision history [back]

### soffice.bin on Windows command line

LibreOffice v4.0.4.2
Windows 7 Business

I have a series of questions about converting documents to PDF with LibreOffice on the command line.

1. Can LibreOffice convert a multi page tiff image into a multi page PDF file?

I am using the following command:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/multi_page.tif

The About Import and Export Filters (help.libreoffice.org/Common/About_Import_and_Export_Filters) page seems to suggest that it can, but I am unable to make it work. The page states "Multipage-TIFFs are allowed when graphics are imported or exported in TIFF format". However, when I try to convert the tiff file to pdf only page 1 is saved. All subsequent pages in the tiff are dropped.

2. Can soffice.bin report an error code and error message for a failed command?

Given the following valid command with an invalid input file:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/I_do_not_exist.xls

LibreOffice silently fails with no indication that anything went wrong. No warning/error diagnostic is printed to STDOUT or STDERR, and the Windows %ERRORLEVEL% variable remains unchanged. Is there an option to enable verbose error reporting for soffice? Is there a better way of doing this on Windows? Am I going about this the wrong way?

3. What is the best way to pass a large number of input files without exceeding the command line length?

I am batch converting many thousands of files and will certainly run afoul of CMD.exe's 8192 character command line length limit if I tried to list all the files out.

From what I can tell I only have the following two options available:
Call soffice.bin with each individual file one-by-one (easy to implement, but very slow since LibreOffice will startup and shut down for each file)
Call soffice.bin with batches of files (faster than calling it for each individual file, but requires more calculations to ensure the command line character limit is not exceeded).

Are there any other ways to pass input files to soffice.bin?
For example, GhostScript allows you to specify a name of a file with '@' appended to the beginning, '@files.txt', that has all the input files listed on separate lines. Can LibreOffice do something similar?

4. Can LibreOffice append PDFs it creates to an existing PDF file?

The whole raison d'etre for all this is to take a bunch of dissimilar files (Excel workbooks, JPEG images, text files, TIFF images, Word documents, RTF files) and combine them all together into a single PDF.

I can convert the files into single PDFs just fine (with the exception of multipage TIFF images as mentioned above), but I was wondering if there was a way to merge them into a single PDF instead. Can LibreOffice do this, or should I leave that task up to a dedicated program like GhostScript?

Thank you for your time.

### soffice.bin on Windows command line

LibreOffice v4.0.4.2
Windows 7 Business

I have a series of questions about converting documents to PDF with LibreOffice on the command line.

1. Can LibreOffice convert a multi page tiff image into a multi page PDF file?
(edit: No it cannot at this time. Use GhostScript instead.)

I am using the following command:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/multi_page.tif

The About Import and Export Filters (help.libreoffice.org/Common/About_Import_and_Export_Filters) page seems to suggest that it can, but I am unable to make it work. The page states "Multipage-TIFFs are allowed when graphics are imported or exported in TIFF format". However, when I try to convert the tiff file to pdf only page 1 is saved. All subsequent pages in the tiff are dropped.

2. Can soffice.bin report an error code and error message for a failed command?
(edit: This has been reported as a bug: fdo#67009)

Given the following valid command with an invalid input file:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/I_do_not_exist.xls

LibreOffice silently fails with no indication that anything went wrong. No warning/error diagnostic is printed to STDOUT or STDERR, and the Windows %ERRORLEVEL% variable remains unchanged. Is there an option to enable verbose error reporting for soffice? Is there a better way of doing this on Windows? Am I going about this the wrong way?

3. What is the best way to pass a large number of input files without exceeding the command line length?
(edit: Use file globbing and send batches of files to soffice.bin)

I am batch converting many thousands of files and will certainly run afoul of CMD.exe's 8192 character command line length limit if I tried to list all the files out.

From what I can tell I only have the following two options available:
Call soffice.bin with each individual file one-by-one (easy to implement, but very slow since LibreOffice will startup and shut down for each file)
Call soffice.bin with batches of files (faster than calling it for each individual file, but requires more calculations to ensure the command line character limit is not exceeded).

Are there any other ways to pass input files to soffice.bin?
For example, GhostScript allows you to specify a name of a file with '@' appended to the beginning, '@files.txt', that has all the input files listed on separate lines. Can LibreOffice do something similar?

4. Can LibreOffice append PDFs it creates to an existing PDF file?
(edit: No it cannot at this time. Use GhostScript instead.)

The whole raison d'etre for all this is to take a bunch of dissimilar files (Excel workbooks, JPEG images, text files, TIFF images, Word documents, RTF files) and combine them all together into a single PDF.

I can convert the files into single PDFs just fine (with the exception of multipage TIFF images as mentioned above), but I was wondering if there was a way to merge them into a single PDF instead. Can LibreOffice do this, or should I leave that task up to a dedicated program like GhostScript?

Thank you for your time.

 3 retagged Alex Kemp 10494 ●14 ●40 ●42 http://etmg.altervista...

### soffice.bin on Windows command line

LibreOffice v4.0.4.2
Windows 7 Business

I have a series of questions about converting documents to PDF with LibreOffice on the command line.

1. Can LibreOffice convert a multi page tiff image into a multi page PDF file?
(edit: No it cannot at this time. Use GhostScript instead.)

I am using the following command:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/multi_page.tif

The About Import and Export Filters (help.libreoffice.org/Common/About_Import_and_Export_Filters) page seems to suggest that it can, but I am unable to make it work. The page states "Multipage-TIFFs are allowed when graphics are imported or exported in TIFF format". However, when I try to convert the tiff file to pdf only page 1 is saved. All subsequent pages in the tiff are dropped.

2. Can soffice.bin report an error code and error message for a failed command?
(edit: This has been reported as a bug: fdo#67009)

Given the following valid command with an invalid input file:
soffice.bin -headless -convert-to pdf:writer_pdf_Export -outdir files/ files/I_do_not_exist.xls

LibreOffice silently fails with no indication that anything went wrong. No warning/error diagnostic is printed to STDOUT or STDERR, and the Windows %ERRORLEVEL% variable remains unchanged. Is there an option to enable verbose error reporting for soffice? Is there a better way of doing this on Windows? Am I going about this the wrong way?

3. What is the best way to pass a large number of input files without exceeding the command line length?
(edit: Use file globbing and send batches of files to soffice.bin)

I am batch converting many thousands of files and will certainly run afoul of CMD.exe's 8192 character command line length limit if I tried to list all the files out.

From what I can tell I only have the following two options available:
Call soffice.bin with each individual file one-by-one (easy to implement, but very slow since LibreOffice will startup and shut down for each file)
Call soffice.bin with batches of files (faster than calling it for each individual file, but requires more calculations to ensure the command line character limit is not exceeded).

Are there any other ways to pass input files to soffice.bin?
For example, GhostScript allows you to specify a name of a file with '@' appended to the beginning, '@files.txt', that has all the input files listed on separate lines. Can LibreOffice do something similar?

4. Can LibreOffice append PDFs it creates to an existing PDF file?
(edit: No it cannot at this time. Use GhostScript instead.)

The whole raison d'etre for all this is to take a bunch of dissimilar files (Excel workbooks, JPEG images, text files, TIFF images, Word documents, RTF files) and combine them all together into a single PDF.

I can convert the files into single PDFs just fine (with the exception of multipage TIFF images as mentioned above), but I was wondering if there was a way to merge them into a single PDF instead. Can LibreOffice do this, or should I leave that task up to a dedicated program like GhostScript?

Thank you for your time.