Centering objects in resize mode seems to be broken
I am pretty confident that this is not immediately related to pdfScale but rather to a change in one of its dependencies that leads to the outcome.
Expectation:
When a pdf (which in our sample case is a svg file that has been converted to a pdf) gets resized to a new file that has different dimensions than the original one the larger side of the content should fill 100% of the new page while the smaller side should be centered.
Current behaviour:
Resizeing also resizes the content as expected but they do not get centered/aligned correctly.
How to replicate
- Get a random pdf file (e.g. the Wikipedia Logo (svg > pdf)) Wikipedia_wordmark.pdf
- Try to resize the object — e.g. to a object with 700x400pt:
pdfscale -r "custom pt 700 400" Wikipedia_wordmark.pdf - Output Wikipedia_wordmark.CUSTOM.pdf
pdfscale v2.5.3 - Verbose Execution
Single Task: Resize PDF Paper
Dry-Run: FALSE
Input File: Wikipedia_wordmark.pdf
Output File: Wikipedia_wordmark.CUSTOM.pdf
Get Page Size: Adaptive Enabled
Method: Grep
Failed
Method: Mac Quartz mdls
Source Width: 375 postscript-points
Source Height: 64 postscript-points
Print Mode: Print ( auto/empty )
Scale Factor: Disabled (resize only)
Fit To Page: Enabled (default)
Auto Rotate: PageByPage
Flip Detect: No change needed
Run Resizing: CUSTOM ( 700 x 400 ) pts
Final Status: File created successfully
OS: macOS Monterey 12.2.1 (21D62)
GS: 9.56.1
Imagemagick: 7.1.0-36 Q16-HDRI arm 20076
BC: bc 1.06
Maybe as a small addon — I have another Mac running Big Sure 11.5.1 with the identical Imagemagick/BC setup but a slightly outdated GS Version (9.54.0) where everything outputs like expected — in case that is helpful.
Digging to the Ghostscript release notes indeed showed that a major changes has been implemented recently. It seems like the rewritten PDF interpreter has caused the issues mentioned above. https://www.ghostscript.com/doc/current/History9.htm
As a workaround adding the flag -dNEWPDF=false will force Ghostscript to still make use of the old PDF interpreter written in PostScript rather than C.
That obviously isn‘t a perfect solution as the reimplemented interpreter should do the trick as well — however it at least keeps everything as it should be for now.
Sorry for the late reply. This is interesting.
I wonder:
- If there is a way to enable the new parser and get the same results
- If using
-dNEWPDF=falseon older GS versions will break the script (we need to test the version before using it if that is the case)
I will need to investigate...