Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to use SVG information in Jasper Report?(Scout Juno 3.8)
How to use SVG information in Jasper Report? [message #1334292] Mon, 05 May 2014 13:52 Go to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi all,
I have create a Jasper-Report with a lot of text fields and for the moment all works fine.

Now I have the necessity to integrate a SVG field to rappresent a drawing.
I define an image in the report and one parameter to transfer SVG data, but return to me un exception

Quote:

!MESSAGE org.eclipse.scout.rt.shared.services.common.exceptionhandler.LogExceptionHandlerService.differentiatedLog(LogExceptionHandlerService.java:76) ProcessingStatus[ERROR code=0 invoking org.zeiss.mo.scout.CZVEDIController.shared.services.custom.reporting.IReportingService:createEDIOrderReport / An error occured during the creation of the report. net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $P{ShapeImage}]

ProcessingException[ProcessingStatus[ERROR code=0 invoking org.zeiss.mo.scout.CZVEDIController.shared.services.custom.reporting.IReportingService:createEDIOrderReport / An error occured during the creation of the report. net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $P{ShapeImage}]]

Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $P{ShapeImage}

Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg viewBox="0 0 900 250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" version="1.1" xml:space="preserve" preserveAspectRatio="xMidYMid meet"> <line x1="10.0" y1="55.354330708" x2="195.196850391" y2="55.354330708" style="stroke:red;stroke-width:1" /><line x1="102.5984251955" y1="10.0" x2="102.5984251955" y2="100.708661416" style="stroke:red;stroke-width:1" /><circle cx="102.5984251955" cy="55.354330708" r="1" stroke="red" stroke-width="1" />....


In my report I define the parameter and the element in the follow way:

	<parameter name="ShapeImage" class="net.sf.jasperreports.engine.JRRenderable" isForPrompting="false">
		<parameterDescription><![CDATA[]]></parameterDescription>
	</parameter>

...
	<image hAlign="Center" vAlign="Middle">
		<reportElement x="2" y="106" width="551" height="186" uuid="0407b952-8088-4146-9dfc-b61f71e78201"/>
		<graphicElement/> 
		<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[$P{ShapeImage}]]></imageExpression>
	</image>
...


I try with parameter with class="net.sf.jasperreports.engine.JRRenderable" or ="java.lang.String" or ="java.awt.Image", but everytime return to me an exception.

