You can try to use Ghostscript for this. The following command will resize each individual PDF to A4:
for input in *.pdf ; do
gs \
-o A4-resized-${input} \
-sDEVICE=pdfwrite \
-dPDFFitPage \
-g5950x8420 \
-dPDFSETTINGS=/prepress \
${input}
done
This command will create a merged PDF from all input files, resizing each page in the process:
gs \
-o A4-resized-${input} \
-sDEVICE=pdfwrite \
-dPDFFitPage \
-g5950x8420 \
-dPDFSETTINGS=/prepress \
*.pdf
If the shell wildcard *.pdf
does not sort the pages to your liking, you have to do it by yourself:
[...gs-cmd...] input1.pdf input2.pdf input3.pdf [input4.pdf ...]
Caveats: The second option (merging and resizing the individual PDFs) may cause problems with fonts in the merged PDF in these cases:
- Your Ghostscript installation is not a recent version.
- Your input PDF files use subsetted fonts where the 'unique' prefix (such as
XAGTRU+
) to the font name is not unique at all but rather predictable. OpenOffice/LibreOffice and other PDF generators are known to always start their prefixes (predictably) as BAAAAA+
, CAAAAA+
, DAAAAA+
. This leads to multiple instances of BAAAAA+Arial
subsetted fonts injected by the input PDFs which are not unique but different and still use the same name.