I'm currently editing code created by a colleague which uses Jasper Reports
to create a PDF
file with certain elements of which one is a bunch of html code. This html consists of text and images (both linked and in base64 format
).
Almost everything works perfectly, but I have issues with the html. Most importantly the images do not show up and secondly not all html tags get processed.
Is this even possible to do with Jasper Reports
?
Current code in the template where the html
is supposed to go:
<textField>
<reportElement positionType="Float" x="100" y="73" width="611" height="307" uuid="d3037b2c-6592-4d7b-b703-d64f736ca4be"/>
<textElement markup="html"/>
<textFieldExpression><![CDATA[$F{content_1}]]></textFieldExpression>
</textField>
Data to be processed by the template:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<compass>
<messages>
<message>
<attachmentCount>0</attachmentCount>
<attachmentString></attachmentString>
<contactPerson>compassmanager manager</contactPerson>
<contactPersonDepartment>Bike</contactPersonDepartment>
<content><p><b>123</b></p><p><
img src="http://globalgamejam.org/sites/default
/files/styles/game_sidebar__normal
/public/game/featured_image/promo_5.png
?itok=9dymM8JD" style="width: 135px;height:
98px;"/><b><br/><
/b></p><p><i>
456</i></p><p><
u>789</u></p><p><
img src="data:image/jpeg;base64,/9j/
4AAQSkZJRgABAgAAAQABAAD......
sxwW6jrcshiI96diGk3OT0joAQBR0nmptgn//2Q=="
style="width: 25%;"/><u><br/><
/u></p><p><strike>
012</strike></p></content>
<countries>BE</countries>
<departments>Sales</departments>
<duedate>16/11/2015</duedate>
<messageType>ACTION</messageType>
<title>Testerij</title>
</message>
</messages>
<publishdate>16/11/2015</publishdate>
<title>Compass 47.7</title>
</compass>
Solution
If found the html-component in Jasper Studio. There's a small discussion between me and colleagues whether or not it has been there from the beginning, but that doesn't really matter for the current situation. As Petter Friberg said below it's available from at least version 6.0 and upwards and we've been using that since we started working with Jasper Reports. Probably overlooked it.
This works for my html and the linked images in it, but doesn't yet process the base64 info. I'm currently fixing this by making sure the images get uploaded when pasted or dragged into the textfield and automatically get added as a linked image.
I'm currently switching from TextAngular to the CKEditor/ng-ckeditor combo because the lather has plugins for this purpose that work quite well.
Still some work to do before I'm finished, but this is the way to go.