Closed loconox closed 2 years ago
There are many things you can try, but depends on the pdf and what you are doing.
Are you scaling, resizing or both?
-f d
-f f
-a d
-a a
You can read the detailed explanation and other options at the help info.
pdfscale --help
If you can provide the pdfscale call and the log of the pdfScale run (use -v
to print it), then it will be easier to guess what is happening.
Apart from that I would need the original PDF to try here.
I tried cmd='pdfscale -v -v -r "custom mm 594 841" -s 0.9 {} {}'.format(infile,outfile)
for the resizing the PDF. I was the facing the same error and I tried the below command
cmd='pdfscale -v -v -r -f d --vertical-alignment top --horizontal-alignment top "custom mm 594 841" -s 0.9 {} {}'.format(infile,outfile)
But I am getting the following error
pdfscale v2.5.3
ERROR! Invalid Paper Type: -f
Usage: pdfscale [-v] [-s <factor>] [-m <mode>] [-r <paper> [-f <mode>] [-a <mode>]] <inFile.pdf> [outfile.pdf]
Help : pdfscale -h
please Help me out., I am using python3 to trigger the command in Ubuntu 18.04
Hi there.
You should probably have created another issue, since this one is unrelated to your problem.
My first advice is to try the command in the shell first.
When it works, transfer the logic to python.
I would start trying to run exactly the same call hardcoded from Python. Same call you KNOW works in a shell.
(Some times the Environment changes when you run from another language and it may bring problems.)
Then I would change it to vars and run again. Each step checking execution.
Also, not sure why you are using -v -v
if your are not gonna post the log from that here.
The first one seems OK
$ pdfscale -v -v -r "custom mm 594 841" -s 0.9 in.pdf out.pdf
2020-12-18:23:56:21 | pdfscale v2.5.3 - Verbose Execution
2020-12-18:23:56:21 | Mixed Tasks: Resize & Scale
2020-12-18:23:56:21 | Dry-Run: FALSE
2020-12-18:23:56:21 | Input File: in.pdf
2020-12-18:23:56:21 | Output File: out.pdf
2020-12-18:23:56:21 | Get Page Size: Adaptive Enabled
2020-12-18:23:56:21 | Method: Grep
2020-12-18:23:56:21 | Source Width: 595 postscript-points
2020-12-18:23:56:21 | Source Height: 842 postscript-points
2020-12-18:23:56:21 | Print Mode: Print ( auto/empty )
2020-12-18:23:56:21 | Fit To Page: Enabled (default)
2020-12-18:23:56:21 | Auto Rotate: PageByPage
2020-12-18:23:56:21 | Flip Detect: No change needed
2020-12-18:23:56:21 | Run Resizing: CUSTOM ( 1684 x 2384 ) pts
2020-12-18:23:56:22 | New Width: 1684 postscript-points
2020-12-18:23:56:22 | New Height: 2384 postscript-points
2020-12-18:23:56:22 | Scale Factor: 0.9
2020-12-18:23:56:22 | Vert-Align: CENTER
2020-12-18:23:56:22 | Hor-Align: CENTER
2020-12-18:23:56:22 | Translation X: 93.55 = 93.55 + 0.00 (offset)
2020-12-18:23:56:22 | Translation Y: 132.44 = 132.44 + 0.00 (offset)
2020-12-18:23:56:22 | Run Scaling: -10 %
2020-12-18:23:56:22 | Background: No background (default)
2020-12-18:23:56:23 | Final Status: File created successfully
The second one fails the same way yours does. Because it should.
You call -r
and then you put the paper type a long way down the road for some reason. So you end up using -f
as a paper type.
ERROR! Invalid Paper Type: -f
Also, you are using top
as horizontal alignment, when you should use one of
left, right, center
So instead of:
pdfscale -v -v -r -f d --vertical-alignment top --horizontal-alignment top "custom mm 594 841" -s 0.9 in.pdf out.pdf
You need something like:
$ pdfscale -v -v -r "custom mm 594 841" -f d --vertical-alignment top --horizontal-alignment center -s 0.9 in.pdf out.pdf
2020-12-19:00:04:30 | pdfscale v2.5.3 - Verbose Execution
2020-12-19:00:04:30 | Mixed Tasks: Resize & Scale
2020-12-19:00:04:30 | Dry-Run: FALSE
2020-12-19:00:04:30 | Input File: in.pdf
2020-12-19:00:04:30 | Output File: out.pdf
2020-12-19:00:04:30 | Get Page Size: Adaptive Enabled
2020-12-19:00:04:30 | Method: Grep
2020-12-19:00:04:30 | Source Width: 595 postscript-points
2020-12-19:00:04:30 | Source Height: 842 postscript-points
2020-12-19:00:04:30 | Print Mode: Print ( auto/empty )
2020-12-19:00:04:30 | Fit To Page: Enabled (default)
2020-12-19:00:04:30 | Auto Rotate: PageByPage
2020-12-19:00:04:30 | Flip Detect: Disabled
2020-12-19:00:04:30 | Run Resizing: CUSTOM ( 1684 x 2384 ) pts
2020-12-19:00:04:30 | New Width: 1684 postscript-points
2020-12-19:00:04:30 | New Height: 2384 postscript-points
2020-12-19:00:04:30 | Scale Factor: 0.9
2020-12-19:00:04:30 | Vert-Align: TOP
2020-12-19:00:04:30 | Hor-Align: CENTER
2020-12-19:00:04:31 | Translation X: 93.55 = 93.55 + 0.00 (offset)
2020-12-19:00:04:31 | Translation Y: 264.89 = 264.89 + 0.00 (offset)
2020-12-19:00:04:31 | Run Scaling: -10 %
2020-12-19:00:04:31 | Background: No background (default)
2020-12-19:00:04:31 | Final Status: File created successfully
Cheers!
Gus
@tavinus Thank you for the reply it was very helpful.
Closing, since this has been unanswered for a long time.
Hi,
I have a PDF which was not correctly generated. Pages should be in landscape but they are in portrait mode. All images are crush horizontally and stretch vertically. Is there a way to resize all pages but not rotate them, it's not a problem of rotation, and stretch each page to the new format ?
Thanks in advance.