我有一段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>
我使用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>
HTML description 变量。
知道如何对齐文字?
答案 0 :(得分:8)
我的解决方案显示普通JRXML
,这是与某人正在使用的工具无关的所需结果,例如iReport GUI,动态报告或Java代码设计Jasper报告。
首先定义一个样式,用于修正将第一行拉到左侧的一些像素的缩进,并向右推动整个框的宽度:
<style name="hanging-indentation-style">
<box leftPadding="23"/>
<paragraph firstLineIndent="-23"/>
</style>
其次,此样式适用于reportElement
的{{1}}:
textField
根据您的字体大小,您可以根据需要改变样式值。
我调整了使用动态报告api的Aligning Bullets in Jasper Reports和Jasper Report HTML bullet hanging indent的输入,它通过GUI显示,这在我的情况下使用iReport Designer 4.5.1是不可能的,因为没有选项可以直接将填充应用于<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>
。