Item8464: GenPDF on Strawberry perl adds fatal artifacts when serving thru the browser
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
When using Strawberry perl (version various) and Foswiki (version 1.07 and 1.09) and HTMLDOC (v1.8.27) on Windows (XP and Server 2003),
GenPDF generates a valid .pdf file in tmp, but as it comes out the browser (FF 3.5.7 and IE 6 and 7) a fatal I/O error is introduced into the .pdf file. The file can still be saved, and when compared to the tmp version, several ^M s have been added within some of the streams.
--
JohnKern - 03 Feb 2010
PS. Its working fine on my cygwin perl FW109 on Windows 2003 box. I have a couple 205K pdf files I can upload or e-mail someone.
--
JohnKern - 03 Feb 2010
Can you attach the bad and good file to this topic. The code that outputs the PDF is extremely simple - I don't see where it could be adding the ^M's Unfortunately I don't have the windows version of htmldoc available for testing.
--
GeorgeClark - 05 Feb 2010
Never mind... I've found a windows binary to use and have recreated the problem. I'll report back when I understand what's going on.
...
I'm seeing quite a few differences other than the the extra ^M s, . How are you doing the comparison of the files? I also get different results when having the browser save the file vs. having acrobat save the file. Unfortunately I don't understand what's going on with this.
--
GeorgeClark - 06 Feb 2010
I believe I have a fix if you want to give it a try.
In lib/Foswiki/Contrib/GenPDF.pm, towards the end of the module, find the code where the PDF is "printed" to the browser. Add a line
binmode $ofh;
(line ends in a semicolon.)
open $ofh, $outputFile;
binmode $ofh; <<<----------- ADD THIS LINE
while (<$ofh>) {
print;
}
close $ofh;
# Cleaning up temporary files
Please post back if this works, and I'll check it in and build another test build. It doesn't appear to break the Linux version. If you could also test this on your cygwin installation, that would be great. Thanks.
--
GeorgeClark - 06 Feb 2010
A test version including the above fix is attached to
GenPDFAddOn
--
GeorgeClark - 06 Feb 2010
George, the suggested edit, fixed my strawberry
GenPDF, and did no harm to my cygwin installaion. I did not test the new attachments. Thanks for the timely response.
--
JohnKern - 07 Feb 2010
I've also had this problem and this fix works for us as well.
Note that installing this on Windows was not easy and I've updated
Foswiki:Tasks/Item1161 with some feedback as well.
--
JulianLevens - 08 Feb 2010