Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #261727 > unrolled thread
| Started by | Greg Marks <gtmarks@gmail.com> |
|---|---|
| First post | 2023-09-17 03:20 +0200 |
| Last post | 2023-09-18 16:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.debian.user
resizing PDF files with Ghostscript Greg Marks <gtmarks@gmail.com> - 2023-09-17 03:20 +0200
Re: resizing PDF files with Ghostscript Curt <curty@free.fr> - 2023-09-18 16:50 +0200
| From | Greg Marks <gtmarks@gmail.com> |
|---|---|
| Date | 2023-09-17 03:20 +0200 |
| Subject | resizing PDF files with Ghostscript |
| Message-ID | <HeOC5-9ud2-1@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
I am trying to use Ghostscript to resize PDF files to letter page size, but on certain files the output is not the correct size. As an example: $wget https://gmarks.org/abrams_anh_pardo.pdf $pdfinfo abrams_anh_pardo.pdf ... Page size: 539 x 737 pts ... $gs -o resized_file.pdf -sDEVICE=pdfwrite -dFIXEDMEDIA -dPDFFitPage -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dBATCH -dSAFER abrams_anh_pardo.pdf $pdfinfo resized_file.pdf ... Page size: 579.224 x 792 pts ... Despite the flags -dDEVICEWIDTHPOINTS=612 and -dDEVICEHEIGHTPOINTS=792, the page size of the output file is 579.224 x 792 pts instead of 612 x 792 pts. (Interestingly, Ghostscript did change the page size, just not to the correct dimensions.) As some printers will refuse to print files that aren't 612 x 792, I'd like to be able to convert such files correctly. How does one do that with Ghostscript? Incidentally, the command $pdfjam --outfile resized_file.pdf --paper letter abrams_anh_pardo.pdf does produce the correct output; however, on certain PDF files, pdfjam yields output files with blank pages, so I'd like to be able to use Ghostscript as an alternative. Best regards, Greg Marks
[toc] | [next] | [standalone]
| From | Curt <curty@free.fr> |
|---|---|
| Date | 2023-09-18 16:50 +0200 |
| Message-ID | <HfnJv-9PWl-3@gated-at.bofh.it> |
| In reply to | #261727 |
On 2023-09-17, Greg Marks <gtmarks@gmail.com> wrote: > > I am trying to use Ghostscript to resize PDF files to letter page size, > but on certain files the output is not the correct size. As an example: > > $wget https://gmarks.org/abrams_anh_pardo.pdf > > $pdfinfo abrams_anh_pardo.pdf=20 > ... > Page size: 539 x 737 pts > ... > > $gs -o resized_file.pdf -sDEVICE=pdfwrite -dFIXEDMEDIA -dPDFFitPage -d > DEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dBATCH -dSAFER abrams_a > nh_pardo.pdf > > $pdfinfo resized_file.pdf=20 > ... > Page size: 579.224 x 792 pts > ... > It appears the output of pdfwrite has a MediaBox of 612x792 but a CropBox of 595.61x792, which must be the result of scaling A4 down to Letter and centering that scaled down area on the page. curty@einstein:~$ pdfinfo -box resized_file.pdf <snip> Page size: 579.224 x 792 pts Page rot: 0 MediaBox: 0.00 0.00 612.00 792.00 CropBox: 16.39 0.00 595.61 792.00 BleedBox: 16.39 0.00 595.61 792.00 TrimBox: 16.39 0.00 595.61 792.00 ArtBox: 16.39 0.00 595.61 792.00 File size: 26538 bytes Optimized: no PDF version: 1.7 I'm unaware of another way of "fixing" this but the following kludge (unless you can tell your printing process to use MediaBox and ignore CropBox). sed -e "/CropBox/,/]/s#.# #g" resized_file.pdf curty@einstein:~$ pdfinfo -box resized_file.pdf <snip> Page size: 612 x 792 pts (letter) Page rot: 0 MediaBox: 0.00 0.00 612.00 792.00 CropBox: 0.00 0.00 612.00 792.00 BleedBox: 0.00 0.00 612.00 792.00 TrimBox: 0.00 0.00 612.00 792.00 ArtBox: 0.00 0.00 612.00 792.00 File size: 26538 bytes Optimized: no PDF version: 1.7
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web