[reportlab-users] Combining reportlab's PDF and pypdf to partially create, partially copy?

Andy Robinson andy at reportlab.com
Fri Apr 17 10:26:09 EDT 2009


2009/4/17 Ken Corey <ken at kencorey.com>:

> But the funny thing is that the output was *only* the files loaded from the

> disk, and the stuff generated by Canvas wasn't there at all.




>

> Anyone know why?  Anyone know how to get around it so that I can crate a

> page using reportlabs, and then a few pages from existing PDF files, and

> then generate some more pages, and so on?


I don't know pypdf, but I am pretty sure you can't mix it in this way.
You would have to generate the new one from reportlab, save it to
disk, and then let pypdf combine that file with the pre-existing ones.
PDF has lots of binary cross-references within the file so it is
more complex than just spitting out pages in order.

The 'save()' basically says ReportLab is finished and writes out the
PDF document to the output device. So you probably sent out two
separate PDF "files" in the same request, and Acrobat Reader (or
whatever opens it) is only looking at the latter one. If you can
capture what you generated into a file and open it with an editor,
you'll probably see two distinct files. They begin with "%%PDF-1.3"
or some version number and end with "EOF".

- Andy


More information about the reportlab-users mailing list