[reportlab-users] Combining reportlab's PDF and pypdf to partially create, partially copy?
Ken Corey
ken at kencorey.com
Fri Apr 17 10:34:50 EDT 2009
Andy Robinson wrote:
> 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".
>
Wow! Quick response. Well done!
You're right about the doubled document. After sending that email, I
editted the PDF file using vim and sure enough, the first document was
in the first part with 9 sections, and the second document had 16.
I was afraid people would say "It's not possible". Rats. I was trying
to get lazy, build up the table of contents programmatically, and then
just include each further section without any further ado. I guess I'll
have to build the whole document programmatically and give up on pypdf.
I'd better brew up a fresh pot of tea!
Thanks.
-Ken
More information about the reportlab-users
mailing list