The SVG information is stored into a String that I pass at this parameter; below you find an example of this string
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg viewBox="0 0 900 250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" version="1.1" xml:space="preserve" preserveAspectRatio="xMidYMid meet"> <line x1="10.0" y1="55.354330708" x2="195.196850391" y2="55.354330708" style="stroke:red;stroke-width:1" /><line x1="102.5984251955" y1="10.0" x2="102.5984251955" y2="100.708661416" style="stroke:red;stroke-width:1" /><circle cx="102.5984251955" cy="55.354330708" r="1" stroke="red" stroke-width="1" /><line x1="122.165354329" y1="55.354330708" x2="132.165354329" y2="55.354330708" style="stroke:green;stroke-width:1" /><line x1="127.165354329" y1="50.354330708" x2="127.165354329" y2="60.354330708" style="stroke:green;stroke-width:1" /><circle cx="192.67343983190142" cy="39.47167533989254" r="1" stroke="black" stroke-width="1" /><circle cx="193.51923562108152" cy="22.26186203772813" r="1" stroke="black" stroke-width="1" /><circle cx="175.5900466283618" cy="13.212598425150006" r="1" stroke="black" stroke-width="1" /><circle cx="154.71357471086574" cy="11.624527970907806" r="1" stroke="black" stroke-width="1" /><circle cx="140.01170087056778" cy="10.766925011520428" r="1" stroke="black" stroke-width="1" /><circle cx="128.48818897465" cy="10.511944446555773" r="1" stroke="black" stroke-width="1" /><circle cx="119.01539207489269" cy="10.249084910934187" r="1" stroke="black" stroke-width="1" /><circle cx="110.53975287955373" cy="10.316823389799282" r="1" stroke="black" stroke-width="1" /><circle cx="102.5984251955" cy="10.377952755899997" r="1" stroke="black" stroke-width="1" /><circle cx="94.65709751144627" cy="10.316823389799282" r="1" stroke="black" stroke-width="1" /><circle cx="86.18145831610732" cy="10.249084910934187" r="1" stroke="black" stroke-width="1" /><circle cx="76.70866141635001" cy="10.511944446555773" r="1" stroke="black" stroke-width="1" /><circle cx="65.42809286897163" cy="11.05645361993912" r="1" stroke="black" stroke-width="1" /><circle cx="50.772804288552976" cy="11.867471319447198" r="1" stroke="black" stroke-width="1" /><circle cx="29.934120450677966" cy="13.401574803100011" r="1" stroke="black" stroke-width="1" /><circle cx="12.743093017093301" cy="22.64966440495786" r="1" stroke="black" stroke-width="1" /><circle cx="10.662356537685326" cy="39.14352130336137" r="1" stroke="black" stroke-width="1" /><circle cx="10.377952755900012" cy="55.354330707999985" r="1" stroke="black" stroke-width="1" /><circle cx="10.662356537685326" cy="71.5651401126386" r="1" stroke="black" stroke-width="1" /><circle cx="12.387933601368374" cy="88.18826446678537" r="1" stroke="black" stroke-width="1" /><circle cx="31.570703890876672" cy="96.36220472315" r="1" stroke="black" stroke-width="1" /><circle cx="51.062332896971654" cy="98.5982467480134" r="1" stroke="black" stroke-width="1" /><circle cx="65.42809286897162" cy="99.65220779606088" r="1" stroke="black" stroke-width="1" /><circle cx="76.70866141634997" cy="100.19671696944422" r="1" stroke="black" stroke-width="1" /><circle cx="86.18145831610728" cy="100.4595765050658" r="1" stroke="black" stroke-width="1" /><circle cx="94.65709751144627" cy="100.39183802620072" r="1" stroke="black" stroke-width="1" /><circle cx="102.59842519549998" cy="100.3307086601" r="1" stroke="black" stroke-width="1" /><circle cx="110.5397528795537" cy="100.39183802620073" r="1" stroke="black" stroke-width="1" /><circle cx="118.88612461914944" cy="100.10441708934088" r="1" stroke="black" stroke-width="1" /><circle cx="128.11023621875" cy="99.54208359336474" r="1" stroke="black" stroke-width="1" /><circle cx="139.03992747641016" cy="98.78362197080477" r="1" stroke="black" stroke-width="1" /><circle cx="152.68687445193484" cy="97.3835300053164" r="1" stroke="black" stroke-width="1" /><circle cx="165.77054598716958" cy="91.82677165235003" r="1" stroke="black" stroke-width="1" /><circle cx="173.98546775621045" cy="81.3370893123932" r="1" stroke="black" stroke-width="1" /><circle cx="181.13490489913926" cy="69.20243104961436" r="1" stroke="black" stroke-width="1" /><circle cx="187.637795273" cy="55.35433070800002" r="1" stroke="black" stroke-width="1" /><polyline points=" 192.67343983190142,39.47167533989254 193.51923562108152,22.26186203772813 175.5900466283618,13.212598425150006 154.71357471086574,11.624527970907806 140.01170087056778,10.766925011520428 128.48818897465,10.511944446555773 119.01539207489269,10.249084910934187 110.53975287955373,10.316823389799282 102.5984251955,10.377952755899997 94.65709751144627,10.316823389799282 86.18145831610732,10.249084910934187 76.70866141635001,10.511944446555773 65.42809286897163,11.05645361993912 50.772804288552976,11.867471319447198 29.934120450677966,13.401574803100011 12.743093017093301,22.64966440495786 10.662356537685326,39.14352130336137 10.377952755900012,55.354330707999985 10.662356537685326,71.5651401126386 12.387933601368374,88.18826446678537 31.570703890876672,96.36220472315 51.062332896971654,98.5982467480134 65.42809286897162,99.65220779606088 76.70866141634997,100.19671696944422 86.18145831610728,100.4595765050658 94.65709751144627,100.39183802620072 102.59842519549998,100.3307086601 110.5397528795537,100.39183802620073 118.88612461914944,100.10441708934088 128.11023621875,99.54208359336474 139.03992747641016,98.78362197080477 152.68687445193484,97.3835300053164 165.77054598716958,91.82677165235003 173.98546775621045,81.3370893123932 181.13490489913926,69.20243104961436 187.637795273,55.35433070800002 192.67343983190142,39.47167533989254" style="fill:none;stroke:blue;stroke-width:1" /><line x1="263.228346453" y1="55.354330708" x2="448.42519684399997" y2="55.354330708" style="stroke:red;stroke-width:1" /><line x1="355.82677164849997" y1="10.0" x2="355.82677164849997" y2="100.708661416" style="stroke:red;stroke-width:1" /><circle cx="355.82677164849997" cy="55.354330708" r="1" stroke="red" stroke-width="1" /><line x1="326.25984251499995" y1="55.354330708" x2="336.25984251499995" y2="55.354330708" style="stroke:green;stroke-width:1" /><line x1="331.25984251499995" y1="50.354330708" x2="331.25984251499995" y2="60.354330708" style="stroke:green;stroke-width:1" /><circle cx="447.7628403063146" cy="39.143521303361396" r="1" stroke="black" stroke-width="1" /><circle cx="445.68210382690665" cy="22.649664404957882" r="1" stroke="black" stroke-width="1" /><circle cx="428.49107639332203" cy="13.401574803100011" r="1" stroke="black" stroke-width="1" /><circle cx="407.652392555447" cy="11.867471319447212" r="1" stroke="black" stroke-width="1" /><circle cx="392.9971039750283" cy="11.05645361993912" r="1" stroke="black" stroke-width="1" /><circle cx="381.71653542765" cy="10.511944446555773" r="1" stroke="black" stroke-width="1" /><circle cx="372.2437385278927" cy="10.249084910934187" r="1" stroke="black" stroke-width="1" /><circle cx="363.7680993325537" cy="10.316823389799282" r="1" stroke="black" stroke-width="1" /><circle cx="355.82677164849997" cy="10.377952755899997" r="1" stroke="black" stroke-width="1" /><circle cx="347.88544396444627" cy="10.316823389799282" r="1" stroke="black" stroke-width="1" /><circle cx="339.40980476910727" cy="10.249084910934187" r="1" stroke="black" stroke-width="1" /><circle cx="329.93700786935" cy="10.511944446555773" r="1" stroke="black" stroke-width="1" /><circle cx="318.4134959734322" cy="10.766925011520428" r="1" stroke="black" stroke-width="1" /><circle cx="303.71162213313426" cy="11.624527970907792" r="1" stroke="black" stroke-width="1" /><circle cx="282.8351502156382" cy="13.212598425150006" r="1" stroke="black" stroke-width="1" /><circle cx="264.90596122291845" cy="22.261862037728115" r="1" stroke="black" stroke-width="1" /><circle cx="265.75175701209855" cy="39.47167533989251" r="1" stroke="black" stroke-width="1" /><circle cx="270.787401571" cy="55.35433070799999" r="1" stroke="black" stroke-width="1" /><circle cx="277.2902919448607" cy="69.20243104961436" r="1" stroke="black" stroke-width="1" /><circle cx="284.4397290877895" cy="81.33708931239315" r="1" stroke="black" stroke-width="1" /><circle cx="292.65465085683036" cy="91.82677165235" r="1" stroke="black" stroke-width="1" /><circle cx="305.73832239206513" cy="97.38353000531637" r="1" stroke="black" stroke-width="1" /><circle cx="319.3852693675898" cy="98.78362197080477" r="1" stroke="black" stroke-width="1" /><circle cx="330.31496062524997" cy="99.54208359336474" r="1" stroke="black" stroke-width="1" /><circle cx="339.5390722248505" cy="100.10441708934087" r="1" stroke="black" stroke-width="1" /><circle cx="347.88544396444627" cy="100.39183802620072" r="1" stroke="black" stroke-width="1" /><circle cx="355.82677164849997" cy="100.3307086601" r="1" stroke="black" stroke-width="1" /><circle cx="363.7680993325537" cy="100.39183802620073" r="1" stroke="black" stroke-width="1" /><circle cx="372.2437385278927" cy="100.45957650506581" r="1" stroke="black" stroke-width="1" /><circle cx="381.71653542765" cy="100.19671696944422" r="1" stroke="black" stroke-width="1" /><circle cx="392.9971039750283" cy="99.65220779606088" r="1" stroke="black" stroke-width="1" /><circle cx="407.3628639470283" cy="98.59824674801341" r="1" stroke="black" stroke-width="1" /><circle cx="426.85449295312327" cy="96.36220472315003" r="1" stroke="black" stroke-width="1" /><circle cx="446.0372632426316" cy="88.18826446678543" r="1" stroke="black" stroke-width="1" /><circle cx="447.7628403063146" cy="71.5651401126386" r="1" stroke="black" stroke-width="1" /><circle cx="448.04724408809994" cy="55.35433070800002" r="1" stroke="black" stroke-width="1" /><polyline points=" 447.7628403063146,39.143521303361396 445.68210382690665,22.649664404957882 428.49107639332203,13.401574803100011 407.652392555447,11.867471319447212 392.9971039750283,11.05645361993912 381.71653542765,10.511944446555773 372.2437385278927,10.249084910934187 363.7680993325537,10.316823389799282 355.82677164849997,10.377952755899997 347.88544396444627,10.316823389799282 339.40980476910727,10.249084910934187 329.93700786935,10.511944446555773 318.4134959734322,10.766925011520428 303.71162213313426,11.624527970907792 282.8351502156382,13.212598425150006 264.90596122291845,22.261862037728115 265.75175701209855,39.47167533989251 270.787401571,55.35433070799999 277.2902919448607,69.20243104961436 284.4397290877895,81.33708931239315 292.65465085683036,91.82677165235 305.73832239206513,97.38353000531637 319.3852693675898,98.78362197080477 330.31496062524997,99.54208359336474 339.5390722248505,100.10441708934087 347.88544396444627,100.39183802620072 355.82677164849997,100.3307086601 363.7680993325537,100.39183802620073 372.2437385278927,100.45957650506581 381.71653542765,100.19671696944422 392.9971039750283,99.65220779606088 407.3628639470283,98.59824674801341 426.85449295312327,96.36220472315003 446.0372632426316,88.18826446678543 447.7628403063146,71.5651401126386 448.04724408809994,55.35433070800002 447.7628403063146,39.143521303361396" style="fill:none;stroke:blue;stroke-width:1" /></svg>


