I am using qpdf to merge all pdf files in a directory and I would like to merge only the first page of multiple inputfiles. According to the qpdf documentation on page selection this should be possible. I have tried couple variants without luck:
qpdf --empty --pages *.pdf 1-1 -- "output.pdf"
qpdf --empty --pages *.pdf 1 -- "output.pdf"
What can I do?
As explained in this qpdf issue, the shell expands
*.pdfin the commandqpdf --empty --pages *.pdf 1 -- "output.pdf", that means it replaces*.pdfwith a list of pdf files in the current directory. Assuming you have the following pdf files in the current directory:file1.pdffile2.pdffile3.pdfthe command becomes:
so the page selector is only applied to the last pdf. On a Mac or Linux you can script the command to add a
1after each pdf-filename, to take the first page of each pdf file and put it all together like so: