Merging two PDF files in a single file

a month ago

Execute:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf

Export each page to a PNG with transparent background (-r600 means 600 dpi resolution):

gs -sDEVICE=pngalpha -o file-out-%03d.png -r600 file-in.pdf

This causes the internal rendering to be scaled down by the given (integer <= 8) factor before being output. For example, the following will produce a 200dpi output png from a 600dpi internal rendering:

gs -sDEVICE=png16m -dDownScaleFactor=3 -o file-out-%03d.png -r600 file-in.pdf