2

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?

Chrizmo
  • 626
  • 2
  • 7
  • 18

3 Answers3

1

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.

Axel Advento
  • 2,995
  • 3
  • 24
  • 32
Chris
  • 44,602
  • 16
  • 137
  • 156
  • According to the rst2pdf manual, the raw directive sends commands directly to [ReportLab](http://www.reportlab.com/software/opensource/). ReportLab apparently only supports embedding PDFs with the PageCatcher add-on, which requires payment. – Chrizmo May 19 '12 at 18:44
0

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.

Roberto Alsina
  • 782
  • 4
  • 8
  • I've tried using GS and Pdftk. The former breaks the page numbering and the PDF index, and the latter just hangs under execution without doing any actual work. I'm beginning to think there's no easy way of doing this open source. – Chrizmo May 20 '12 at 08:51
  • Your appendices won't appear in the index/table of contents, but you can easily merge PDFS with [Ghostscript](http://pages.cs.wisc.edu/~ghost/) using the command: `gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf your_pdf.pdf appendix1.pdf appendix2.pdf`. – Chris May 20 '12 at 19:14
0

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

Chrizmo
  • 626
  • 2
  • 7
  • 18