Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my Ubuntu Server 12.04, I am converting all .docx files under a directory to .pdf files with this command:

libreoffice -headless -convert-to pdf:writer_pdf_Export *.docx

Can I merge multiple documents and convert them to single .pdf file like this?

For example:


And the output should be one .pdf file like merged_result.pdf. I have to do it from Terminal because I'm using it in PHP.

Furthermore, can I add picture like front image? Any kind of source I can get the Terminal functions for LibreOffice is appreciated, too; I was unable to find what I'm looking for.

Thanks in advance.

share|improve this question
up vote 3 down vote accepted

Maybe you could use an additional tool, like pdftk for instance, to do the merging part. You could then chain the two commands; the first one with Libreoffice, the second one with pdftk.

share|improve this answer
I just was wondering if I could solve it with only one comment/plugin. Thanks, I tried pdftk and it's working good(I tried .docx, .xlsx and .jpg so far). One more question, do you know a way to add line numbers? Neither using LibreOffice nor pdftk. – kubilay Jun 23 '12 at 20:54
No I don't. Please consider opening new question. By the way, I think I should say this to you: don't forget to upvote good answers, eventually in addition to marking as accepted. I see that here on Stack Overflow you barely do it. It gives points to the answerer, which is an indicator for community trust and a mean to get more privileges on a Stack Exchange website. Do you see what I mean ? – Agmenor Jun 23 '12 at 21:12
sure, thanks for your help. – kubilay Jun 23 '12 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.