I have a bunch of PDF files that I have been using to make PNG files, with a width of 320 pixels. The way I have been doing this is by creating the PDFs in LaTex with a width of 4.44444 inches, then converting to PNGs at Zamzar.

I am wondering if there is a way to use my LaTex files to make double-scale PNGs that are 640 pixels wide. The PNGs should be the same as before, but appropriately scaled up (i.e. not just by turning every pixel into 4 identical pixels).

is there a way I can do this?



Why don't you just create bigger PDF files to begin with using LaTeX? You can use the geometry package to set the page size to whatever you want, and use \scalebox or \resizebox from the graphicx package to scale any portion of the document to whatever size you want. (And if everything inside is text or vector graphics, it'll be the good kind of stretching, and not pixel duplication: if what's inside contains raster graphics, there's nothing you can do anyway.)

Finally if you have PDFs already made that you want to scale PDF, you can do so with the pdfpages package. E.g.:


Compile with pdflatex.

You can also use absolute height and width instead of scale. See the package documentation linked above for more info.

Any why are you using Zamzar? If you're using LaTeX, you definitely have dvipng installed, which can convert dvi's created by regular LaTeX to PNG. You almost certainly have ghostscript installed, which can convert PDF or PS to PNG or a variety of other formats. (If you tell me what operating system you're using, I'll tell you what ghostscript command to use.) You might also have ImageMagick installed, which can do even more. And there is a ton of other free software you could use, some of which would handle the scaling for you. For example, you could use the GIMP if you wanted a graphical interface for doing this.

  • My OS is macOSX – William Jockusch Nov 25 '10 at 21:12
  • I think the ghostscript command for conversion would be the same as on linux then. gs -dSAFER -dBATCH -dNOPAUSE -r300 -sDEVICE=png16m -dGraphicsAlphaBits=4 -dFirstPage=3 -dLastPage=3 -sOutputFile=output.png input.pdf to convert page 3 of input.pdf to output.png. Change the -r300 higher to lower for higher or lower resolution. Change the -dFirstPage and -dLastPage for other page numbers. Of course you can change the input/output file names too. I'd leave the rest the same. – frabjous Nov 26 '10 at 4:56

You could use Ghostscript to rescale your PDF pages. This is what I used yesterday to scale a A4 sized PDF to A6, at the same time selecting only pages 22-27 for the output:

gswin32c.exe ^
  -o A6-output.pdf ^
  -sDEVICE=pdfwrite ^
  -dPDFFitPage ^
  -g2975x4210 ^
  -dFirstPage=22 ^
  -dLastPage=27 ^
  -dPDFSETTINGS=/prepress ^

Above command example is for Windows. On Linux replace the .exe by just gs, and the ^ by \.

-g2975x4210 gives the output size in pixels. To understand that value, you need to know that my input A4 size is 595 x 842, my desired A6 paper size is 297.5 x 421 points.

A point is a unit for measuring PostScript or PDF dimensions. There are 72 points to one inch. And Ghostscript's output device uses 720 dpi (dot per inch) resolution by default. Hence my "funny" page size given as -g2975x4210.

To directly convert to PNG, I should have used:

gswin32c.exe ^
  -o input_page_%03d_A6.png ^
  -sDEVICE=pngalpha ^
  -dPDFFitPage ^
  -g297x421 ^
  -dFirstPage=22 ^
  -dLastPage=27 ^

This gives me one PNG file per PDF page.

Note that I needed to change the -g param because the default resolution for Ghostscript's image output devices is 72dpi. Of course I could have changed that by giving the resolution as, say -r200x200, but then I'd have to re-calculate the -r... value too. And I simply was too lazy to do that....

  • Nice! Is the 720 in "Ghostscript's output device uses 720 dpi (dot per inch) resolution by default" correct? – Arjan Dec 19 '10 at 13:11
  • @Arjan: It's correct... for the pdfwrite output device. I admit that my wording above was ambiguous though. Most other, such as Ghostscript's image output devices (jpeg, tiffg4, pngalpha, bmp256, ... etc.) do use 72dpi by default. – Kurt Pfeifle Dec 19 '10 at 14:01

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.