Skip to main content

Expand Row Height to Match Content

· 3 min read
James A. Brannan

You can expand rows to easily match the height of your content. You can even use Lines and Rectangles to expand with a field's content. Here's how to do it.

DynamicPDF Designer is a powerful tool for graphically creating rich PDF reports. One feature of Designer is its ability to expand a field on a row in the report's Body section to fit the field's content width.

info

Set a RecordBox or FormattedRecordBox element's expandable property to true to resize the row to fit the field's content.

Automatically Expand a Row to Expandable

Let's illustrate expanding a row using the Create a PDF (dlex-layout) sample project.

  • Open SimpleReportWithCoverPage.dlex into Designer.

  • Scroll to the Body and note the ProductName field.

  • Open the JSON data and modify the first ProductName to a string value too large to fit in the field's width.

  • Run the report and notice the text is not fully displayed.

  • Select the ProductName field in Designer and change the expandable property to true.

  • Re-run the report and notice the full text is displayed.

Add a Line to Report

Now let's add a line to the report that repeats for each row of data.

  • Add a Line to the Body.

  • Select ProductName and notice the x and y position.

tip

It is much easier to modify dimensions through the Properties pane then to use your mouse to fine-tune positions and sizes of layout elements.

  • Move the line to match the the line's y value as y + width from the ProductName, the x1 position to 0, and the x2 position 512 (the report's width).

  • Run the report and notice the line repeats for each row and is placed in the proper location.

danger

If you do not position the line to be equal or below the field's value, then the line will not display correctly nor repeat.

Add a Rectangle to Report

You are not limited to using lines when formatting a report with expanding field content and repeating rows. You can also use a Rectangle element.

  • Delete the Line and add a Rectangle to the report's Body.

  • Resize the rectangle to match the row's top and width and resize the rectangle to match the report's width.

  • Run the report and the rectangle is repeated for each row and resizes it's height to accommodate the largest height of the elements in the row.