private static PdfFixedDocument DrawFormattedContent(PdfFormattedContent fc) { PdfFixedDocument _doc = new PdfFixedDocument(); PdfPage page = _doc.Pages.Add(); page.Width = 595; page.Height = 842; PdfFormattedContent fragment = fc.SplitByBox(485, 742); while (fragment != null) { page.Graphics.DrawFormattedContent(fragment, 60, 50); page.Graphics.CompressAndClose(); fragment = fc.SplitByBox(485, 742); if (fragment != null) { page = _doc.Pages.Add(); page.Width = 595; page.Height = 842; } } return(_doc); }
/// <summary> /// Draws the formatted content on document's pages. /// </summary> /// <param name="document"></param> /// <param name="fc"></param> private void DrawFormattedContent(PdfFixedDocument document, PdfFormattedContent fc) { double leftMargin, topMargin, rightMargin, bottomMargin; leftMargin = topMargin = rightMargin = bottomMargin = 36; PdfPage page = document.Pages.Add(); PdfFormattedContent fragment = fc.SplitByBox(page.Width - leftMargin - rightMargin, page.Height - topMargin - bottomMargin); while (fragment != null) { page.Graphics.DrawFormattedContent(fragment, leftMargin, topMargin, page.Width - leftMargin - rightMargin, page.Height - topMargin - bottomMargin); page.Graphics.CompressAndClose(); fragment = fc.SplitByBox(page.Width - leftMargin - rightMargin, page.Height - topMargin - bottomMargin); if (fragment != null) { page = document.Pages.Add(); } } }