I have a TextArea that I want to export to a PDFDocument. If I follow the Xojo documentation I use the following code:
Var tempPDFDocument As PDFDocument = New PDFDocument(PDFDocument.PageSizes.A4)
Var tempGraphics As Graphics = tempPDFDocument.Graphics
tempGraphics.DrawText(myTextEditor.Text, 20, 20, tempPDFDocument.PageWidth - 40)
tempPDFDocument.Save(f)
There are two thing this cannot do:
- Print the formatted text
- Print more than one page
So, I tried to use the code to print to the current printer (see below), but it crashes inside the While loop.
Var tempStyledTextPrinter As StyledTextPrinter = myTextEditor.StyledTextPrinter(tempGraphics, tempPDFDocument.PageWidth)
While Not tempStyledTextPrinter.EOF
tempStyledTextPrinter.DrawBlock(0, 0, tempPDFDocument.PageHeight) 'crashes here
tempGraphics.NextPage
Wend
How can I export a styled, multipage TextArea to a PDFDocument?