17

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.

3

2 Answers 2

25

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.

Notes:

  • 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..

Code:

\documentclass{standalone}
\usepackage{graphicx}
\begin{document}
    \includegraphics[width=320mm,height=450mm]{../images/EiffelWide}
\end{document}
6
  • 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, 2012 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. :-) Nov 30, 2012 at 8:28
  • 2
    @PeterGrill Is it not preferable to append also the keepaspectratio option? Nov 30, 2012 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? Nov 30, 2012 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 Nov 30, 2012 at 9:54
11

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

\documentclass{article}
\usepackage[
  paperwidth=320mm,
  paperheight=450mm,
  landscape,
]{geometry}
\usepackage{pdfpages}
\pagecolor{black}

\begin{document}
  \includepdf{lolcat.jpg}
\end{document}

Cat on rotated media with black margins

Image rotation with distortion

\documentclass{article}
\usepackage[
  paperwidth=320mm,
  paperheight=450mm,
]{geometry}
\usepackage{pdflscape}
\usepackage{pdfpages}

\begin{document}
  \begin{landscape}
    \includepdf[
      angle=90,
      keepaspectratio=true,
      width=\paperwidth,
      height=\paperheight
    ]{lolcat.jpg}
  \end{landscape}
\end{document}

Rotated cat with distortion

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .