Calculating PDF Table Height when cell text overruns. iTextSharp
I am writing a PDF invoice, various tables are being created and
specifically positioned depending on the total content of the invoice.
I have a part exchange window and a "Connect" window, which I am having
issues avoid a collision.
The "connect" box is generated first as this is part of a separate
template script. This template script returns a series of co-ordinates of
template content so I can position other content around them.
To calculate the top Y position of the Part Exchange window I am returning
the top Y position of the Connect box, then calculating the height of the
intended part exchange window and simply adding them.
This works if none of the text in any individual cell overruns and wraps,
thus making the cell larger. It would appear that the height calculation
which I am using doesn't cater for this.
I am using code inspired by the answer given here:
Itextsharp: Adjust 2 elements on exactly one page
to calculate the table height, and have also tried a variation which loops
the table rows and calculates individual row height, both have the same
outcome.
I could try this route:
How To Adjust Font Size To Fill A Fixed Height Table Cell In iTextSharp
And resize text, so wrapping does not occur, but it could create
unreadable lines.
Can anyone help me to identify a means of calculating table heights
Including catering for wrapping text?
No comments:
Post a Comment