【问题标题】:Removing extra padding from StaticText/TextFields从 StaticText/TextFields 中删除额外的填充
【发布时间】:2014-12-10 21:43:06
【问题描述】:

是否可以删除文本字段/静态文本字段中的额外填充?这是一个例子:

编辑:我不是指文本字段的宽度,我指的是高度。

我将文本字段的像素大小设置为尽可能低的数字,而文本不会消失。

字段上的填充设置为 0。

我发现我用这个填充浪费了大量的额外空间。我不确定我是否能够将所需信息与我需要使用的字体大小一起放入一页报告中。

【问题讨论】:

  • 您可以减少文本字段的高度以及文本的字体大小以减少额外的填充。
  • 您好,感谢您的评论。我的问题是我需要为某些元素使用特定的字体大小。我无法更改字体大小,也无法调整文本字段大小超过某个点,因为有一些额外的填充。我在下面遇到的解决方案可以达到我的目的。

标签: jasper-reports


【解决方案1】:

minus 也适用于填充。下面的代码确实救了我。请注意在下面的代码中我使用的是减 13。当你增加负数时,填充变得越来越小。

<box topPadding="-13" leftPadding="3" bottomPadding="-13" rightPadding="3">
                    <pen lineWidth="1.0"/>
                    <topPen lineWidth="1.0" lineColor="#666666"/>
                    <leftPen lineWidth="1.0" lineStyle="Dotted" lineColor="#FFFFFF"/>
                    <bottomPen lineWidth="1.0" lineColor="#666666"/>
                    <rightPen lineWidth="1.0" lineColor="#666666"/>
                </box>

【讨论】:

    【解决方案2】:

    实际上,我找到了一种方法,虽然有点 hacky。

    提供填充(用于边框)的是“box”元素。 为了删除填充,将框填充设置为 -1,如下所示:

    <staticText>
                <reportElement x="10" y="271" width="160" height="15" uuid="325acf4c-c003-4d50-aa1e-a3ae1c8f0dff">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box padding="-1"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[SPECIAL INSTRUCTIONS]]></text>
    </staticText>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-06
      • 2011-11-24
      • 1970-01-01
      • 2017-09-18
      • 2015-10-24
      • 2014-12-14
      • 1970-01-01
      • 2011-10-16
      相关资源
      最近更新 更多