How to use SVG file in Jasper report ?

Hi Community,

I'm using  Jaspersoft Studio 6.12.2.

I'm inserting an SVG file in my report using :

            <image>
                <reportElement x="-20" y="-20" width="595" height="820" forecolor="#4353FA" uuid="66f9bb24-79ed-487c-b594-07c9928c9fb3">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <imageExpression><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.net.URL("https://url.svg"))]]></imageExpression>
            </image>

When testing in Jaspersoft Studio (report preview) the svg file shows properly. However when uploading my file to the server, it doesn't work.  My Jaspersoft Studio is not connected to the server, so I upload jrxml file manually.

The error I'm getting is : 

            2021-02-11T06:44:48,607 ERROR ErrorPageHandlerAction,http-nio-1000-exec-10:118 - Error UID 42135d25-06b4-4b72-bc67-5b9b2b16b969 org.apache.batik.bridge.BridgeException: null:0
            The URI "data:image/png;base64, iVBORw0KGgoAAAA....="
            on element <image> can't be opened because:
            URL data in unsupported format or corrupt
                at org.apache.batik.bridge.UserAgentAdapter.getBrokenLinkDocument(UserAgentAdapter.java:448)
                at org.apache.batik.bridge.SVGImageElementBridge.createRasterImageNode(SVGImageElementBridge.java:641)
                at org.apache.batik.bridge.SVGImageElementBridge.createImageGraphicsNode(SVGImageElementBridge.java:339)
                at org.apache.batik.bridge.SVGImageElementBridge.buildImageGraphicsNode(SVGImageElementBridge.java:179)
                at org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(SVGImageElementBridge.java:121)
                at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:213)
                at ... etc

Some one Here is saying The error can be resolved by adding batik-codec.jar to the classpath...

I downloaded a certain version of batik-codec.jar and put it as shown below but it didn't work. Still getting the same error. 

Does anyone know how to add this jar to the classpath please ? and where to find it ?

canidesign's picture
Joined: Jan 5 2019 - 8:01am
Last seen: 3 weeks 4 days ago

0 Answers:

No answers yet
Feedback