Jump to content

Recommended Posts

Posted

Report output speaks of the issue, Any help or advice here is highly appreciated. Code inculuded below.

The second band resizes appropriately when text is more - so height is max of text and image frame. But when text is little as in first band scenario, need the band to size to max height of text and image frame. 

Capture(24).PNG.c7f3d8ef74a484fd9cd59bed44fa1602.PNG

 

<?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="Test" pageWidth="600" pageHeight="800" whenNoDataType="AllSectionsNoDetail" columnWidth="520" leftMargin="40" rightMargin="40" topMargin="0" bottomMargin="0"><queryString>  <![CDATA[sELECT 'Test Report' as Report FROM DUAL]]></queryString><detail>  <band height="20">   <line>    <reportElement x="0" y="19" width="540" height="1"/>   </line>  </band>  <band height="100">   <textField isStretchWithOverflow="true">    <reportElement x="0" y="0" width="150" height="0" isRemoveLineWhenBlank="true"/>    <box>     <pen lineWidth="0.1" lineColor="#00FF00"/>    </box>    <textFieldExpression><![CDATA["This is some long text. This is some long text. "+      "This is some long text. This is some long text. "]]></textFieldExpression>   </textField>   <frame>    <reportElement positionType="Float" x="0" y="0" width="150" height="100" isRemoveLineWhenBlank="true">     <printWhenExpression><![CDATA[false]]></printWhenExpression>    </reportElement>   </frame>   <frame>    <reportElement x="200" y="0" width="300" height="100" isRemoveLineWhenBlank="true"/>    <box>     <pen lineWidth="0.1" lineColor="#0000FF"/>    </box>    <!-- One of the below frames is always printed and the other not -->    <frame>     <reportElement x="0" y="0" width="300" height="50" isRemoveLineWhenBlank="true">      <printWhenExpression><![CDATA[false]]></printWhenExpression>     </reportElement>     <staticText>      <reportElement x="50" y="15" width="200" height="30"/>      <text><![CDATA[This frame height has to be fixed, to fit some fixed size images in here.]]></text>     </staticText>    </frame>    <frame>     <reportElement x="0" y="50" width="300" height="50" isRemoveLineWhenBlank="true">      <printWhenExpression><![CDATA[true]]></printWhenExpression>     </reportElement>     <staticText>      <reportElement x="50" y="15" width="200" height="30"/>      <text><![CDATA[This frame height has to be fixed, to fit some fixed size images in here.]]></text>     </staticText>    </frame>   </frame>  </band>  <band height="20">   <line>    <reportElement x="0" y="0" width="540" height="1"/>   </line>   <line>    <reportElement x="0" y="19" width="540" height="1"/>   </line>  </band>  <band height="100">   <textField isStretchWithOverflow="true">    <reportElement x="0" y="0" width="150" height="0" isRemoveLineWhenBlank="true"/>    <box>     <pen lineWidth="0.1" lineColor="#00FF00"/>    </box>    <textFieldExpression><![CDATA["This is some long text. This is some long text. "+      "This is some long text. This is some long text. "+      "This is some long text. This is some long text. "]]></textFieldExpression>   </textField>   <frame>    <reportElement positionType="Float" x="0" y="0" width="150" height="100" isRemoveLineWhenBlank="true">     <printWhenExpression><![CDATA[false]]></printWhenExpression>    </reportElement>   </frame>   <frame>    <reportElement x="200" y="0" width="300" height="100" isRemoveLineWhenBlank="true"/>    <box>     <pen lineWidth="0.1" lineColor="#0000FF"/>    </box>    <!-- One of the below frames is always printed and the other not -->    <frame>     <reportElement x="0" y="0" width="300" height="50" isRemoveLineWhenBlank="true">      <printWhenExpression><![CDATA[false]]></printWhenExpression>     </reportElement>     <staticText>      <reportElement x="50" y="15" width="200" height="30"/>      <text><![CDATA[This frame height has to be fixed, to fit some fixed size images in here.]]></text>     </staticText>    </frame>    <frame>     <reportElement x="0" y="50" width="300" height="50" isRemoveLineWhenBlank="true">      <printWhenExpression><![CDATA[true]]></printWhenExpression>     </reportElement>     <staticText>      <reportElement x="50" y="15" width="200" height="30"/>      <text><![CDATA[This frame height has to be fixed, to fit some fixed size images in here.]]></text>     </staticText>    </frame>   </frame>  </band>  <band height="1">   <line>    <reportElement x="0" y="0" width="540" height="1"/>   </line>  </band></detail></jasperReport>[/code]

 

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Posted

The problem you are experiencing is that the Detail band is growing by the same amount as the textfield. if you allocate the text field the same amount of space as the frame then the band will expand by the correct amount:

 

 

<?xml version="1.0" encoding="UTF-8"?> sELECT 'Test Report' as Report FROM DUAL "This is some long text. This is some long text. "+ "This is some long text. This is some long text. "+ "This is some long text. This is some long text. " This frame height has to be fixed, to fit some fixed size images in here. The above line has to start right after end of the text or end of the image frame.
Posted
But that keeps the height of the band fixed (the text field would take entire height even when it has few chars). I had it that way, so band would shrink according to the content
Posted
After some edit to the code, when there is large text(2nd band) the band height is keeping to the max height of either frames, which is expected. But if text is small(1st band) - I still need the band height ta be max height - so it should just fit upto the image frame on the right, with no extra space below.
Posted

Hi,

I think here we have two columns that need to collapse independent of one another.

The only solution that I can see right now is to isolate the content of those two columns that run side by side in two separate subreports.

This is because only subreports allow you to have content bigger than the subreport element height itself.

We are working on a modification of layout code to allow frame elements to be smaller than their declared content height.

The frame would stretch to display all its content, even if the initial frame height declared at design time is smaller.

It would allow you to isolate the two columns in two separate frames, side by side, instead of having to use subreports.

Thanks,

Teodor

 

 

Posted

As you only have 2 variations of the output you could adapt what you already have.

 

Create 2 detail bands, one with the smaller frame height and one with the larger. Set the left field to be the same height as the frame in each case so that the expansion works correctly. Then use the print when expression on the band instead of the frame

Posted

<?xml version="1.0" encoding="UTF-8"?>

sELECT 'Test Report' as Report FROM DUAL

"This is some long text. This is some long text. "+</p><p> "This is "

This frame height has to be fixed, to fit some fixed size images in here. 2

"This is some long text. This is some long text. "+</p><p> "This is some long text. This is some long text. "+</p><p> "This is some long text. This is some long text. "+</p><p> "This is some long text. This is some long text. "+</p><p> "This is some long text. This is some long text. "+</p><p> "This is some long text. This is some long text. "+</p><p>&nbsp;</p><p> "This is some long text. This is some long text. "

This frame height has to be fixed, to fit some fixed size images in here. 3

 

Posted
Allen, That works if that is the only data i am dealing (if only those mentioned two variations). But it has more to the problem(the image frame is kind of a vertical stack of images of which i will show a few and hide rest) and i tried to show the problem extracting a small piece of it. Thanks for the advice.
Posted
Teodor - I tried doing what you said, extracting the right frame into a sub report and setting the height of the sub-report as '0' in the main-report. That worked like a charm and is exactly what i am looking at. Thanks so much.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...