danfickle / danfickle/openhtmltopdf
Cannot display SVG with inline png image (png on multiple lines)
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
Had a 6 hour debugging session to figure out why my SVG is not displayed with inline png image. I'm using openhtmltopdf (and svg-support) version 1.0.10 (with batik version 1.14) and openjdk 11.0.9_11.
I suspect line 125 in SVGImageExtension to be in error and further line 34 in the same file. Since the inline png image is provided as data:image/png, the lines 125/34 tries to resolve its URI, which leads to the following error in java.net.URI: Illegal character in opaque part.
https://github.com/danfickle/openhtmltopdf/blob/780ba564839f1ad5abfa5df12e4aebb9dd6782d2/openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/SVGImageExtension.java#L125
https://github.com/danfickle/openhtmltopdf/blob/780ba564839f1ad5abfa5df12e4aebb9dd6782d2/openhtmltopdf-svg-support/src/main/java/com/openhtmltopdf/svgsupport/SVGImageExtension.java#L34
The issue only happens when the inline png is displayed on multiple lines. This happens for example with Adobe Illustrator 17.0.2, SVG Export Plug-In. So, a multi line inline png (using \n character or even a space) generated by another tool gets parsed using URI Java API which leads to an error.
In my debug session I have bypassed somehow the line 125 in SVGImageExtension. As a consequence, the SVG has been correctly displayed in the generated PDF file.
Thanks for your support.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.