3

I process PDF files in an existing Perl framework. Some of the incoming files have very large page sizes. What I would like to do:

  1. Check if the input file's page size is larger than a specific format f (A4/Letter)
  2. If it is larger than f: scale it down to f.

This is the corresponding command in Unix using GhostScript:

gs -sPAPERSIZE=a4 -dFIXEDMEDIA -dPSFitPage -o <outputFile> -sDEVICE=pdfwrite <inputFile>

Is there a way to do this within Perl, i.e. without requiring to call external tools? I checked the modules PDF and CAM::PDF, but the documentation does not really cover my issue and I couldn't find a straight-forward solution.

Carsten
  • 1,732
  • 26
  • 52
  • The PDF module has not been updated for 16 years. CAM::PDF might have it. I suggest you use [metacpan](https://metacpan.org/release/CAM-PDF) to browse it as that makes your life considerably easier. Check all the things it brings. I'm also pretty sure that PDF::API2 cannot do what you want. – simbabque Feb 14 '17 at 15:21
  • This answer uses PDF::API2 to address a similar issue http://stackoverflow.com/questions/2947925/how-to-add-header-footer-with-images-using-pdfapi2lite/3049803#3049803 Note that you can pass a scale to the `formImage` method – dwarring Feb 16 '17 at 03:45

0 Answers0