I searched the stackoverflow for the problem. The nearest link is:
How to set custom page size with Ghostscript
How to convert multiple, different-sized PostScript files to a single PDF?
But this could NOT solve my problem.
The question is plain simple.
How can we combine multiple pdf (with different page sizes) into a combined pdf which have all the pages of same size.
Example:
two input pdfs are:
hw1.pdf with single page of size 5.43x3.26 inch (found from adobe reader)
hw6.pdf with single page of size 5.43x6.51 inch
The pdfs can be found here:
https://github.com/bhishanpdl/Questions
The code is:
gs -sDEVICE=pdfwrite -r720 -g2347x3909 -dPDFFitPage -o homeworks.pdf hw1.pdf hw6.pdf
PROBLEM: First pdf is portrait, and second page is landscape.
QUESTION: How can we make both pages portrait ?
NOTE:
-r720 is pixels/inch.
The size -g2347x3909 is found using python script:
wd = int(np.floor(720 * 5.43))
ht = int(np.floor(720 * 3.26))
gsize = '-g' + str(ht) + 'x' + str(wd) + ' '
# this gives: gsize = -g4308x6066
Another Attempt
commands = 'gs -o homeworks.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=674 ' +\
' -dDEVICEHEIGHTPOINTS=912 -dPDFFitPage ' +\
'hw1.pdf hw6.pdf'
subprocess.call(commands, shell=1)
This gives first both pages portrait, but they do not have the same size.
First page is smaller is size, and second is full when I open the output in adobe reader.
In general, how can we make size of all the pages same?