A web based application, I am working on, must provide users with the ability to export a collection of articles to one single PDF document. This articles contain HTML code for formatting the text as well as positioning of various parts of the article.
Below is the code which I came up with for Exporting one single article:
var html = File.OpenText(artPath).ReadToEnd();
var buffer = new byte[0];
var pdfProvider = new PdfFormatProvider();
var htmlFormatProvider = new HtmlFormatProvider();
HtmlImportSettings importSettings = new HtmlImportSettings();
importSettings.UseHtmlHeadingStyles = true;
htmlFormatProvider.ImportSettings = importSettings;
var document = htmlFormatProvider.Import(html);
document.LayoutMode = DocumentLayoutMode.Paged;
document.EnsureDocumentMeasuredAndArranged();
buffer = pdfProvider.Export(document);
using (var fs = new FileStream(pdfDocPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
fs.Write(buffer, 0, buffer.Length);
fs.Flush();
}
However, I am not being able to figure out how to export multiple articles into one single PDF document. Any help would be highly appreciated.
Thanks!
Zen