I am using iReport for building report. I had a requirement of displaying HTML content into report. I referred link( Export html content to pdf using JasperReports) and applied the necessary jars and able to get the report with HTML component.
We have rich text editor in our application. Its must be displayed in the report. The rich text editor will give us an HTML string, rendered in using the HTML component.
Issue: In report output when HTML content is bigger than the frame then it is shrinking and showing. It is not able to stretch when overflow. Note: Tried all the Scale Type options but none of them are leading to solution.
Output Snap Shot:
Output with more data:
Output with less data:
JRXML Code
<?xml version="1.0" encoding="UTF-8"?>
<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="report3" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a68bd555-1d68-49e7-be27-9b152830d349">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="6dda9e0f-4cb6-492b-bc53-ad64f8f3c572">
<parameter name="parameter1" class="java.lang.String"/>
</subDataset>
<parameter name="parameter1" class="java.lang.String"/>
<group name="asd">
<groupExpression><![CDATA[$V{PAGE_NUMBER}]]></groupExpression>
<groupHeader>
<band height="138">
<componentElement>
<reportElement key="table" style="table" stretchType="RelativeToTallestObject" x="0" y="0" width="555" height="136" uuid="8435c53e-4068-4ebb-9604-e95ce7e31fce"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1" uuid="6343fcbb-31b2-413a-804e-acea580c7dd2">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
</datasetRun>
<jr:column width="436" uuid="0adde13b-d941-4695-a55d-22918541d075">
<jr:columnHeader style="table_CH" height="35" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="436" height="35" uuid="eafaea0a-b010-4c6e-b21e-da32c1df3859"/>
<textFieldExpression><![CDATA["Column"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="101" rowSpan="1">
<componentElement>
<reportElement style="table" stretchType="RelativeToTallestObject" x="0" y="1" width="436" height="100" isPrintWhenDetailOverflows="true" uuid="2b4df7ba-fbef-44b9-838d-b3e585a7b2f1"/>
<hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="RetainShape" horizontalAlign="Left" verticalAlign="Middle">
<hc:htmlContentExpression><![CDATA["<p style='table;padding-left: 30px;'>Procedure<br /><span style='text-decoration: underline;'>NOTE:</span> For the basic Aircraft configuration, refer to Ref. INTRO A350-A-00-6X-XX-11ZZZ-018Z-D “Introductions”.</p>"]]></hc:htmlContentExpression>
</hc:html>
</componentElement>
</jr:detailCell>
</jr:column>
<jr:column width="35" uuid="2141b0e3-64ff-4133-8bd1-ec13e1191b2e">
<jr:columnHeader style="table_CH" height="35" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="35" height="35" uuid="4f152705-b7fa-4184-a3d5-1124c5fe4e07"/>
<textFieldExpression><![CDATA["Column1"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="101" rowSpan="1"/>
</jr:column>
<jr:column width="48" uuid="32e77e5d-73e9-4d4b-b501-57153d212800">
<jr:columnHeader style="table_CH" height="35" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="46" height="35" uuid="26d09584-674d-442e-81b8-cb8941b6fad7"/>
<textFieldExpression><![CDATA["Column2"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="101" rowSpan="1"/>
</jr:column>
<jr:column width="38" uuid="14778a16-6346-437c-ae9c-4e771080012d">
<jr:columnHeader style="table_CH" height="35" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="38" height="35" uuid="a811171f-614b-4db5-ba7f-e0cc9f570e7c"/>
<textFieldExpression><![CDATA["Column3"]]></textFieldExpression>
</textField>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="101" rowSpan="1"/>
</jr:column>
</jr:table>
</componentElement>
</band>
</groupHeader>
<groupFooter>
<band height="50"/>
</groupFooter>
</group>
</jasperReport>