mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-29 15:47:57 +02:00
Use the environment's zlib implementation if available to get reasonably-sized SVG files when an XObject image is converted to PNG. The generated PNG is not optimal because we do not use a PNG predictor. Futher, when our SVG backend is run in a browser, the generated PNG images will still be unnecessarily large (though the use of blob:-URLs when available should reduce the impact on memory usage). If we want to optimize PNG images in browsers too, we can either try to use a DEFLATE library such as pako, or re-use our XObject image painting logic in src/display/canvas.js. This potential improvement is not implemented by this commit Tested with: - Node.js 8.1.3 (uses zlib) - Node.js 0.11.12 (uses zlib) - Node.js 0.10.48 (falls back to inferior existing implementation). - Chrome 59.0.3071.86 - Firefox 54.0 Tests: Unit test on Node.js: ``` $ gulp lib $ JASMINE_CONFIG_PATH=test/unit/clitests.json node ./node_modules/.bin/jasmine --filter=SVG ``` Unit test in browser: Run `gulp server` and open http://localhost:8888/test/unit/unit_test.html?spec=SVGGraphics To verify that the patch works as desired, ``` $ node examples/node/pdf2svg.js test/pdfs/xobject-image.pdf $ du -b svgdump/xobject-image-1.svg # ^ Calculates the file size. Confirm that the size is small # (784 instead of 80664 bytes). ``` |
||
---|---|---|
.. | ||
annotation_spec.js | ||
api_spec.js | ||
bidi_spec.js | ||
cff_parser_spec.js | ||
clitests.json | ||
cmap_spec.js | ||
crypto_spec.js | ||
custom_spec.js | ||
display_svg_spec.js | ||
document_spec.js | ||
dom_utils_spec.js | ||
evaluator_spec.js | ||
fonts_spec.js | ||
function_spec.js | ||
jasmine-boot.js | ||
metadata_spec.js | ||
murmurhash3_spec.js | ||
network_spec.js | ||
parser_spec.js | ||
primitives_spec.js | ||
stream_spec.js | ||
test_utils.js | ||
testreporter.js | ||
type1_parser_spec.js | ||
ui_utils_spec.js | ||
unicode_spec.js | ||
unit_test.html | ||
util_spec.js | ||
util_stream_spec.js |