I have, in the same directory, several odt files.

I'd like to have in one PDF document the first page of these odt files, sorted alphabetically based on their filename.

For example, if I have these files:

  • a.odt
  • b.odt
  • c.odt

I would have a resulting PDF that has 3 pages: the first one of a.odt, then the first one of b.odt and then the first one of c.pdf.

Does any one of you think about a command to do that?

1 Answer 1

for i in *.odt; do
  echo "Converting [ $i ]"
  unoconv -f pdf "$i"
  echo "Extracting 1st page of [ $i ]"
  pdftk P="$i" cat P1-1 output "$i".1
echo "Merging pdfs"
pdftk *.1 cat output result.pdf
rm *.1

You have to install unoconv and pdftk.

Ubuntu: sudo apt-get install unoconv pdftk

  • 1
    You should probably use pdftk to merge the PDFs, not convert. convert will rasterize all the pages, so the fonts and any vector artwork will be converted to bitmaps, increasing the size of the PDF and reducing its quality. Jun 24, 2014 at 13:00
  • One downside to pdftk is that it doesn't preserve bookmarks and metadata. You can create a dump of all metadata but importing it has never worked properly for me. If preserving this data is important to you, you can always use an alternative like sejda or cpdf. Jun 24, 2014 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .