[reportlab-users] Damaged pdf file in release mode Compile

Robin Becker robin at reportlab.com
Tue Apr 18 10:17:37 EDT 2006


Thomas Zehbe wrote:
> Hi All,
> 
> The report code connects to a PostgreSQL database to retrieve the data defined 
> by the given parameters an builds a simple report using the platypus engine.
> The app is compiled and linked with Visual C 6.
> 
> Using the debug version of the app I get a readable pdf doc just as expected. 
> Using the release version of the app leads do a damaged pdf doc which cannot 
> be opened by acrobat. Message: "The file is damaged and cannot be restored."
> 
> The files are nearly equal in size. I compared them using kate on my Linux 
> box. The human readable parts seem to be the same except the sizes mentioned 
> in one of three "stream parts".
> The first two binary stream parts of files seem to be the same. But the last 
> stream part just before "endobj" differs both in size (about 50 bytes) and 
> content.
> 
> Any idea would be appreciated ....
> Thanks
> Thomas
> 

are all your files being opened in binary mode? It would be a good idea to split 
the report code off so you can supply it with data directly into the doc 
generation. So far as I know canvas.save() is OK, but if you're trying to do 
something special with streams etc then binary mode is essential.

Another way things can go wrong is if two bits of your app are trying to do 
things to the document simultaneously. reportlab is not threadsafe.
-- 
Robin Becker


More information about the reportlab-users mailing list