Abs*_*Abs 7 pdf-generation indentation jasper-reports 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>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>
Run Code Online (Sandbox Code Playgroud)
我使用JasperReports textField在PDF中显示这段HTML,上面的HTML应该在生成的PDF中显示如下.
但是这个HTML显示为:

来自jrxml文件的片段:
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="7" y="47" width="501" height="15" isRemoveLineWhenBlank="true" forecolor="#283234"/>
<textElement markup="html">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
</textField>
Run Code Online (Sandbox Code Playgroud)
描述变量中包含HTML .
任何想法如何对齐文本?
我的解决方案显示了plain JRXML,这是独立于某人使用的工具所需的结果,例如iReport GUI,动态报告或java代码设计Jasper报告.
首先定义一个样式,该样式可以修正第一行的缩进,将某些像素向左拉,并将整个框向右推宽度相同:
<style name="hanging-indentation-style">
<box leftPadding="23"/>
<paragraph firstLineIndent="-23"/>
</style>
Run Code Online (Sandbox Code Playgroud)
其次,这种风格应用到reportElement的textField:
<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>
Run Code Online (Sandbox Code Playgroud)
根据您的字体大小,您可以根据需要改变样式值.
我调整了Jasper Reports中Aligning Bullets的输入,其中使用了动态报告api,Jasper报告HTML子弹悬挂缩进,通过GUI显示,在我的情况下使用iReport Designer 4.5.1是不可能的,因为有没有选项直接应用填充到textField.
| 归档时间: |
|
| 查看次数: |
4718 次 |
| 最近记录: |