-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG images are not rendered with right size #592
Comments
Some changes to BatikSVGImage parseLength method, so that it supports absolute CSS units and fractional measurements as mentioned in danfickle#592.
We do this by firing up the CSS parser for values of the width and height attributes that are not plain numbers. With test proof (output identical to Chrome).
Hi @DanielWulfert, Firstly, thanks heaps for contributing to this project! I have not used your PR in favor of firing up the CSS parser to deal with unit values as you can see in commit. I think this will handle more units (font relative units, even percentages) than rolling another parser. However, without your PR I would not have worked on this issue, so thank you. PS. You may want to try your SVG with this commit. It gives identical output to Chrome with the simple values I have tried it with but you may find other edge cases with more complex SVGs. Thanks again, |
Hi @danfickle looks fine to me and thanks for all the efford you put into this project. Great improvement of flying-saucer. Happy to at least contribute a very small part ;) Regards, |
Hi @DanielWulfert I tried to render SVG with BASE 64 encoding, mentioned in issue. BUT while building PDF Im getting below warning and SVG image is not aligning as per width & height. Please suggest. public static void main(final String[] args) {
com.openhtmltopdf.general WARNING:: Invalid integer passed as dimension for SVG: 782.61853
--------------------------------------
|
SVG images with either given dimensions or images with no given dimensions are not rendered with the right size. Reason for that is, that BatikSVGImage.parseLength does not handle double values nor handles css units.
Simple example:
The images is rendered correctly, but the space around the image is too big. The text should be exactly below the image and the image should be 3mm away from the top. You can find the following warning messages in the output after the rendering:
com.openhtmltopdf.general WARNING:: Invalid integer passed as dimension for SVG: 850.39px
com.openhtmltopdf.general WARNING:: Invalid integer passed as dimension for SVG: 183.035px
As mentioned I am using the BatikSVGDrawer from the openhtmltopdf-svg-support plugin.
Since I have already fixed this issue for my project I will make a pull request later if you like.
The text was updated successfully, but these errors were encountered: