Я пытаюсь создать шаблон с расширенным текстом с помощью Jasper. Результатом должен стать документ с множеством абзацев, списками с отступами, у некоторых есть подсписки и заголовки. Весь документ будет распространяться на несколько страниц, и поскольку многие части документа создаются на основе данных, разрывы страниц не являются фиксированными.
Мой первый вопрос: мой вариант использования - это что-то, что нужно делать с jasper, или мне лучше настроить что-то с помощью markdown или даже LateX? Все шаблоны и примеры, которые мне удалось найти, содержат более одного пейджера с таблицами и графиками, но нет документов на нескольких страницах, однако Jasper быстро создает время и также может создавать файлы слов (в дополнение к PDF-файлам), что большой плюс.
Если я использую Jasper для правильной цели, то должен ли я использовать новое текстовое поле для каждого абзаца или я должен написать весь документ в одном текстовом поле? Мне не нравится идея записать все в одно, поскольку Jasper не позволяет хорошо отформатировать код, а также у меня были проблемы с новыми страницами.
Или я должен создать новое текстовое поле для каждого абзаца? это то, что я попробовал ниже, но я борюсь с макетом, абзацы встречаются друг с другом, и некоторые части повторяются на каждой странице, а некоторые никогда не появляются. Весь мой документ испорчен, и я не могу понять, почему изменение параметров действительно вносит изменения, но я не могу понять, что происходит
Так что, если мне нужно создать новое текстовое поле для каждого абзаца, как мне настроить макет так, чтобы они появлялись после друг друга. Они будут сгенерированы, следовательно, длина не фиксирована, и я хочу, чтобы абзацы были равномерно распределены, чтобы между ними не было разрыва.
Чтобы показать мои проблемы, см. Следующий файл jrxml
, который компилируется в документ с испорченным макетом. Я знаю, что я мог бы просто установить все текстовые поля как плавающие и установить их в точное положение, но это не идея, так как я буду генерировать поля, так что я ищу что-то вроде разметки.
<?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>