How to Batch Convert Writer Documents to PDF in LibreOffice


This advanced tutorial would help you to batch convert Writer documents (docx, odf, odt) 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. Especially, if you are dealing with hundreds of files and need to convert them into PDF in batches. You can convert hundreds, thousands of files to PDF using the free LibreOffice office suite.

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 the command prompt or Press Windows+R and type ‘cmd’ and press enter.
  • In the command prompt, type the 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 the terminal (CTRL+ALT+T) and run the below command:
lowriter --headless --convert-to pdf Untitled1.odt


  • By default, the installation directory of LibreOffice is in the above path for Windows 10 & Windows 11. If you have installed it on 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 via batch mode

  • Converting multiple files is tricky due to different ways of handling wildcard characters in Windows.
  • Open the command prompt or Press Windows+R and type ‘cmd’ – enter.
  • In the command prompt, type three lines precisely 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 the terminal (CTRL+ALT+T) and run the below commands:
lowriter --headless --convert-to pdf *.odt
  • Wait till the above command executes. It takes some time to convert each document. On average, it takes approximately 20 to 30 seconds per file (2 pages) on Windows 10.
  • After conversion, check the folder of the source document for converted PDF files.
Batch convert Writer documents in Linux
Batch convert Writer documents in Linux

Additional Options for batch conversation via command line (LibreOffice 7.4 and above)

LibreOffice 7.4 and above offers the following options for better control while using the command line. Here are some examples.

  • Skip the first page while converting a Draw document to PDF.
soffice --convert-to 'pdf:draw_pdf_Export:{"PageRange":{"type":"string","value":"2-"}}' test.odg
  • Add a watermark in the PDF
soffice --convert-to 'pdf:draw_pdf_Export:{"TiledWatermark":{"type":"string","value":"draft"}}' test.odg
  • Add a password to the PDF document while converting. Change the below “secret” string to your password.
soffice --convert-to 'pdf:draw_pdf_Export:{"EncryptFile":{"type":"boolean","value":"true"},"DocumentOpenPassword":{"type":"string","value":"secret"}}' test.odg
  • Change the PDF writer version of your output PDF
soffice --convert-to 'pdf:draw_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"15"}}' test.odg
  • Sign the PDF.
soffice --convert-to 'pdf:draw_pdf_Export:{"SignPDF":{"type":"boolean","value":"true"},"SignCertificateSubjectName":{"type":"string","value":"CN=…"}}' test.odg


The above methods explain how you can easily batch convert Writer documents (docx, odt) to pdf using free LibreOffice Writer. You do not need any other software, installers, or pdf printers for this work.

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


--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.

Join our Telegram channel and stay informed on the move.


Creator of libreofficehelp.com. The aim is to help as many people with easy-to-understand tutorials and no BS. Connect with me via Telegram, Twitter, LinkedIn, or send us an email.

Notify of

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

Newest Most Voted
Inline Feedbacks
View all comments
Pedro de Alcântara Teixeira Junior

The method stated by the author to convert multiple files didn’t work for me. I was trying to convert my word files (with extension .doc) to pdf files using the above instructions, but no success. It took me a lot of time to figure it out how to do it properly, so I will share my solution here (Notice that I am running Libreoffice version, 64 bits on Windows 10, I don’t know the syntax on Linux).

I opened a prompt (Windows + R, then type CMD), navigated to the folder where my doc files where, and then simply used the following command (all in one line, not in “three lines”, lik suggested!):

for %f in ("*.doc") do "C:\Program Files\LibreOffice\program\soffice" --convert-to pdf "%f"

(the difference is the double-quotes in the expressions *.doc and %f)

1 – If you have docx files, simply adapt the command line, using “*.docx” instead of “*.doc”. The same goes for any libreoffice document (odg, odt, etc);
2 – Check the LibreOffice path beforehand, because depending on the settings, you may need to replace the “C:\Program Files\LibreOffice\program\soffice” with your PC’s path for the soffice.exe file;
3 – To use the command above in a batch file for ease of use (in case you need to run that command more than once in different folders), you need to use %% instead of % (two percentage symbols instead of one), so the example line would be like follows:

