Merge Multiple Documents and Convert to One Pdf in LibreOffice from Terminal

7,267

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:
7,267
kubilay
Author by

kubilay

PHP and iOS developer from Turkiye. Big fan of *nix. @kublaios

Updated on September 18, 2022

Comments

  • kubilay
    kubilay over 1 year

    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:

    file1.docx
    file2.docx
    file3.docx  
    

    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.

  • kubilay
    kubilay almost 12 years
    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.
  • Agmenor
    Agmenor almost 12 years
    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 ?