I try to convert HTML to PDF using HtmlRenderer. This is part of code:
private byte[] CreateHtmlContent()
{
string htmlContent = File.ReadAllText(@"htmlExample.txt");
using (MemoryStream ms = new MemoryStream())
{
PdfDocument pdfDocument = new PdfDocument();
PdfDocument pdf = PdfGenerator.GeneratePdf(htmlContent, PdfSharp.PageSize.A4, 60);
pdf.Save(ms);
res = ms.ToArray();
}
return res;
}
Everything works fine except page break. On some pages I have result like on this image
Is it possible to fix this? HTML content is simple HTML that contains only headings and paragraphs and no other tags. I had no problem with iTextSharp but on this project I have to use PDFSharp and MigraDoc.