antprochazka Posted February 11, 2022 Share Posted February 11, 2022 Hello all. I am struggling with overflowing document. In my usecase I have a report with textfield showing input text parameter that can be generally multiple lines. What I want:1) The document to be fix size of A4 unless the content overflows.2) When the input parameter generates more lines than can fit into one A4 page then stretch the page to become taller.For the sake of simplicity I have set fix content into my textfield (not using the input parameter). To simulate multiline input parameter value currently it consists of "a" followed by 18 newlines (<br>) and letter "b" at the end.<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="315a7b0d-5c86-4525-85d8-b2ceba19bbf4"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"/> </columnHeader> <detail> <band height="486"> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="10" height="12" uuid="8270fbc3-5b36-4f0d-976d-9ad192e8ef68"/> <textElement markup="html"> <font size="12"/> </textElement> <textFieldExpression><![CDATA["a<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>b"]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code]Current (undesired) output:Desired output:Acceptable solutions for me:1) Shrink the page height always to max(real content height, A4 height). I absolutely do not want the page to stretch by empty space.2) Set isIgnorePagination to "false" and generate 2nd page with overflowing content when there is not enough space on the first page. If I try it now it generates 2nd EMPTY A4 page which is definitely not what I want. Still this is worse solution because I am generating electronically signable documents where it is more suitable to have one page stretched (by CONTENT, no empty space) than have two pages. Thank you very much for your answers guys. I have been looking for solving my problem for a long time but I still have not found sufficient answer. Link to comment Share on other sites More sharing options...
bigalex Posted February 11, 2022 Share Posted February 11, 2022 Keep the Detail band height within height of the contents. Double click on the Detail band will shrink the band. Link to comment Share on other sites More sharing options...
antprochazka Posted February 11, 2022 Author Share Posted February 11, 2022 This is the option I am currently using. The problem is that when the variable holds only a few lines of text the result pdf is too short and looks like this:which is all right for printing but on the screen it does not look like A4 which is wrong. Link to comment Share on other sites More sharing options...
bigalex Posted February 11, 2022 Share Posted February 11, 2022 You may expand other bands like header or footer to accommodate the visual format, but expanding the Detail band only adds space between rows. Link to comment Share on other sites More sharing options...
antprochazka Posted February 11, 2022 Author Share Posted February 11, 2022 Can you provide an edited code please? I tried to adequately expand columnFooter or pageFooter to accomodate the visual format for single-line textfield but the result (with 18 <br>s) was not A4 format but undesired long page. It ended up the same as with the code I provided. Link to comment Share on other sites More sharing options...
bigalex Posted February 11, 2022 Share Posted February 11, 2022 To keep the page format you may need to uncheck "Ignore Pagination".Values true The report will be generated on one long page. The specified page height will still be used for report design. false The report will be paginated according to the pageHeight attribute. Link to comment Share on other sites More sharing options...
antprochazka Posted February 11, 2022 Author Share Posted February 11, 2022 Set isIgnorePagination to "false" is not the optimal solution for me because I am generating electronically signable documents where it is more suitable to have one page stretched (by CONTENT, no empty space) than having two pages. Link to comment Share on other sites More sharing options...
antprochazka Posted February 15, 2022 Author Share Posted February 15, 2022 Does anybody know whether it is able to configure the report to not allow generating next page when content overflows only with empty space? This case can easily be simulated by taking my code and setting isIgnorePagination="false". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now