While working on this I found another problem with the page size setup. With -origpagesizes setpagedevice is output twice. The first time by the pdfSetupPaper PS macro (which calls setoutputdevice) using imgURX, imgURY which is the media box size. Then setpagedevice is output with width, height.
There is also this comment
// Set page size only when it actually changes, as otherwise Duplex
// printing does not work
so I'm not sure how this can be correct since the pdfSetupPaper is unconditionally calling setpagedevice.
Till, could you look at this and see if it can be fixed to only output setpagedevice once (preferably using the pdfSetupPaper macro since that is what is used for mode = psModePS.
While working on this I found another problem with the page size setup. With -origpagesizes setpagedevice is output twice. The first time by the pdfSetupPaper PS macro (which calls setoutputdevice) using imgURX, imgURY which is the media box size. Then setpagedevice is output with width, height.
There is also this comment
// Set page size only when it actually changes, as otherwise Duplex
// printing does not work
so I'm not sure how this can be correct since the pdfSetupPaper is unconditionally calling setpagedevice.
Till, could you look at this and see if it can be fixed to only output setpagedevice once (preferably using the pdfSetupPaper macro since that is what is used for mode = psModePS.