Jasper reports Jasper中的流程布局

Jasper reports Jasper中的流程布局,jasper-reports,Jasper Reports,我正在尝试用Jasper创建一个富文本模板。结果应该是一个包含许多段落、缩进列表、一些子列表和标题的文档。整个文档将分散在几页上,由于文档的许多部分是由数据生成的,因此分页符不是固定的 我的第一个问题是,我的用例实际上是应该用jasper做的事情,还是应该用降价甚至乳胶做一些事情?所有模板和示例我都能找到多个带有表格和图表的页面,但没有多个页面的文档,但是Jasper的创建时间很快,而且还能创建word文件(除了PDF),这是一个很大的优势 如果我使用Jasper的目的是正确的,那么我应该为每个

我正在尝试用Jasper创建一个富文本模板。结果应该是一个包含许多段落、缩进列表、一些子列表和标题的文档。整个文档将分散在几页上,由于文档的许多部分是由数据生成的,因此分页符不是固定的

我的第一个问题是,我的用例实际上是应该用jasper做的事情,还是应该用降价甚至乳胶做一些事情?所有模板和示例我都能找到多个带有表格和图表的页面,但没有多个页面的文档,但是Jasper的创建时间很快,而且还能创建word文件(除了PDF),这是一个很大的优势

如果我使用Jasper的目的是正确的,那么我应该为每个段落使用一个新的文本字段,还是应该在一个文本字段中编写整个文档?我不喜欢把所有的东西都写进一个,因为Jasper不允许把代码的格式都设置得很好,而且我在新页面上也遇到了问题

或者我应该为每个段落创建一个新的文本字段?这是我在下面尝试过的,但我在布局上遇到了困难,段落相互重叠,有些部分在每页上重复,而有些部分从未出现过。我的整个文档乱七八糟,我不明白为什么,改变参数确实会改变,但我不明白发生了什么

因此,如果我应该为每个段落创建一个新的文本字段,我应该如何设置布局,使它们彼此紧随其后。它们将生成,因此长度是不固定的,我希望段落均匀分布,它们之间没有不同的空间

要显示我遇到的问题,请参见下面的
jrxml
文件,该文件编译为布局混乱的文档。我知道我可以将所有文本字段设置为浮动,并将它们设置为精确位置,但这不是我的想法,因为我将生成字段,所以我要寻找的是某种flowlayout


我宁愿使用更适合您的用例的JasperReports,而不是更多用于生成报告、统计数据和其他表格和网格结构文档的JasperReports

例如,我们使用ApacheFop生成包含大量段落、地址、个人数据、页码、徽标等的合同文档

ApacheFop使用XML作为模板和数据源。这意味着您可以创建XSL-FO模板(手动或使用任何FO编辑器),然后创建或以编程方式生成包含所有段落、列表、标题和其他动态内容的结构化XML,并使用Apache FOP执行XSL转换,您可以在其中定义各种输出格式,如PDF、PS、RTF、PNG等

Internet上有很多XSL-FO教程,您可以在上面查看示例

更新:我忘了提到哪些定义了用于编写书籍、手册、学士学位论文等的语义语言。内容再次存储在XML中,其结构由DocBook schema定义,然后您可以使用其中一个预定义模板将其转换为PDF。转换为PDF也使用ApacheFOP,但这里只创建包含内容的XML(XSL模板已经完成)。

