Jaspersoft页面打印方向错误

时间:2018-03-23 16:21:47

标签: jasper-reports

我有一个jasper报告以纵向打印一张小发票,但是当我发送到打印时,它是横向的并且在A4页面占用了大量空间。 如何修改方向以保持纵向?

我已经尝试将jrxml的代码放在这里,但是我很大,所以,在链接上你可以下载.jxrml或者通过pastebin。

invoice.jrxml

Invoice by pastebin

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="recibo" pageWidth="538" pageHeight="842" columnWidth="518" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" isIgnorePagination="true" uuid="11534e1c-358a-479d-bf93-b6f8c442b8f6">
    <property name="ireport.zoom" value="2.479338842975207"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="131"/>
    <property name="com.jaspersoft.studio.unit." value="cm"/>
    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="cm"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="cm"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="cm"/>
    <parameter name="LOGO_EMITENTE" class="java.lang.Object" isForPrompting="false"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="tit.identificacao" class="java.lang.String"/>
    <field name="tit.valor" class="java.lang.Double"/>
    <field name="tit.valor_ext" class="java.lang.String"/>
    <field name="pag.nome" class="java.lang.String"/>
    <field name="tit.dtPag" class="java.lang.String"/>
    <field name="emit.fant" class="java.lang.String"/>
    <field name="emit.xNome" class="java.lang.String"/>
    <field name="emit.xLgr" class="java.lang.String"/>
    <field name="emit.nro" class="java.lang.String"/>
    <field name="emit.xCpl" class="java.lang.String"/>
    <field name="emit.xBairro" class="java.lang.String"/>
    <field name="emit.cep" class="java.lang.String"/>
    <field name="emit.xMun" class="java.lang.String"/>
    <field name="emit.uf" class="java.lang.String"/>
    <field name="emit.fone" class="java.lang.String"/>
    <field name="emit.nrDocumento" class="java.lang.String"/>
    <field name="emit.ie" class="java.lang.String"/>
    <field name="emit.im" class="java.lang.String"/>
    <field name="tit.dtPagExtenso" class="java.lang.String"/>
    <field name="rec.nome" class="java.lang.String"/>
    <detail>
        <band height="180">
            <property name="com.jaspersoft.studio.layout"/>
            <frame>
                <reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="518" height="180" uuid="c0e55f85-87e9-440d-ae9b-b3c4567027e5">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                </reportElement>
                <box leftPadding="0" bottomPadding="0" rightPadding="0">
                    <pen lineWidth="0.0"/>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="0.5"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <staticText>
                    <reportElement x="121" y="9" width="270" height="20" uuid="1e5ac468-8b43-444b-9b66-fb0e81427f12">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    </reportElement>
                    <textElement textAlignment="Center" verticalAlignment="Top">
                        <font fontName="Monospaced" size="14" isBold="true"/>
                    </textElement>
                    <text><![CDATA[RECIBO]]></text>
                </staticText>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement positionType="Float" x="80" y="32" width="435" height="20" uuid="dc2e375a-32f1-4ca7-8094-abcd3198af0e"/>
                    <textElement textAlignment="Left" verticalAlignment="Top">
                        <font fontName="Monospaced" size="8" isBold="true" isUnderline="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{pag.nome}]]></textFieldExpression>
                </textField>
                <textField pattern="¤ #,##0.00;¤ -#,##0.00" isBlankWhenNull="true">
                    <reportElement positionType="Float" x="396" y="8" width="119" height="20" uuid="90210ce2-92ef-418d-bde0-8e9f5b675576"/>
                    <textElement textAlignment="Right" verticalAlignment="Top">
                        <font fontName="Monospaced" size="12" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{tit.valor}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" pattern="¤#,##0.00;¤-#,##0.00" isBlankWhenNull="true">
                    <reportElement positionType="Float" x="60" y="83" width="454" height="20" uuid="35a3c249-1a76-43ce-a290-eb754bee83af">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    </reportElement>
                    <textElement textAlignment="Left" verticalAlignment="Top">
                        <font fontName="Monospaced" size="8" isBold="true" isUnderline="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{tit.identificacao}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement positionType="Float" x="459" y="172" width="52" height="8" uuid="7a716ed8-4f4e-44d4-a699-275510648c8a"/>
                    <textElement textAlignment="Right" verticalAlignment="Middle">
                        <font fontName="Monospaced" size="5" isItalic="true"/>
                    </textElement>
                    <text><![CDATA[www.sentus.com.br]]></text>
                </staticText>
            </frame>
            <staticText>
                <reportElement x="2" y="32" width="78" height="12" uuid="19cd0546-23ff-4e55-b549-822b7a737b09"/>
                <textElement textAlignment="Left" verticalAlignment="Top">
                    <font fontName="Monospaced" size="8"/>
                </textElement>
                <text><![CDATA[Recebi(emos) de]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="2" y="52" width="58" height="12" uuid="88baf49a-023a-42ce-821e-7ef6bcd17b95"/>
                <textElement textAlignment="Left" verticalAlignment="Top">
                    <font fontName="Monospaced" size="8"/>
                </textElement>
                <text><![CDATA[a quantia de]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" pattern="¤#,##0.00;¤-#,##0.00" isBlankWhenNull="true">
                <reportElement positionType="Float" x="60" y="52" width="455" height="24" uuid="ea680987-de0f-4766-89fc-f1fce0b2f47b">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Top">
                    <font fontName="Monospaced" size="8" isBold="true" isUnderline="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{tit.valor_ext}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement positionType="Float" x="2" y="83" width="58" height="12" uuid="753a6211-5cf0-4bc8-a703-14a204e80e60">
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Top">
                    <font fontName="Monospaced" size="8"/>
                </textElement>
                <text><![CDATA[referente à]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="2" y="107" width="204" height="12" uuid="854cc28e-80fe-4fd2-9d55-0c5c9b850075"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="Monospaced" size="8"/>
                </textElement>
                <text><![CDATA[e para clareza firmo(amos) o presente.]]></text>
            </staticText>
            <textField isBlankWhenNull="true">
                <reportElement positionType="Float" x="153" y="130" width="220" height="12" uuid="c8231b66-f3f2-42b8-bcc0-7f6c29acfb58"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Monospaced" size="8" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{emit.xMun} + ", " + $F{tit.dtPagExtenso}]]></textFieldExpression>
                <patternExpression><![CDATA[$F{emit.xMun}]]></patternExpression>
            </textField>
            <line>
                <reportElement positionType="FixRelativeToBottom" x="193" y="158" width="149" height="1" uuid="4d95856f-f0ec-427d-bfc6-bc012da4f236"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement positionType="Float" x="163" y="170" width="204" height="10" uuid="a839d66e-220b-48e5-a15b-7021aac21b25"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Monospaced" size="7" isBold="false"/>
                </textElement>
                <text><![CDATA[Assinatura]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement positionType="Float" x="163" y="160" width="204" height="10" uuid="3287959a-43aa-472d-8589-c1e777b8a146"/>
                <textElement textAlignment="Center" verticalAlignment="Top">
                    <font fontName="Monospaced" size="7" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{rec.nome}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

谢谢

1 个答案:

答案 0 :(得分:0)

我解决了创建一个A4尺寸正确的新报告的问题,在其中,我把我在问题中提到的旧报告invoice.jrxml。

效果很好。

invoice_A4.jrxml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="recibo_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty" uuid="97db2eb7-eacb-4a72-af21-544bfd5ffe59">
    <property name="com.jaspersoft.studio.unit." value="cm"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="cm"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="cm"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="cm"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="cm"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="cm"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="recibos" class="java.lang.Object"/>
    <detail>
        <band height="802" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
            <frame>
                <reportElement key="" x="0" y="0" width="555" height="802" uuid="7896b407-46da-4b1a-a3c7-835e45d14bc5">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                </reportElement>
                <box>
                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <subreport>
                    <reportElement x="0" y="0" width="555" height="802" uuid="ca317fd4-37db-4802-be56-943b67fd4189"/>
                    <dataSourceExpression><![CDATA[$F{recibos}]]></dataSourceExpression>
                    <subreportExpression><![CDATA["reports/recibo.jasper"]]></subreportExpression>
                </subreport>
            </frame>
        </band>
    </detail>
</jasperReport>