I work with Java with IDE Eclipse Juno 3.8 and Jasperstudio 5.5.2.

I think my mistake is in step as I pass the data to the parameter, but I cannot figure out exactly what and where. In my application the SVG data is defined as String, how can manage it with the corrisponding paramert in Jasper-Report?
I have also the following question : when I haven't this information to create SVG data, how can manage the corrisponding parameter in Jasper-Report?

Thanks in advance for any help and explanation
Re: How to use SVG information in Jasper Report? [message #1336758 is a reply to message #1334292] Tue, 06 May 2014 14:56 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 204
Registered: February 2013
Location: Italy
Senior Member
Hi,
I solved this problem.

An help is on this links:

https://www.linuxnet.ch/jasper-reports-inline-images-as-svg-for-better-scaling/

and

http://community.jaspersoft.com/questions/525861/how-use-svg-jasperreports

If you have/use a inline SVG string instead of SVG file, as showed in this links, it's necessary use this net.sf.jasperreports.renderers.BatikRenderer.getInstanceFromText in your report definition.

Example of my .jrxml:
...
	<parameter name="ShapeImage" class="java.lang.String" isForPrompting="false">
		<parameterDescription><![CDATA[]]></parameterDescription>
	</parameter>

...
	<image hAlign="Center" vAlign="Middle">
		<reportElement x="2" y="106" width="551" height="186" uuid="0407b952-8088-4146-9dfc-b61f71e78201"/>
		<imageExpression><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstanceFromText($P{ShapeImage})]]></imageExpression>
	</image>
</frame>
...


Re: How to use SVG information in Jasper Report? [message #1338322 is a reply to message #1336758] Wed, 07 May 2014 06:52 Go to previous message
Matthias Nick is currently offline Matthias NickFriend
Messages: 197
Registered: August 2013
Senior Member
Hi marco,
cool! Thanks for sharing your solution!

Matthias
Previous Topic:Automatically adjust the size of a dialog
Next Topic:Enabling/disabling form fields
Goto Forum:
  


Current Time: Sat Apr 20 01:03:51 GMT 2024

Powered by FUDForum. Page generated in 0.03338 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top