I started by creating a document using PdfDocument but now realise that i need to incorporate the Document object as I need to create paragraphs that will automatically go on to another page when a page is filled. However, I have a slight problem. I create my sections using various methods and then use documentRenderer to format the document as shown below:
MigraDoc.Rendering.DocumentRenderer docR = new DocumentRenderer(doc);
docR.PrepareDocument();
if (docR.FormattedDocument.PageCount > 0)
{
int pageCount = docR.FormattedDocument.PageCount;
for (int i = 1; i < pageCount + 1; i++)
{
PdfPage newpage = document.AddPage();
newpage.Height = XUnit.FromCentimeter(29.7).Point;
newpage.Width = XUnit.FromCentimeter(21.5).Point;
gfx = XGraphics.FromPdfPage(newpage);
docR.RenderPage(gfx, i);
}
}
However, for some reason the sections are appearing on seperate pages instead of one after the other. Does anyone know why this is happening?
|