I'm trying to just create a page with some text on it (just like the hello world example, but my string is a lot longer. I put some newlines in there, but it didn't work right, the text just went off the page and newlines appeared as the block character.
Is there anything i can do? Should i use some other API method to do this?
Code:
// Create a new PDF document
PdfDocument document = new PdfDocument();
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
XFont font = new XFont("Arial", 20, XFontStyle.Bold, options);
string text = this.Name;
//Make multiline if longer than 10 characters
if (text.Length > 10)
{
text = text.Replace(" ", "\n");
}
for (int i = 1; i <= this.Pages; i++)
{
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
gfx.DrawString(text + "\nPage " + i.ToString(), font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
}
document.Save(targetdirectory + "\\" + filename);