Adding a external PDF as appendix with ReStructuredText

1.3k views Asked by At

I'm writing a major report, and have two PDF files I'd like to include as appendices. The report is written using ReStructuredText, and rst2pdf will be used to convert it.

Does docutils or rst2pdf have any functionality for external files as appendices?

3

There are 3 answers

0
Chrizmo On BEST ANSWER

In the end, I couldn't fix this problem directly. I converted the ReStructuredText file to Latex, and included the appendices there.

1
Chris On

Docutils has the raw directive for passing data through to the final output untouched. In the documentation they demonstrate this for the LaTeX and HTML outputs. rst2pdf seems to support this directive: in the manual they use the raw directive to include some text/commands in the final PDF (see the section headed Raw Directive) but they do not demonstrate using this directive for including external PDF files.

If rst2pdf does support this feature, you should just be able to use:

.. raw:: pdf
   :file: your_pdf_file.pdf
   :encoding: the encoding of the PDF file, if different from the
              reStructuredText document's encoding.

I have just had a go at doing this (if in doubt, give it a go) and I get a number of UnicodeDecodeErrors, so the feature seems to be supported but I can't get it to work.

2
Roberto Alsina On

You could embed PDFs as images, but that makes no sense for appendixes.

If you only have those files as PDF, you can add them using a PDF manipulation tool, but those usually break page numbering or links or some other piece of the PDFs.