贾斯珀报告 - 显示来自html源代码的图像 [英] Jasper Reports - Show images from html source

查看:98
本文介绍了贾斯珀报告 - 显示来自html源代码的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编辑由一位使用 Jasper Reports 的同事创建的代码,用于创建 PDF 文件其中一个元素是一堆html代码。这个html由文本和图像组成(链接并以 base64格式)。



几乎所有的东西都可以正常工作,但我有问题的HTML。最重要的是图片不会显示出来,其次不是所有的html标签都得到处理。



这甚至可以处理 Jasper Reports



 < textField> 
< reportElement positionType =Floatx =100y =73width =611height =307uuid =d3037b2c-6592-4d7b-b703-d64f736ca4be/>
< textElement markup =html/>
< textFieldExpression><![CDATA [$ F {content_1}]]>< / textFieldExpression>
< / textField>

要由模板处理的数据:

 <?xml version =1.0encoding =UTF-8standalone =yes?> 
<指南针>
<消息>
< message>
< attachmentCount> 0< / attachmentCount>
< attachmentString>< / attachmentString>
< contactPerson> compassmanager manager< / contactPerson>
< contactPersonDepartment> Bike< / contactPersonDepartment>
< content>< p& gt;< b& gt; 123& lt; / b& gt;& lt; / p& gt;& lt; p& gt; &安培; LT;
img src =http://globalgamejam.org/sites/default
/ files / styles / game_sidebar__normal
/public/game/featured_image/promo_5.png
?itok = 9dymM8JDstyle =width:135px; height:
98px;/& gt;< b& gt;< br /& gt;& lt;
/ b& gt;& lt; / p& gt;& lt; p& gt;& lt; i& gt;
456& lt; / i& gt;& lt; / p& gt;& lt; p& gt;& lt;
u& gt; 789& lt; /& gt;& lt; / p& gt;< p& gt;& lt;
img src =data:image / jpeg; base64,/ 9j /
4AAQSkZJRgABAgAAAQABAAD ......
sxwW6jrcshiI96diGk3OT0joAQBR0nmptgn // 2Q ==
style =width: 25%;/&安培; GT;&安培; LT; U&安培; GT;&安培; LT峰; br /&安培; GT;&安培; LT;
/ u& gt;& lt; / p& gt;& lt; p& gt;< strike& gt;
012& lt; / strike& gt;& lt; / p& gt;< / content>
<国家> BE< /国家>
<部门>销售< / departments>
< duedate> 16/11/2015< / duedate>
< messageType> ACTION< / messageType>
< title> Testerij< / title>
< / message>
< /消息>
< publishdate> 16/11/2015< / publishdate>
< title>指南针47.7< / title>
< / compass>

解决方案

如果在Jasper Studio中找到了html组件。我和同事之间有一个小小的讨论,不管它是否从一开始就在那里,但这对目前的情况并不重要。正如Petter Friberg所说,它至少可以从6.0版本开始使用,而且自从我们开始使用Jasper Reports以来,我们一直在使用它。可能被忽视了。

这适用于我的html和其中的链接图像,但尚未处理base64信息。我目前正在通过确保图片上传时粘贴或拖入文本框并自动添加为链接图像来解决此问题。



我目前正在从TextAngular到CKEditor / ng-ckeditor的组合,因为它的插件为此目的效果很好。



在完成之前还有一些工作要做,但是这个

使用 textField 表格, img style =border:1px ecc。



由于文本字段显示文本。带格式的文本,es。 < b>字符串< / b> 将起作用。

一种方法是检查jasper报告htmlcomponent < hc:html /> 这会呈现您的html或网址的图片


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>&lt;p&gt;&lt;b&gt;123&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;
                     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;"/&gt;&lt;b&gt;&lt;br/&gt;&lt;
                     /b&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;
                     456&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;
                     u&gt;789&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;
                     img src="data:image/jpeg;base64,/9j/
                     4AAQSkZJRgABAgAAAQABAAD......
                     sxwW6jrcshiI96diGk3OT0joAQBR0nmptgn//2Q=="
                     style="width: 25%;"/&gt;&lt;u&gt;&lt;br/&gt;&lt;
                     /u&gt;&lt;/p&gt;&lt;p&gt;&lt;strike&gt;
                     012&lt;/strike&gt;&lt;/p&gt;</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.

解决方案

With textField NO, markup="html" will not work on tags like table, img, style="border:1px" ecc.

Why? Because a text field displays text. Formatted text, es. <b>String</b> will work.

One way would be to check the jasper report htmlcomponent <hc:html/> this will render an image of your html or an url

这篇关于贾斯珀报告 - 显示来自html源代码的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