Attaching files to PDFs with QPDF

Here's a demo that uses QPDF to embed the markdown source code of a file into the PDF generated by pandoc.

Using the example markdown file from the Markdown to reStructuredText example at

I'm able to use pandoc to produce eg1.pdf and then attach to eg1.pdf creating out.pdf. Notice in step 4 that the list of attachements output is shown:

  1. nix-shell -p pandoc qpdf
  2. pandoc -s -o eg1.pdf
  3. qpdf eg1.pdf --add-attachment -- out.pdf
  4. qpdf --list-attachments ../out.pdf -> 146,0
  1. qpdf ../out.pdf >
  2. diff ../

I'm very grateful to Brian for pointing out QPDF to me when I went asking about attaching files to PDFs. Thanks, Brian!

Tags: PDF, pandoc, qpdf

← Back home