Cookie Into the (open) source


LibreOffice from terminal: convert to PDF


This article was written in the 2013, there may have been some developments in the subject matter.
If in doubt please leave a comment in the bottom of the article.

With today's article we complete the article in the 31 May concerning the Printing from Client to Server, no drivers whatsoever. Perhaps not everyone knows that LibreOffice and OpenOffice integrate between their packages some commands from flipping through the terminal. These commands are identical for all operating systems (you, for Windows) and produce the same results. Among these we see today is the syntax for convert any file type through terminal opened with LibreOffice / OpenOffice in PDF.

The command for Linux is as follows:

soffice --headless --invisible --convert-to pdf /dir/file.pptx --outdir /dir

It is clear that adding a line to our crontab file can automate the process:

# print server
* * * * * soffice --headless --invisible --convert-to pdf /var/www/uploader/upload/* --outdir ./
* * * * * sleep 15; lpr / var / www / uploads / upload / * | sleep 30; mv / var / www / uploader / uploads / * / var / www / uploader / deposits /
0 4 * * * rm-Rf / var / www / uploader / deposit / *

In this way ...

First line: crontab every minute converted in PDF all files in the directory (those referred LibreOffice recognize the extension),

Second line: crontab expected 15 seconds to facilitate the conversion process, the files are then printed and after another 30 seconds moved in the directory "deposit",

Third row: four in the morning files "deposited" are deleted definitely.


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.

Comments (2) Trackbacks (0)
  1. Ciao Marco,
    the article is clearly written: “The command for Linux is as follows […]”. I honestly do not know how you could do with windows (I do not have a copy handy). Try looking on the net.

    However, if you only need to convert a document that you can just click to open “file” – “Export in pdf format”.

    Good luck.

  2. Hello.
    My level is soooo amateur.
    I installed LibreOffice, and is located in the folder C:/Programs / LibreOffice 4.
    Can you tell me step by step how to launch that command you specified above, to convert a file that is on my desktop(prova.docx) a pdf file (prova.pdf) that you will always find on your desktop?
    Thanks a lot in advance.

Leave a comment

No trackbacks yet.