TextArea to pdf via DynaPDF?

I have the code below which uses MBS DynaPDF to print a ListBox as a pdf:

DrawListbox pdf, lb_sales, 50, 50, pdf.GetPageWidth-100

Does anyone know what line of code I need in order to create a pdf from a TextArea called TextArea1?

You could simply use WriteFTextEx to write it in a rectangle area of page.

Do you have any examples of that - I have looked but can’t find an example appropriate?
I have no idea how much text will be in the TextArea (does that make a difference)?

Danke Schön Christian.

Did you check “text formatting” examples?

Yes, but the examples use an external text file containing the text, and I simply have a TextField in my window.
As a novice - I have no idea how to simply write a TextField to a pdf :frowning:

maybe like this:

call pdf.WriteFTextEx 100, 100, 400, 400, pdf.ktaJustify, textarea1.text

you may need to change coordinates.

That gives me a No Active Font Error :frowning:
Not to worry - thanks anyway Christian.

Does anyone have an example of writing a TextArea to a pdf using the MacOSLib stuff.
I really like the MBS Plugins, but unfortunately, as powerful as the DynaPDF plugin is - it feels like I need a degree in programming, just to print a TextArea.

If there is a MacOSLib example - I could then study it and learn from it.
Hope someone can help.

Thank you all in advance.

Did you look at the examples?

You don’T give up because you miss a single line to load a font?

for example like this:

call pdf.SetFont “Times”, pdf.kfsItalic, 12.0, true, pdf.kcp1252

Of course I am not giving up because of a missing font :slight_smile:

What I meant was, - for me, looking at the code is confusing, and finding what I need in the documentation is almost impossible, as there is so much information. I often get lost when looking at your website :frowning:

I will of course try again, but other alternatives are always a possible solution.

Thank you for all your help Christian - I appreciate it :slight_smile:

Most people learn best from examples and I have a lot of simply examples there.
But in general DynaPDF is not that difficult. It can do a lot, but most people just need a dozen functions to create a PDF.

OK - I am almost there but am struggling with creating the rectangle to fit in all the TextArea’s text.
I will not know in advance how much text is in the TextArea, and I need a 50 pixel border top, left, right, and bottom.

Here is my code so far:

call pdf.SetFont "Arial", pdf.kfsRegular, 12.0, true, pdf.kcp1252 Dim taHeight as Integer = pdf.GetPageHeight Dim taWidth as Integer = pdf.GetPageWidth call pdf.WriteFTextEx 50, 50, (tawidth - 100), (taheight - 100), pdf.ktaJustify, myTextArea.text

Well, if text doesn’t fit, you can get a PageBreak event and there for example start a new page.

That’s strange - my code above now seems to be working :slight_smile:

I now just need to be able to insert page numbers at the top right of each page.
I currently have the following code:

Dim TotalPages as Integer = pdf.GetPageCount Dim CurrentPage as Integer Dim i as Integer for i = 1 to TotalPages WHAT CODE DO I NEED TO ADD HERE? next

I am now a bit lost as to what code I need next?

Not that difficult:

call pdf.editPage(i) call pdf.WriteText x, y, str(i) call pdf.endpage

I now get an open page detected error?
My code is listed below:

[code] Dim taHeight as Integer = pdf.GetPageHeight
Dim taWidth as Integer = pdf.GetPageWidth

Dim TotalPages as Integer = pdf.GetPageCount
Dim i as Integer
for i = 1 to TotalPages
call pdf.editPage(i)
call pdf.WriteText 100, 100, str(i)
call pdf.EndPage

call pdf.WriteFTextEx 50, 50, (tawidth - 100), (taheight - 100), pdf.ktaJustify, TextAreaFinal.text
call pdf.EndPage[/code]