Skip to content

SVG images are not rendered with right size #592

Closed
@DanielWulfert

Description

@DanielWulfert

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:

<html` xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
        <title>Test</title>
    </head>
    <body>
        <div id="content" class="content">
            <div id="logo" style="margin-top:3mm;">
                <img src="some_fancy.svg" alt="here comes the SVG" title="" />
            </div>    
            <div id="main" style="font-size:15px;">Some text below the SVG</div>
         </div>
    </body>
</html>

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions