Jasper reports 使用JasperReports在生成的PDF中缩进
我在数据库中存储了一段HTML,如下所示:Jasper reports 使用JasperReports在生成的PDF中缩进,jasper-reports,pdf-generation,indentation,export-to-pdf,Jasper Reports,Pdf Generation,Indentation,Export To Pdf,我在数据库中存储了一段HTML,如下所示: <ul> <li>Pretend you're talking to a busy colleague and have to sum up your entire question in one sentence: what details can you include that will help someone identify and solve your problem?</li> <li&
<ul>
<li>Pretend you're talking to a busy colleague and have to sum up your entire question in one sentence: what details can you include that will help someone identify and solve your problem?</li>
<li>Spelling, grammar and punctuation are important! Remember, this is the first part of your question others will see - you want to make a good impression. If you're not comfortable writing in English, ask a friend to proof-read it for you. </li>
<li>If you're having trouble summarizing the problem, write the title last - sometimes writing the rest of the question first can make it easier to describe the problem. </li>
</ul>
- 假设你正在和一位忙碌的同事交谈,并且必须用一句话来总结你的整个问题:你可以包括哪些细节来帮助别人识别和解决你的问题
- 拼写、语法和标点符号很重要!记住,这是你的问题的第一部分,其他人会看到-你想留下好印象。如果你不习惯用英语写作,请朋友帮你校对李>
- 如果你在总结问题时遇到困难,请最后写标题——有时先写问题的其余部分可以更容易地描述问题李>
我使用JasperReports文本字段在PDF中显示这段HTML,上面的HTML在生成的PDF中应该显示如下
- 假设你正在和一位忙碌的同事交谈,并且必须用一句话来总结你的整个问题:你可以包括哪些细节来帮助别人识别和解决你的问题
- 拼写、语法和标点符号很重要!记住,这是你的问题的第一部分,其他人会看到-你想留下好印象。如果你不习惯用英语写作,请朋友帮你校对李>
- 如果你在总结问题时遇到困难,请最后写标题——有时先写问题的其余部分可以更容易地描述问题
HTML输入到描述变量中
知道如何对齐文本吗?我的解决方案显示的是纯
JRXML
,这是一个理想的结果,与人们正在使用的工具无关,例如iReport GUI、动态报告或java代码设计Jasper报告
首先定义一个样式,它修正缩进,将第一行向左拉一些像素,并将整个框向右推相同的宽度:
<style name="hanging-indentation-style">
<box leftPadding="23"/>
<paragraph firstLineIndent="-23"/>
</style>
根据字体大小,您可以根据需要更改样式值
我修改了输入,其中使用了动态报告api,并且通过GUI显示,这在我使用iReport Designer 4.5.1的情况下是不可能的,因为如果我们像你建议的那样做得很糟糕,就没有选项直接将填充应用于
文本字段
,这意味着在jasperreports中ul/li没有意义。与其他标记类型一起,它们被解析为内部结构。结果以默认样式进行布局。在您的情况下,默认列表样式没有挂起缩进,因此需要自定义样式来实现所需的结果。相关
<style name="hanging-indentation-style">
<box leftPadding="23"/>
<paragraph firstLineIndent="-23"/>
</style>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="hanging-indentation-style" positionType="Float" mode="Transparent" x="0" y="0" width="555" height="20" isRemoveLineWhenBlank="true"/>
<textElement markup="html"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{description}]]></textFieldExpression>
</textField>