I have a larger png image: width is 5400 pixels and height is 3850 pixels. I need to transform it into a pdf file in SPA3 size, which means 320mm x 450mm. Is there a way to do it with LaTeX? What I think I need, is to be able to specify the paper size explicitly and to tell LaTeX that there should not be anything around the image.


You can use the standalone class which will produce a pdf with no border. If you want a small border you can add [border=<length>] class option.


  • As LionelMANSUY mentioned in the comments it is usually preferable to use keepaspectratio, but if specific dimensions of both height and width are required, using `keepaspectratio may conflict with those requirements..


  • 2
    Thanks a lot! It works perfectly! I love stackexchange. It works so fast and so effective (of course because of its users). – Roman Nov 30 '12 at 8:27
  • 10
    Your welcome.. But keep in mind this is TeX.SE -- I think this site is a whole lot friendlier than your regular stackexchange. :-) – Peter Grill Nov 30 '12 at 8:28
  • 2
    @PeterGrill Is it not preferable to append also the keepaspectratio option? – Lionel MANSUY Nov 30 '12 at 8:55
  • 2
    @LionelMANSUY: Well yes, but since both the height and width are fixed amounts, not sure it makes sense to also specify keepaspectratio? – Peter Grill Nov 30 '12 at 8:57
  • @PeterGrill If I don't mistake, when you write both height and width, you will have a disproportionated picture if the values are not proportional to the source picture's ones. Here: 5400/3850=1.403 and 450:320:1.406; the difference is here negligible but still exist – Lionel MANSUY Nov 30 '12 at 9:54

Media size (SRA3): 320mm x 450mm
Image size: 5400px x 3850px

  • Media or image needs to be rotated to prevent severe distortion of the image (keepaspectratio=false) or larger margins (keepaspectratio=true).

  • Package geometry can be used to set the paper size and package pdfpages also works with images.

  • If the image is rotated, then package pdflscape tells the PDF viewer to rotate the viewed page.

  • After rotation the ratios are 1.40625 vs. 1.4026. The difference is quite small, depending on the image and application distortion of the image might be acceptable to avoid a small margin otherwise.

  • The margin area can be colored using \pagecolor of package graphics (also loaded by package pdfpages).

Some examples that uses a lolcat.jpg from a StackExchange error page (also found here).

Media rotation without distortion, black margins



Cat on rotated media with black margins

Image rotation with distortion



Rotated cat with distortion

  • 5
    Isn't it time you bought your cat a new computer? – David Carlisle Nov 30 '12 at 11:04
  • 1
    @DavidCarlisle AFAIK the cat is from StackExchange. Some image that is shown in case of errors. – Heiko Oberdiek Nov 30 '12 at 11:20
  • 7
    @David's cat uses Vim. :) – Paulo Cereda Nov 30 '12 at 13:03

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.