I am generating a PDF from data that is not HTML based, and I have HTML that data that I want to insert part way through creating the PDF i.e.
[Non HTML]
[HTML]
[Non HTML]
[HTML]
....
public class CreatePDF
{
private Document _document;
private const int FontSizeHeading2 = 12;
private void RegisterFonts()
{
// register non standard fonts....
}
public MemoryStream GeneratePDF(DataSet Data)
{
using (MemoryStream buffer = new MemoryStream())
{
using (PdfDocument document = new PdfDocument(new PdfWriter(buffer)))
{
RegisterFonts();
foreach (DataRow row in Data.Tables[0])
{
Text text = new Text(Text).SetFont(_fontRegular).SetFontSize(FontSizeHeading2);
Paragraph title = new Paragraph(row.Field<string>("Heading"));
/* Insert HTML content here - note this is just what
can be rendered, I am not looking for a faithful rendered. I just want the content displayed */
}
}
}
}
I am using iText to generate the PDF so using the pdfHTML plugin seemed a logical choice. However, pdfHTML closes the document/stream. The only way round it (as far as I can ascertain) is to create a PDF, hold it in memory and then add merge the two PDFs. Is there a way that I can add the HTML content to the PDF without having to merge the documents?