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.

1 Answer 1


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.

  • 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, 2012 at 20:54
  • 1
    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, 2012 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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