Is it possible to only import part of a pdf file? For example if I want to import lines 20 - 25 from page X from a pdf file, is this possible?

I am familiar with importing whole documents, or pages using \includepdf, but is this import of sections possible?

Moreover, would this result in a figure, or can it be inserted into "regular" text?

  • Have you tried \includegraphics options page=... and viewport=... yet? – AlexG Dec 9 '19 at 9:57
  • includepdf has the option pages=20-25, and includegraphics has page=20. – Ulrike Fischer Dec 9 '19 at 9:58
  • Oh lines, not pages ;-). I completly misread the question. – Ulrike Fischer Dec 9 '19 at 10:32

No, you can't import a part of a PDF page as if it were text of your *.tex file, unless you just copy the text out of the PDF and paste it into your *.tex file as a quotation.

Either produce a picture (jpg, png, by taking a screenshot e.g.) and include this as it is (\includegraphics) or within an figure, or copy the text out of the PDF and paste it.

Using the viewport option of the graphics bundle isn't as easy as making a screenshot of the PDF.

  • 2
    Note that if your PDF content is vector-based, you'll be losing quality by taking a screenshot (which is rasterized). But if you "includegraphics" the PDF with cropping, the full PDF content is still present in your output file, increasing file size and possibly including information you don't want present. It's possible, though not trivial, to "truly crop" your PDF file: set the MediaBox by using Inkscape, for example, then "print to PDF" or use a tool like pdftocairo to drop all content outside the MediaBox. – Eric Marsden Dec 9 '19 at 10:56
  • @Keks With the Gv Postscript/PDF viewer, lower left and upper right corners of the viewport can easily be determined using the mouse pointer (cross hair). – AlexG Dec 9 '19 at 11:09

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.