How to get the last cell of an inner table stretched to fill the whole cell it is contained in (in P

apleuss
apleuss Member
edited February 11, 2022 in Analytics #1
<p>I have a table that contains multiple inner tables (or grids) side by side in the same row of an outer table. I would like to have the last cell of each of the inner tables to be stretched to the bottom of the outer cell, so that all inner tables have the same height (i.e., the height of the longest inner table, see the sketch in the figure).</p>
<p> </p>
<p>In Excel and HTML/Excel this is done automatically but I cannot achieve this in PDF. Is there any way to get this done in PDF? I’d be happy about any hint, could also be some workaround or scripting.</p>

Comments

  • <p>What version of BIRT are you using?</p>
    <p>Is your report setup as fixed layout of auto layout?</p>
    <p> </p>
    <p>It may be possible to implement some scripting that will read the outer table row height and then the inner tables row height and adjust the last rows height based on the outerRow - innerRows.</p>
    Warning No formatter is installed for the format ipb
  • <p>I’m using the report designer version 4.4.1. The report layout is fixed.</p>
    <p> </p>
    <p>Can you tell me how to access the calculated height of a row (instance)? I tried "this.getHeight()" in an onRender() event but it just returns null.</p>
  • <p>You can use this.height to get the height of a row. However, this will only return a value in onRender if you have explicitly set a height on row.</p>
    <p> </p>
    <p>Digging deeper into the issue, there are a few options available.</p>
    <p> </p>
    <p>1. Modify the PDF emitter.</p>
    <p style="margin-left:40px;">- The version of iText utilized by the PDF emitter does not include the method setExtendedLastRow. However, newer versions of iText do include this method. </p>
    <p style="margin-left:40px;">- You could download the source for the PDF emitter (<a data-ipb='nomediaparse' href='https://github.com/eclipse/birt/tree/master/engine/org.eclipse.birt.report.engine.emitter.pdf'>https://github.com/eclipse/birt/tree/master/engine/org.eclipse.birt.report.engine.emitter.pdf</a>) and modify it to use a new version of iText with the setExtendedLastRow method. </p>
    <p style="margin-left:40px;"> </p>
    <p>2. In the case of grids inside of grids, you can set the grids to have fixed dimensions for their rows height. With fixed dimensions, you can manually configure the last row to be extended.</p>
    <p> </p>
    <p>3. For tables inside of grids this gets a little bit trickier and solutions will depend a bit more on your layout/configuration. You will still need to set fixed dimensions for the outer grid row as well as the detail row of the table. Then you could perform a calculation before onRender of the table to determine the number of rows that will be in the table. With the number of rows, you can calculate how much of the outer grid row they will take up based on the fixed detail row height multiplied by the number of rows and then adjust the height of the last row onRender accordingly. </p>
    Warning No formatter is installed for the format ipb
  • <p>Many thanks for your reply. Options 2 and 3 seem not to fit to my specific layout as I don’t know the heights of rows because most cells can contain text of any length. Option 1 will work but seems to be a bit tricky. Looking at the PDF emitter I got the impression that the used version of iText actually does include the method setExtendedLastRow (in class PdfPTable) but the PDF emitter seems not to make use of this class (or a superclass). So it seems that rather large changes on the PDF emitter will be required. Is that what you thought or do you see any easier way?</p>