0

All the examples I can find seem to assume you are merging existing PDFs, and in particular sticking a bunch of PDFs at the end of another PDF.

In my situation I am generating something analogous to a bibliography but if the reference is to a file of PDF format, they want the contents of that PDF inserted inline, immediately after the citation, not out of place at the end of the file.

Note that there is no guarantee that the external PDFs use the same page size, rotation, etc, as the PDF document I'm generating.

Is there a way to do this? I've tried modifying the itext example on how NOT to do this (with a PdfWriter) but I get an unbalanced save/restore state message. I'm also considering doing this by post-processing as all the examples do, but I'm not quite sure how I'd go about looping through the bibliography PDF and determining where to insert the pages of the external PDFs.

Thanks.

  • First of all, *example on how NOT to do* something are meant to NOT do, even with minor modifications. That been said, do you want to include whole source page contents or merely sections thereof? Furthermore do you expect re-flowing of the source text? – mkl May 01 '16 at 03:06
  • I need to include the entire document, as is. Although it would be better to keep it as text, inserting an image version of the document would be better than reflowing the text. [Actually, this NOT TO example is clearly marked as valid in response to the particular user problem. I didn't expect it's necessarily valid for mine, but it was the closest example I could find to what I want!] – user3757294 May 02 '16 at 17:31
  • So essentially do you need something like shown in this [answer](http://stackoverflow.com/a/32008211/1729265)? It shows how to import the whole content (without leading or trailing white space) of a PDF page en block into a new PDF. Or do you require the flexibility from the merger in [this answer](http://stackoverflow.com/a/29078954/1729265) which splits the source pages if need be? – mkl May 03 '16 at 05:57

0 Answers0