Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centering objects in resize mode seems to be broken #28

Closed
bkroggel opened this issue Jun 3, 2022 · 2 comments · Fixed by #29
Closed

Centering objects in resize mode seems to be broken #28

bkroggel opened this issue Jun 3, 2022 · 2 comments · Fixed by #29

Comments

@bkroggel
Copy link
Contributor

bkroggel commented Jun 3, 2022

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

  1. Get a random pdf file (e.g. the Wikipedia Logo (svg > pdf))
    Wikipedia_wordmark.pdf
  2. Try to resize the object — e.g. to a object with 700x400pt:
    pdfscale -r "custom pt 700 400" Wikipedia_wordmark.pdf
  3. 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.

@bastian-pnptc
Copy link

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.

@tavinus
Copy link
Owner

tavinus commented Sep 19, 2022

Sorry for the late reply. This is interesting.

I wonder:

  1. If there is a way to enable the new parser and get the same results
  2. If using -dNEWPDF=false on 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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants