3

Suppose you have a draft pdf, and the only difference with a desired final version of it is the lack of figures. And suppose too you have the original figures, but not the source code of the document.

What would be your best trick to achieve the document with its figures on place?

6
  • 1
    What do you mean draft document? and why do you have draft enabled?
    – daleif
    Commented Jan 21, 2014 at 13:09
  • 1
    Probably the answer from this question might help. In short: add the option final to the graphicx package.
    – crixstox
    Commented Jan 21, 2014 at 14:01
  • @daleif, I mean one generated with ´draft´ option on in documentclass or graphix package, so it only has frames and image paths in the place of images. Also it is not very clear in the question, so I edit it, that you have not the original source code.
    – Andrestand
    Commented Jan 21, 2014 at 21:31
  • 1
    Then you would ave to edit the PDF in some program. Without the .tex you cannot run this through LaTeX
    – daleif
    Commented Jan 21, 2014 at 23:03
  • 1
    I am not saying this is the best way, but you could do this if you wanted to. If you included pages from the PDF as background images, you could then include the figures in the appropriate positions in the document. However, I cannot really think of any reason to do this. A better solution would be to use pdfpages to include the PDF and then lay the graphics over the top. But I am not sure that's possible.
    – cfr
    Commented Jan 22, 2014 at 2:02

1 Answer 1

3

Example with two images tiger.pdf and flowers.eps from TDS:doc/generic/pstricks/images/:

\documentclass[a5paper]{article}
\usepackage[hmargin=10mm,vmargin={10mm,20mm}]{geometry}
\usepackage[draft]{graphicx}
\usepackage{lipsum}
\begin{document}
\lipsum[11]
\begin{center}
  \includegraphics[width=.5\linewidth]{tiger}%
\end{center}
\lipsum[2]
\begin{center}
  \includegraphics[width=.5\linewidth]{flowers}%
\end{center}
\end{document}

without images

Then I have measured the positions of the image boxes (using gv, ...):

\newcommand*{\imglist}{%
  \img{1}{118bp}{306bp}{301bp}{498bp}{tiger}%
  \img{1}{118bp}{65bp}{301bp}{204bp}{flowers}%
}

The first argument of \img is the page number, then the coordinates of the lower left corner and of the upper right corner follows. The following example will use the coordinate system of PDF (gv) with horizontal values from the left and vertical values from the bottom. The last argument contains the image file name.

Then first a white box is put in the image area to clear the frame and image file name of option draft. Then the image is placed. It is assumed that the image is not distorted.

Package atbegshi is used to put the images on the foreground of the output pages. Package picture extends the picture environment. Also lengths values can be used instead of factors for \unitlength. Package pdfpages includes the original PDF file without images. And package color is needed for the white box.

Example file:

\documentclass{article}
\usepackage{pdfpages}
\usepackage{atbegshi}
\usepackage{picture}
\usepackage{color}

\newcommand*{\imglist}{%
  \img{1}{118bp}{306bp}{301bp}{498bp}{tiger}%
  \img{1}{118bp}{65bp}{301bp}{204bp}{flowers}%
}

\newcommand*{\img}[6]{%
  \ifnum#1=\value{page}%
    \AtBeginShipoutUpperLeftForeground{%
      \put({\dimexpr(#2)\relax},{-\dimexpr\paperheight-(#3)\relax}){%
        \rlap{%
          \textcolor{white}{%
            \rule{\dimexpr(#4)-(#2)\relax}{\dimexpr(#5)-(#3)\relax}%
          }%
        }%  
        \includegraphics[%
          width=\dimexpr(#4)-(#2)\relax,
          height=\dimexpr(#5)-(#3)\relax,
        ]{#6}%
      }%
    }%  
  \fi
  \ignorespaces
}
\AtBeginShipout{%
  \imglist
}

\begin{document}
  \includepdf[pages=-,fitpaper]{t.pdf}% PDF file without images
\end{document}

Result

You must log in to answer this question.

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