Einhugur pdf-plugin, textrect text-wrapping

Hi everyone,
i am using Einhugur pdf-plugin. Now i’m wondering if it’s not possible to wrap a longer text inside a textrect.
I can measure the height of the rect with TextRectMeasure, this works fine for the height of the textarea, but the text won’t wrap.
I can always only see the first line of the text fitting the rect.

Has anybody experiences with the Einhugur PDFPlugin.

I took the Basic PDF test example project and modified this section here to test:

if myFont <> nil then
myPage.BeginText()
myPage.SetFont(myFont,40)
myPage.TextRect(“Einhugur PDF export, some very long long long text”, 10,800, myPage.Width - 10,600, Page.TextAlignmentEnum.CENTER,outLength)

myPage.EndText()
end if

Result is this:

Or am I misunderstanding something in your question ?

Thanks

Björn

Hi Björn,
yes you absolutely understood it right. Thank you for your answer.

I tried it in your Basic pdf-test example and it works. Later i will test it in my code…

Hi Björn,
now i’ve tested it in my code. The problem was, that i am using it with a variable height of the TextRec and mine was not high enough for displaying the whole text.

A “condensed” option would be nice. :slight_smile:

It’s me once again…
I thought i could set the height of the TextRec by using the TextRectMeasure method, but the height ist not high enough for the text.
Setting the height “by hand” leads to the correct display of all text the lines.

This is a part of my code

...
s="Das ist ein Testbemerkungstext der etwas lnger ist und auch in voller Lnge dargestellt werden muss."
w=pdfSet.pg.Width-pdfSet.lRand
pdfSet.pg.SetFont(pdfSet.pdfFont_i,10)
Dim hoehe As Single
Dim zAnzahl As Integer
hoehe=pdfSet.pg.TextRectMeasure(s,w,zAnzahl)
pdfSet.pg.TextRect(s,sp,ze,w,hoehe, Page.TextAlignmentEnum.Left,outLength)
ze=ze+hoehe
...

and the result

As you can, the reserved space for the text is correct (variable ‘ze’). The following lines start at the correct height. But the height of the TextRect is too small. Changing the height (variable ‘hohe’) " by hand" for example to 400, the text appears.

...
s="Das ist ein Testbemerkungstext der etwas lnger ist und auch in voller Lnge dargestellt werden muss."
w=pdfSet.pg.Width-pdfSet.lRand
pdfSet.pg.SetFont(pdfSet.pdfFont_i,10)
Dim hoehe As Single
Dim zAnzahl As Integer
hoehe=pdfSet.pg.TextRectMeasure(s,w,zAnzahl)
pdfSet.pg.TextRect(s,sp,ze,w,[b]600[/b], Page.TextAlignmentEnum.Left,outLength)
ze=ze+hoehe
...

and the result with the height of 600

But the height must be variable, defined by the height of the text. It seems like the value from TextRectMeasuere is fine for the position of the next line, but not for the height oft the TextRect itself.

What am i doing wrong??

There is chance there is some inaccuracy somewhere in Haru or in the plugin I suppose.

Do you know just how much it is off ? Like if you do TextRectMeasuere + 1, TextRectMeasuere + 2 , etc at what point do you see it correct ?

Björn

This seems to be a really big difference between the result of the TextRectMeasure and the needed hight for the example text shown above.
When i set a breakpoint i can see that “hoehe” is 12, but i need a height around 460(!) to show the text.

So it looks like that the result of the TextRectMeasure height is something completely different.

OK…the first thing i was wrong with is that i thought, the 4. parameter of the TextRect is the height, but it’s the bottom coordinate.
So i need to add the “hoehe”-value to the top-value (“ze”).

But this is still not enough to show the whole text.

In my example top is at 429 and “hoehe”, the value from TextRectMeasure, is 12.
So 429+12 is less than the needed 460 as the bottom value. (btw. i am using TransformCoordinates=True)

You will need to provide better example, where we can reproduce something, a block of code with how you draw it and example text like I have done bellow.

(and your code above has bug in it since it never makes sense to assign height to Bottom parameter as you hinted your self in your last post).

This is just code from the Modified Einhugur example project (which does measure correctly and display all the text):

if myFont <> nil then
myPage.BeginText()
myPage.SetFont(myFont,40)

Dim lineNum As Integer
Dim height As Single = myPage.TextRectMeasure(“Einhugur PDF export, some long long long long text 123456789”, myPage.Width - 10,lineNum)

MsgBox Str(lineNum)
MsgBox Str(x)

myPage.TextRect(“Einhugur PDF export, some long long long long text 123456789”, 10,800, myPage.Width - 10, 800 - height, Page.TextAlignmentEnum.CENTER,outLength)

myPage.EndText()
end if

Thanks

Björn

When i’m testing it in your example code “Basic pdf test” it works, but not in my code. I don’t know why, there must be something wrong in my code, but it’s too long and complicated to post it here.

Now i don’t want to spend more time on this case, i already did a lot. So i helped myself by adding the amount of two times linenumber to the height. That’s not the best way but it comes near to a result which i’m fine with.

Thanks Björn for your help, maybe later i will come back to find a better solution.

Maybe it‘s time to restructure it then :wink:

:wink: yes maybe you are right