考虑使用生成PDF。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<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="Test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="daade75b-7134-4af7-b206-2451426de5a9">
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="72" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
            <textField>
                <reportElement x="0" y="0" width="555" height="36" uuid="a253abbc-8696-4ab4-8d58-bc33a059982c"/>
                <textElement textAlignment="Center">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Hello"]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="36" width="555" height="36" uuid="5494bb7d-0f10-479c-aad7-61ba1a10868c"/>
                <textElement textAlignment="Center" markup="html">
                    <font fontName="Times New Roman" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Consulting agreement]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="19" splitType="Stretch"/>
    </pageHeader>
    <detail>
        <band height="367" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
            <textField isStretchWithOverflow="true">
                <reportElement isPrintRepeatedValues="false" x="0" y="0" width="555" height="55" isPrintWhenDetailOverflows="true" uuid="892c2a2f-d320-4dc2-b31a-c15bccb6af43"/>
                <textElement>
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tincidunt rhoncus vestibulum. In vitae neque lectus. Donec nec elementum sem. Donec ullamcorper leo in felis mattis, sit amet fringilla sapien semper. In consectetur neque porttitor semper vulputate. Nunc et tellus purus. Nam et urna nec urna fringilla molestie. Duis eleifend rutrum porttitor."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="55" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="ba36dcb6-d88f-43ea-bfc1-16dfcb1d5837"/>
                <textElement>
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Phasellus euismod, sapien commodo iaculis lacinia, urna odio pretium quam, in scelerisque dolor nisi at purus. Proin at condimentum lectus. Phasellus vitae felis augue. Praesent vulputate ipsum nibh, in cursus metus vehicula quis. Vestibulum facilisis elit tristique, posuere sem vitae, rutrum dui. Sed varius eros nec euismod bibendum. Sed dapibus condimentum lectus, semper dignissim felis rhoncus sit amet. In viverra varius tincidunt. Aenean eu tincidunt nulla, eu sagittis ante. Duis ullamcorper eros ut tincidunt mattis. Quisque ac dolor imperdiet, volutpat lorem ut, luctus turpis."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="107" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="71df41c1-9607-40b7-8dd8-897882470e88"/>
                <textElement markup="html">
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph lineSpacing="Single" firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Donec eget ligula vitae tellus tincidunt ornare at nec lacus. Aliquam interdum lobortis hendrerit. Suspendisse tempus ipsum urna, vel convallis est luctus et. Duis fermentum ipsum mi, sed lobortis arcu fermentum in. Mauris sagittis nisl arcu, at fermentum justo tincidunt quis. Curabitur tristique nunc et nulla ornare, eget bibendum nisl efficitur. Quisque porta sem sed quam porttitor tristique eget in ex. Maecenas scelerisque felis eu est vulputate condimentum. Donec efficitur lobortis tristique. Praesent nulla augue, mollis non elementum sit amet, luctus in arcu. Etiam viverra orci sit amet ante mattis aliquet."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="159" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="71df41c1-9607-40b7-8dd8-897882470e88"/>
                <textElement markup="html">
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph lineSpacing="Single" firstLineIndent="0" leftIndent="30"/>
                </textElement>
                <textFieldExpression><![CDATA["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pretium malesuada dapibus. In hac habitasse platea dictumst. Curabitur suscipit metus vitae tellus laoreet semper. Fusce vehicula a libero sed venenatis. Vestibulum accumsan egestas nisl. Sed at enim vel mauris ornare auctor vel vitae nisl. Morbi sed lobortis arcu. Duis blandit aliquam auctor."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="211" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="7ab5d201-6c88-4932-bc84-941900d1dc39"/>
                <textElement markup="html">
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph lineSpacing="Single" firstLineIndent="0" leftIndent="40"/>
                </textElement>
                <textFieldExpression><![CDATA["Phasellus a nulla ornare, dapibus nunc in, scelerisque urna. Integer vestibulum neque at tellus cursus congue. Aliquam tempor mauris porta, egestas ante vitae, sollicitudin enim. Vivamus cursus convallis mauris non varius. Integer euismod eros cursus justo pharetra, nec fringilla ante tempor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In facilisis at augue ac tempor."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement isPrintRepeatedValues="false" x="0" y="263" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="3b3879c4-fd99-4e49-b8b2-7f15f09d1667"/>
                <textElement>
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Norse mythology is the body of myths of the North Germanic people stemming from Norse paganism and continuing after the Christianization of Scandinavia and into the Scandinavian folklore of the modern period. The northernmost extension of Germanic mythology, Norse mythology consists of tales of various deities, beings, and heroes derived from numerous sources from both before and after the pagan period, including medieval manuscripts, archaeological representations, and folk tradition."]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="315" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="c922c7c9-93d3-4cc3-b4df-8ab7f6f80090"/>
                <textElement>
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Most of the surviving mythology centres on the plights of the gods and their interaction with various other beings, such as humanity and the jötnar, beings who may be friends, lovers, foes or family members of the gods. The cosmos in Norse mythology consists of Nine Worlds that flank a central cosmological tree, Yggdrasil. Units of time and elements of the cosmology are personified as deities or beings. Various forms of a creation myth are recounted, where the world is created from the flesh of the primordial being Ymir, and the first two humans are Ask and Embla. These worlds are foretold to be reborn after the events of Ragnarök when an immense battle occurs between the gods and their enemies, and the world is enveloped in flames, only to be reborn anew. There the surviving gods will meet, and the land will be fertile and green, and two humans will repopulate the world."]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <pageFooter>
        <band height="367" splitType="Stretch">
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="315" width="555" height="52" isPrintWhenDetailOverflows="true" uuid="4e12811e-3a76-4e19-86d1-08e2a1239c23"/>
                <textElement>
                    <font fontName="Times New Roman" size="12"/>
                    <paragraph firstLineIndent="20"/>
                </textElement>
                <textFieldExpression><![CDATA["Numerous gods are mentioned in the source texts such as the hammer-wielding, humanity-protecting thunder-god Thor, who relentlessly fights his foes; the one-eyed, raven-flanked god Odin, who craftily pursues knowledge throughout the worlds and bestowed among humanity the runic alphabet; the beautiful, seiðr-working, feathered cloak-clad goddess Freyja who rides to battle to choose among the slain; the vengeful, skiing goddess Skaði, who prefers the wolf howls of the winter mountains to the seashore; the powerful god Njörðr, who may calm both sea and fire and grant wealth and land; the god Freyr, whose weather and farming associations bring peace and pleasure to humanity; the goddess Iðunn, who keeps apples that grant eternal youthfulness; the mysterious god Heimdallr, who is born of nine mothers, can hear grass grow, has gold teeth, and possesses a resounding horn; the jötunn Loki, who brings tragedy to the gods by engineering the death of the goddess Frigg's beautiful son Baldr; and numerous other deities."]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
</jasperReport>