cage1016 / pdfium

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

pdfium_test sample program produces corrupt PPM images under Windows #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile pdfium from git under Windows

2. Run pdfium_test.exe on the attached Test.pdf [1] with the --write_images 
option:

pdfium_test.exe --write_images Test.pdf

Expected Output:
Generated PPM image looks like test-pdf-correct.png

Actual Output:
Generate PPM image looks like test-pdf-corrupt.png

What version of the product are you using? On what operating system?

Current pdfium version on Windows (commit 
9a52eb09edf2f5001f33f2227cc3888ef2e8c338)

Please provide any additional information below.

The problem stems from using just "w" in the fopen call used in the WritePpm() 
function in samples/pdfium_test.cc . 

Under Windows this implicitly uses text mode, which replaces every occurrence 
of the byte 0xa with 0x0d 0x0a while writing the ppm file.

By applying one of the two attached patches, the problem does not occur 
anymore. 

pdfium_test-fopen-file-corruption-generic.patch changes the fopen calls to 
explicitly use "wb" and "rb" on all platforms.

Alternatively pdfium_test-fopen-file-corruption-winspecific.patch uses "wb" and 
"rb" only on Windows platforms.

I would prefer the first generic version of the patch, because it is more 
explicit to use binary mode to open the files.

Test PDF obtained from:
http://stlab.adobe.com/wiki/images/d/d3/Test.pdf

Original issue reported on code.google.com by m.dopp...@gmail.com on 25 Jun 2014 at 9:38

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the detailed error report with a fix. The first patch looks best, 
I agree.

Can you follow the Chromium instructions to upload a cl for review using "git 
cl upload"? Also add yourself to AUTHORS after signing the CLA: 
http://dev.chromium.org/developers/contributing-code/external-contributor-checkl
ist. I can then land the cl for you.

Original comment by jam@chromium.org on 26 Jun 2014 at 3:18

GoogleCodeExporter commented 9 years ago
btw the instructions are http://dev.chromium.org/developers/contributing-code, 
linked to from pdfium's wiki

Original comment by jam@chromium.org on 26 Jun 2014 at 3:18

GoogleCodeExporter commented 9 years ago
Thanks for your feedback.

I signed the CLA and uploaded the change to the chromium code review site:
https://codereview.chromium.org/343303004/

Original comment by m.dopp...@gmail.com on 26 Jun 2014 at 5:01

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by jam@chromium.org on 26 Jun 2014 at 5:18