I have a set of images stored as separate PDF files. One image per file. Each image takes up one PDF page.

I need to re-scale all of these images, preferably at the command line, so that the image content and the page dimensions of the PDFs are both scaled relative to their original sizes/dimensions. For example: scale all the images by 50% should shrink the size of the image and the dimensions of the page.

Already tried:

  • pdfpages + latex: will re-scale the image but dimensions of the pages stay the same.
  • pdfjam: same problem; can re-scale but page dimensions want to be letterpaper or a4.
  • convert (imagemagick): converts to raster, which I don't want.
  • ghostscript: seems to scale based on absolute new page size, and I need relative page size.

I know one of these must work. I can't figure out where I've gone wrong. I'm on Mac but a Linux solution would work just as well.

5 Answers 5


I think I found one: http://community.coherentpdf.com/

cpdf -scale-page "0.5 0.5" in.pdf -o out.pdf

  • 5
    Yes thanks. I use cpdf -scale-to-fit "210mm 210mm" in.pdf -o out.pdf and it works great
    – maxbellec
    Feb 22, 2017 at 10:25
  • 3
    could not find cpdf in ubuntu repos but for me pdfjam as per this answer did the trick.
    – cardamom
    Aug 28, 2017 at 11:15
  • I used pdfposter as per this answer. Jun 12, 2018 at 8:49
  • Thanks, this is a magical tool!
    – Autodidact
    Jul 20, 2019 at 21:24
  • 1
    @young_souvlaki, there's an online user manual with detailed examples
    – Sam
    Jul 22 at 22:39

pdfjam works for this.

pdfjam --outfile out.pdf --paper a5paper in.pdf
  • Yes, and you can also just add --landscape to do exactly that. Sep 24, 2020 at 11:23
  • 1
    I wanted to really just scale both dimensions by some factor. In order to keep the initial image ratio you need to specify the explicit target size, e.g. --papersize '{16in,10in}' for some 16:10 ratio. Otherwise you might end up with unexpected whitespace around the image. You could extract the initial size as suggested here.
    – bixel
    Apr 9, 2021 at 10:38
  • Note that while this is potentially useful for many use cases, this example usage does *not* answer the question as-asked (and indeed, is listed as a non-workable solution). That said, it seems like pdfjam can (now?) mostly do this, as it does have a --scale option. That said, that option does not auto-scale the page size, too, as was requested in the original question. So, very useful for many, no doubt, but not strictly a valid answer to this question as asked... though could perhaps be adapted to be one??
    – lindes
    Jun 17 at 20:53
  • For US "letter" paper sizes (8.5 x 11 inches), use: pdfjam --outfile out.pdf --paper letter in.pdf Jun 27 at 21:53

The following will do what you want:


NB: As at 2021-07-14, there is no way to specify an arithmetic scale factor, but as pdfScale does accept custom page sizes, the following posix shell script overcomes that limitation:

# NB: 50% linear scaling takes A4 to A6
# For 50% area scaling (A4 to A5), use scalePercent=70
oldSize=$(pdfinfo $inFile | grep '^Page size')
oldWidth=$(echo "$oldSize" | awk '{print $3}')
oldHeight=$(echo "$oldSize" | awk '{print $5}')
newWidth=$(($oldWidth * scalePercent / 100))
newHeight=$(($oldHeight * scalePercent / 100))
pdfScale.sh -r "custom pts $newWidth $newHeight" $inFile
# default output filename is yourFilenameHere.CUSTOM.pdf

There's a page at https://ma.juii.net/blog/scale-page-content-of-pdf-files which explains the history behind the project - interesting stuff! HTH.


Thanks, I tried pdfScale.sh and cpdf, and cpdf works for me. cpdf will stretch the cover and content to fill the entire page without extra white space left.

Here is the command, you need to calculate the scale ratio when use cpdf with the option -scale-page

cpdf -scale-page "x_ratio_not_size y_ratio_not_size" input.pdf -o output.pdf

I use a fish function cpdfscale which depends on pdfinfo and cpdf to convert pdf files for my apple devices.

Here is the cpdfscale.fish source code:

function cpdfscale
  # Get pdf file origin size
  set -l dim_x (pdfinfo $argv[3] | grep -a "Page size" | cut -d\: -f2 | cut -dx -f1 | sed 's/^[ \t]*//')
  set -l dim_y (pdfinfo $argv[3] | grep -a "Page size" | cut -d\: -f2 | cut -dx -f2 | cut -d' ' -f2 | sed 's/^[ \t]*//')
  echo Origin Page Size\t :\t $dim_x x $dim_y pts
  echo Scaled Page Size\t :\t $argv[1] x $argv[2] pts

  # Calc scale ratio
  set -l sx (math $argv[1] / $dim_x)
  set -l sy (math $argv[2] / $dim_y)
  echo Scaled Page Ratio\t :\t $sx x $sy

  # Set output file and convert
  if test (count $argv) -gt 3
    echo Scaled Output File\t :\t $argv[4]
    cpdf -scale-page "$sx $sy" $argv[3] -o $argv[4] &> /dev/null
    set -l outfile (echo $argv[1]x$argv[2] - (basename $argv[3] .pdf).pdf)
    echo Scaled Output File\t :\t $outfile
    cpdf -scale-page "$sx $sy" $argv[3] -o $outfile &> /dev/null
  echo "Scale finished"


cpdfscale x_size_in_pts y_size_in_pts input.pdf [output.pdf].

if the output file is not specified, a new file name with origin name and new file page dimensions ${x_size_in_pts}x${y_size_in_pts} - ${origin_name}.pdf will be used.

The following command convert any pdf file for my iPad Air4 which has a screen with size 1640 x 2360 pts.

cpdfscale 1640 2360 origin.pdf scaled.pdf

The core command to get my work done is:

cpdf -scale-page "3.253968 4.173453" origin.pdf -o scaled.pdf

Here is the output:

>=>  cpdfscale 1640 2360 origin.pdf
Origin Page Size     :   504  x 565.479 pts
Scaled Page Size     :   1640 x 2360 pts
Scaled Page Ratio    :   3.253968 x 4.173453
Scaled Output File   :   1640x2360 - origin.pdf
Scale finished

>=>  cpdfscale 1640 2360 origin.pdf scaled.pdf
Origin Page Size     :   504  x 565.479 pts
Scaled Page Size     :   1640 x 2360 pts
Scaled Page Ratio    :   3.253968 x 4.173453
Scaled Output File   :   scaled.pdf
Scale finished

I also had a problem finding a tool that can do something like that; I want to change page size of and rotate a PDF document, but without scaling contents. And I just realized pdfedit (which is a GUI tool, however), can do it:

  • After the document is opened, go to Page/"Edit page metrics", and then edit the x,y positions of left upper/right lower corners, and then Change.
  • After that, can go to Page/"Rotate page 90 Degrees"

Note that:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.