diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs
index 08b270586..c8c167e05 100644
--- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs
+++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs
@@ -89,7 +89,44 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css
{
// create PDF document to render the HTML into
var document = new PdfDocument();
-
+
+ // add rendered PDF pages to document
+ AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad);
+
+ return document;
+ }
+
+ ///
+ /// Create PDF pages from given HTML and appends them to the provided PDF document.
+ ///
+ /// PDF document to append pages to
+ /// HTML source to create PDF from
+ /// the page size to use for each page in the generated pdf
+ /// the margin to use between the HTML and the edges of each page
+ /// optional: the style to use for html rendering (default - use W3 default style)
+ /// optional: can be used to overwrite stylesheet resolution logic
+ /// optional: can be used to overwrite image resolution logic
+ /// the generated image of the html
+ public static void AddPdfPages(PdfDocument document, string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null)
+ {
+ var config = new PdfGenerateConfig();
+ config.PageSize = pageSize;
+ config.SetMargins(margin);
+ AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad);
+ }
+
+ ///
+ /// Create PDF pages from given HTML and appends them to the provided PDF document.
+ ///
+ /// PDF document to append pages to
+ /// HTML source to create PDF from
+ /// the configuration to use for the PDF generation (page size/page orientation/margins/etc.)
+ /// optional: the style to use for html rendering (default - use W3 default style)
+ /// optional: can be used to overwrite stylesheet resolution logic
+ /// optional: can be used to overwrite image resolution logic
+ /// the generated image of the html
+ public static void AddPdfPages(PdfDocument document, string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null)
+ {
XSize orgPageSize;
// get the size of each page to layout the HTML in
if (config.PageSize != PageSize.Undefined)
@@ -146,11 +183,10 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css
HandleLinks(document, container, orgPageSize, pageSize);
}
}
-
- return document;
}
+
#region Private/Protected methods
///