There are more than 10 textboxes on my PDF for a paragraph like content to show on the PDF to look like lines of running text. Initially I set the line length to some 100 characters for each line in my code like if the text to show is 400 characters I was displaying in 4 lines. My issue was it is giving space on right side of the PDF textbox when text is in small letters. Then I increased number of characters to show from 100 to 120. Then the issue was with the uppercase text it was concatenated as the textbox width on the PDF form is limited and cannot increase.
The solution is to calculate the best fit of text length at runtime instead hard coding to 100 or 120. When the text is in uppercase the length can be calculated to 90 or so. And when the text is in lower case the length can be 120 characters.
Case Study: We are using iTextSharp (an open source project from SourceForge), there is a mothod GetEffectiveStringWidth() in the PdfContentByte class. This function will calculate how many points will the text take on the PDF at runtime based on the supplied font.