How to Batch Convert Writer Documents to PDF in LibreOffice

This advanced tutorial would help you to convert multiple docx, odf, odt files to PDF using the free LibreOffice office suite.

Converting multiple Microsoft Word *.docx, *.doc OR open document format files – *.odf, *.odt files to PDF at once can be tricky. Specially, if you are dealing with hundreds of files and need to convert them in batch. You can convert hundreds, thousands of files to PDF using free LibreOffice office suite. Here’s how.

Steps to convert document files to PDF

Note: The steps are different for Windows and Linux. Follow accordingly.

Convert a single file

  • In Windows systems (tested in Windows 10), open command prompt or Press Windows+R and type ‘cmd’ – press enter.
  • In the command prompt type below command:
"C:\Program Files (x86)\LibreOffice 5\program\swriter.exe" --headless --convert-to pdf Untitled1.odt
  • In Linux systems including Ubuntu as well, open terminal (CTRL+ALT+T) and run below commands:
lowriter --headless --convert-to pdf Untitled1.odt

Note:

  • By default the installation directory of LibreOffice is in above path for Windows 10. If you have installed in a different path, change accordingly.
  • The document Untitled1.odt would be converted to Untitled1.pdf in the same directory as the odt.
  • If you have a docx Word file, you can specify the same in place of Untitled1.odt.

Convert multiple files in batch

  • Converting multiple files is bit tricky due to different way of handling wildcard characters in Windows.
  • Open command prompt or Press Windows+R and type ‘cmd’ – press enter.
  • In the command prompt type below three lines exactly as below. Enter each line and press enter.
  • You can change *.odt in the first line to *.docx for Word files.
For %f in (*.odt) do (
"C:\Program Files (x86)\LibreOffice 5\program\swriter.exe" --headless --convert-to pdf %f
)
  • In Linux systems including Ubuntu as well, open terminal (CTRL+ALT+T) and run below commands:
lowriter --headless --convert-to pdf *.odt
  • Wait till above command executes. It takes some time to convert each document. On an average it takes approx 20 to 30 seconds per file (2 page) on Windows 10.
  • After conversion check the folder of the source document for converted PDF files.
SEE ALSO:  How To Apply Different Orientation In Specific Writer Page
PDF File Creation in Linux
PDF File Creation in Linux

 

Conclusion

This is how you can easily convert multiple docx, odt files to pdf using LibreOffice Writer which is free. You do not need any other softwares or installers or pdf printers for this work.

Drop a comment below if this article helped you or if you have any questions.

Reference

--convert-to OutputFileExtension[:OutputFilterName]
[--outdir output_dir] [--convert-images-to]
Batch convert files (implies --headless). If --outdir
isn't specified, then current working directory is used
as output_dir. If --convert-images-to is given, its
parameter is taken as the target MIME format for *all*
images written to the output format. If --convert-to is
used more than once, the last value of OutputFileExtension
[:OutputFilterName] is effective. If --outdir is used more
than once, only its last value is effective. For example:
--convert-to pdf *.odt
--convert-to epub *.doc
--convert-to pdf:writer_pdf_Export --outdir /home/user *.doc
--convert-to "html:XHTML Writer File:UTF8" *.doc
--convert-to "txt:Text (encoded):UTF8" *.doc

Looking for something else?

Read our complete tutorial index of Calc, Writer, Impress and Draw.


Related

Support Us


Be an expert on LibreOffice.

Small and quality tutorials. Delivered. Thrice a week.


11 thoughts on “How to Batch Convert Writer Documents to PDF in LibreOffice

  1. For %f in (*.odt) do (
    “C:\Program Files (x86)\LibreOffice 5\program\swriter.exe” –headless –convert-to pdf %f
    timeout /T 18)

    The script need time to create the file, if you don’t add this command, it will execute whithout errors but no file will be create.
    Sorry for my english

  2. Brilliant! Converted 50 .doc files to .pdf in a fraction of a second. In Ubuntu 18.04.3, I used the following command in Terminal, after getting into the directory where my .doc files were:
    libreoffice6.1 –writer –headless –convert-to pdf *.doc
    Thanks a ton!

  3. For %f in (*.odt) do (
    “C:Program Files (x86)LibreOffice 5programswriter.exe” –headless –convert-to pdf %f
    timeout /T 18)

    The script need time to create the file, if you don’t add this command, it will execute whithout errors but no file will be create.
    Sorry for my english

  4. Hi there, thank you for your help;
    Executing the scripts gets always the error: “”LibreOffice 6.3 Die Anwendung kann nicht gestartet werden – ein interner Fehler ist aufgetreten” (starting swriter was not possible – internal error”
    Using W10 1909 Build 18323.720
    Restart – no change, new installation LO – no change

  5. I had to adjust your command line but works perfectly in the end in windows cmd.

    I also included a command to write names of processed files in a text file.
    It helps to convert all the files (and slows down the proccess and allows to create all the pdf files – otherwise some of the odt files are skipped during the batch conversion)

    For %f in (*.odt) do ( “C:\Program Files\LibreOffice\program\soffice.exe” –headless –convert-to pdf “%f” | echo %f >> C:\1\list.txt )

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top