Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support

All forums · Statistics · Search ·

Two Pilots forum / For software developers / text out box and number of lines
Author Message
colin wiseman
# Posted: 7 Jun 2006 14:14

I am creating reports and need each alternative description to have a grey background. Also as each description will be over more than 1 line i need to work out how many lines are displayed.

What i have tried is to calculate the text width, and the box width, and then calculated the lines from this...but it doesn't take into account white space at the end of the line, due to some words not fitting on the line, thus going to another line.

My Code:

Dim textwidth As Double
Dim nLines As Integer
Dim boxwidth As Integer

If ssi.DetailedDesc <> "" Then
textwidth = PDF.PDFPAGE_GetTextWidth(ssi.DetailedDesc)
textwidth = PDF.PDFPAGE_GetTextWidth(ssi.NominalDesc)
End If

'how many lines will this take
'85 margin to the left
'PDF.PDFPAGE_Width - 95 margin to the right
'gives the box width

boxwidth = (PDF.PDFPAGE_Width - 95) - 85

nLines = textwidth / boxwidth

But nLines, from my calculations can be 1 line out or spot on, so i can't just add 1 to nLines to make it work.

I need to calculate nLines to be able to the create the shaded box behind the text, and to make sure the textoutbox is the correct height, and for when the next description is in the correct place on the page.

Any suggestions on what i should do, or even a better way to do this?



# Posted: 9 Jun 2006 15:48

Hello Colin,

I am sorry for the delay with the answer. We have some problems with functioning of our forum.
I have forwarded your question to our developer and will reply to you soon.
Sorry again.

Olga Panchenko
Two Pilots

# Posted: 9 Jun 2006 18:58

Dear Colin,

I think you can use DrawText GDI function - it should return very close value to library output. To use it, you need to create te,porary DC, and specify parameters. It should return height of the text in logical units.

Thank you very much !

Best regards,
Two Pilots

Please note that we change our email address from time to time
to reduce spam. So if it stops working, just visit our feedback form:



Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.014


Page top