yyn0210 / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

addImage() and addImageStream() cause corrupt PDF: #246

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use 0.1.5 RC swc
2. Inside of a canvas, create n HBoxes, each being the size of a printable
A4 page (or as close as 72 PPI and 300 DPI allow you to get)
3. Add each HBox to the PDF.

What is the expected output? What do you see instead?
I expect to see a PDF with image snapshots of components, or image
components themselves (inside of a canvas large enough for individual
pages).  However, and strangely enough, on the first, third, fifth, odd n +
2, times I run this, I get a PDF with the correct size and number of pages,
but an error: "There was a problem reading this document (14)."

What version of the product are you using? On what operating system?
Using 0.1.5 RC source code, on Windows7 64 (Springsource STS w/
Flashbuilder 4 plugin, SDK 3.4),  on Mac 10.6.2 (Eclipse Ganymede w/
Flashbuilder 4 plugin, SDK 3.4)

Please provide any additional information below.
Oddity was that on the 2nd, 4th, 6th, even n + 2 time I ran it (where I
didn't initialize a new PDF, but was adding to my existing one, I would get
the added images (but only from the second set, not from the first set).

Finally I pulled the source code itself into the project to step through
the add and save portions.  What I found was the following:

protected var image:PDFImage

and inside of insertImage(), for each (var image:PDFImage in streamDictionary).

Once I found this, I changed the var inside the function to be
insert_image:PDFImage, and all subsequent vars inside the method that
referenced that var.  I did not have a chance to actually spend time
inspecting the effect of using the class variable and the local variable,
but once I changed this, the PDF was populating every time without error.

Original issue reported on code.google.com by jpba...@remachines.com on 27 May 2010 at 3:13