spread text over multiple pages

Aug 16, 2010 at 11:11 AM



I have a large text in a string. I've used "/n" as a line break.

I use the following code to put the text in the page:

 XGraphics gfx = XGraphics.FromPdfPage(page);

XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

XFont font = new XFont("Huxtable", 20, XFontStyle.Bold, options);

gfx.DrawString(test, font, XBrushes.Black,
                  new XRect(0, 0, page.Width, page.Height),

But the text is just one line in the pdf, no line breaks and nu spread over multiple pages. How can I do that?




Aug 26, 2010 at 9:25 AM


I Think you can use the XTextFormatter.DrawString() instead.

XTextFormatter tf = new XTextFormatter(gfx);
tf.DrawString(text, font, textBlock.Foreground, rect, XStringFormat.TopLeft);