I had a requirement to use the save() function twice, once to get the binary
for saving to the
database, then again to print the file to the browser so the user could preview
it. The first save
worked fine, but the second file would always result in a corrupt PDF file.
myPDF.fileData = myPDF.save(Method.LOCAL);
myPDF.save(Method.REMOTE, "/go/print","inline",outFilename);
I worked around the issue by subclassing PDF.as, adding a numSaves:uint class
variable, and
only invoking the finish() logic when numSaves==0:
override public function save ( method:String, url:String='',
downloadMethod:String='inline', fileName:String='generated.pdf',
frame:String="_blank" ):*
{
// don't do finishing more than once per file. causes second save to corrupt.
if(numSaves==0) {
dispatcher.dispatchEvent( new ProcessingEvent ( ProcessingEvent.STARTED ) );
var started:Number = getTimer();
finish();
dispatcher.dispatchEvent ( new ProcessingEvent ( ProcessingEvent.COMPLETE,
getTimer() - started ) );
buffer.position = 0;
var output:* = null;
}
numSaves++;
....
Original issue reported on code.google.com by rich.thi...@gmail.com on 8 Dec 2009 at 7:20
Original issue reported on code.google.com by
rich.thi...@gmail.com
on 8 Dec 2009 at 7:20