3

I'd like to add to a pdf a margin of 1cm. Around this page I will add a frame later and like to draw something else to the frame. However, how can I add a margin to a pdf without scaling the pdf (-> single page document: the old pdf unscaled plus a 1 cm border)?

This is what I have tried it so far:

\documentclass{scrartcl}
\usepackage{pdfpages}
\usepackage{geometry}

\begin{document}
\includepdf[frame, fitpaper]{incl.pdf}
% I thought I'd use fitpaper and add a margin...
\newgeometry{left=3cm,right=1cm} % This does not do anything at all.
\end{document}
5
  • So incl.pdf is a single page document? Your idea is to insert the page, but make it have a 1cm border inside the PDF page? I don't understand your final call to \newgeometry...
    – Werner
    Jul 10, 2015 at 18:44
  • Add a margin without scaling! ... What a magic! Then, you have to crop.
    – AboAmmar
    Jul 10, 2015 at 19:34
  • It is a single page document. Hm..I want to have the pdf unscaled and outside a 1cm border.@AboAmmar: Cropping is to remove the border, isn't it? Jul 10, 2015 at 19:41
  • @StefanBollmann: Will there be anything else in this document, or just the included page incl.pdf?
    – Werner
    Jul 10, 2015 at 19:49
  • @Werner Later I'd like to draw a dashed frame around the edge of the whole construct. However, I thought to brake this problem into pieces... Jul 10, 2015 at 19:56

1 Answer 1

6

The following minimal example creates lipsum.pdf - a single-page document with an image (no border included):

enter image description here

\documentclass{article}
\usepackage{graphicx,lipsum}
\begin{document}
\noindent
\includegraphics[width=\linewidth]{example-image}

\bigskip

\lipsum[1-2]
\end{document}

The following minimal example insert the single-page PDF lipsum.pdf with a 1cm padded border:

enter image description here

\documentclass{article}
\usepackage{pdfpages}
\usepackage{geometry}
% Grab external image for processing
\newsavebox{\externalimage}
\savebox{\externalimage}{\includegraphics{lipsum.pdf}}
\setlength{\fboxsep}{1cm}
\geometry{
  paperwidth=\dimexpr\wd\externalimage+2\fboxrule+2\fboxsep,
  paperheight=\dimexpr\ht\externalimage+2\fboxrule+2\fboxsep,
  margin=0pt
}
\setlength{\parindent}{0pt}
\begin{document}
\fbox{%
  \setlength{\fboxsep}{-\fboxrule}% (remove)
  \fbox{% (remove)
    \usebox{\externalimage}%
  }% (remove)
}
\end{document}

The included PDF remains unscaled as the page geometry is made to fix exactly lipsum.pdf + two rules (left/right or top/bottom, resulting from \fboxrule) + two 1cm gaps (\fboxsep).

For visual effect, I've added a frame around the included page, by that can be (remove)d.

4
  • Is there a way to do this leaving a 1cm margin only on one side, to the left? What I'm looking for is to get more place to bind with glue on a small a6 book. And the 130 pages pdf is already set.
    – nilon
    May 27, 2016 at 3:30
  • 1
    @nilon: You can set the geometry with using left and right to set the respective left/right margins. Or, perhaps margin=5mm,left=1cm would set all margins to 5mm but keep the left one at 1cm. Alternatively, if you are printing double-sided, you might be interested in inner and outer. Read the geometry documentation.
    – Werner
    May 27, 2016 at 4:50
  • @nilon: ...I see you've asked a new/follow-up question. Good!
    – Werner
    May 27, 2016 at 4:52
  • double thanks @Werner, for answer and the additional encouraging. However this isn't working for me. I've set watermarks, and images and poetry already set. I'd like not to mess up the pdf as is. Just add margin without changing the rest of the pdf result. Possible perhaps?
    – nilon
    May 27, 2016 at 5:06

You must log in to answer this question.

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