for %f in ("*.doc") do "C:\Program Files\LibreOffice\program\soffice" --convert-to pdf "%f"

Hope it saves you the headache I had to find this solution… 😉

Last edited 1 day ago by arindam

Thanks a lot for the hint of %%, I wasn’t understanding why it doesn’t work on a BAT file.


Acredito que vc fale português tbm, excelente dica para resolver o problema para quem quer criar um arquivo BAT.
Muito obrigado Pedro.


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


There is a better way using START /WAIT to wait for the topical process to finish before the next is started.

FOR %G IN (*.docx) DO (START /WAIT “” “C:\Program Files\LibreOffice\program\soffice.exe” –headless –convert-to pdf “%G”)

Otherwise the for-loop starts so many libreoffice processes that my pc chokes and arbitrarily skips files.

omnivor Rajan

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!


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


Thank you for your comment. It is helpful for our readers.


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


“C:\Programme\LibreOffice\Program\swriter.exe” exists


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 )


Where do you put original odt files?


It works for calc too (replacing lowriter with localc). You could update the post to generalize it.
this is very useful.


Windows 10 64

This command worked for me docx files

for %f in (“*.docx”) do “C:\Program Files\LibreOffice\program\soffice” –-convert-to pdf “%f”


Hello everyone,
I’d like to automatically convert all my libreoffice files to pdf on a USB key with directories organised in the same way as the original files. Do you know of any routine which could do that ?
Thank you,

Rich Langford

Excellent work, thanks.
Just one tip. If the filename has a space it will not convert (Windows 7, 64-bit). Easily solved with Renamer.

Guillermo Venuto

Thanks for the explanation. It works like a charm. Is there a way to select specific pages? eg. Page Range=3-4?


Dear Arindam,
Thank you for your article. I am trying to convert a csv to a xlsx document using this line of code:
for %f in (“D:\pabi\work\BSC\xlsxConvert\*.csv”) do “C:\Program Files\LibreOffice\program\soffice.exe” –convert-to xlsx “%f”

It works. However the xlsx file gets in Cell A1 these strange characters “”.I have tried xlsx or xls both show the same behaviour. Any idea how I may get rid of them?

Kind regards


I found out that the strange characters are called BOM (Byte Order Mark), whitch is standard in UTF8 Format. The tool I am using to creat the CSV is unable to export without BOM so it is not a problem of the converter used. I have to clean up my files after exporting it seems.

John Fredy Cortes Triana

Excellent and thanks, one question, works with Calc books?, in fact, Can do some directly with csv files to pdf?.

Last edited 11 months ago by John Fredy Cortes Triana

For windows (replace program path if needed): How to convert all *.doc to *.docx in all dirs starting with current dir:
“FOR /d /r %I IN (.) DO start “” /WAIT “c:\Program Files\LibreOffice\program\swriter.exe” –convert-to docx “%I\*.doc” –outdir “%I””

Last edited 3 months ago by dobandvla

it seems images are not exported to pdf.


This post saved my day. Thanks a lot.



I used this article to convert multiple ODT files to PDF at once with success.

I used an improved version of the article command line, found in the comment section, because I like to have a log.

Since I am using a portable version of LibreOffice, the command line then is:

For %f in (*.odt) do ( "C:\storage\POR\[v6]LibreOfficePortable\App\libreoffice\program\soffice.exe" -headless -convert-to pdf "%f" | echo %f >> C:\temp\list.txt )

This worked like a charm with writer files having spaces in their name, and tables and colors in them.

Thank you


Windows 10 Enterprise
Coffee Extension Association

Last edited 1 day ago by arindam

-convert-to deprecated need to use –-convert-to and no need for for loops just do
C:\Program Files\LibreOffice\program\writer.exe –-convert-to pdf *.odt
does all files in batch by itself.

Would love your thoughts, please comment.x