简体   繁体   English

Jaspersoft页面打印方向错误

[英]Jaspersoft page wrong orientation on print

I have a jasper report to print a little invoice in portrait orientation, but whem I send to print, it's in landscape and takes up a lot of space at the A4 page. 我有一个碧玉报告,以纵向打印一些发票,但是我发送打印时,它是横向的,并且在A4页面上占用了大量空间。 How can I do to fix the orientation to maintain as portrait? 如何固定方向以保持纵向?

I've tryed to put the code of my jrxml here, but i'ts big, so, on the link you can download the .jxrml or by pastebin. 我尝试将jrxml的代码放在这里,但不大,因此,在链接上,您可以下载.jxrml或通过pastebin下载。

invoice.jrxml invoice.jrxml

Invoice by pastebin 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>

Thank you 谢谢

I solved the problem creating a new report with the correct A4 size, and inside of it, I put my old report invoice.jrxml that I mentioned in the question. 我解决了创建具有正确A4大小的新报告的问题,并在其中放入了我在问题中提到的旧报告invoice.jrxml。

It worked perfectly. 效果很好。

invoice_A4.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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM