[reportlab-users] Broken PDFs with multiBuild and file objects
Holger Hoffmann
reportlab-users@reportlab.com
Thu, 02 Jan 2003 00:20:16 +0100
--==========1199602363==========
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
BaseDocTemplate.multiBuild with a file object as parameter
seems to produce a broken pdf document. If I use a filename
as parameter all goes well. With a file object as parameter
a broken pdf is generated. I've attached a script which
demostrates this.
The problem is that BaseDocTemplate.multiBuild makes multiple
passes and generates one complete pdf document in each pass. If
I use a filename as parameter to multiBuild, PDFDocument.SaveToFile
opens and closes the file in every pass. If I use a file
object as parameter, I get 2 pdf documents in one file.
... Holger
--
PublicKey: http://www.stud.uni-potsdam.de/~hoeffi/hohoff.pgp
Fingerprint: 38D8 D583 A95D 4D53 D6A4 FCA3 4E04 194B FFAF 29C9
--==========1199602363==========
Content-Type: application/octet-stream; name="test.py"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.py"; size=1629
ZnJvbSByZXBvcnRsYWIubGliLnVuaXRzIGltcG9ydCBpbmNoCmZyb20gcmVwb3J0bGFiLmxpYi5w
YWdlc2l6ZXMgaW1wb3J0IEE0CmZyb20gcmVwb3J0bGFiLnBsYXR5cHVzLmRvY3RlbXBsYXRlIGlt
cG9ydCBCYXNlRG9jVGVtcGxhdGUsIFBhZ2VUZW1wbGF0ZQpmcm9tIHJlcG9ydGxhYi5wbGF0eXB1
cy5mcmFtZXMgaW1wb3J0IEZyYW1lCmZyb20gcmVwb3J0bGFiLnBsYXR5cHVzLnBhcmFncmFwaCBp
bXBvcnQgUGFyYWdyYXBoCmZyb20gcmVwb3J0bGFiLnBsYXR5cHVzLmZsb3dhYmxlcyBpbXBvcnQg
UGFnZUJyZWFrCmZyb20gcmVwb3J0bGFiLmxpYi5zdHlsZXMgaW1wb3J0IGdldFNhbXBsZVN0eWxl
U2hlZXQKZnJvbSByZXBvcnRsYWIucGxhdHlwdXMudGFibGVvZmNvbnRlbnRzIG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