Hi Aspose,
At the moment we do our line breaks with ‘page-break-before: always;’ Unfortunatly we do not always know how long the content is. We would like to avoid a page break within a certain div with the css prop: break-inside: avoid; It is in the css standard ( break-inside - CSS: Cascading Style Sheets | MDN ) but asopose does not react to this css prop.
var pdfDocument = new Document();
HtmlLoadOptions options = new HtmlLoadOptions();
var html = "<div style=\"border: 10px solid red; break-inside: avoid; height: 200px\">dont break me </div><div style=\"border: 10px solid red; break-inside: avoid; height: 200px\">dont break me </div><div style=\"border: 10px solid red; break-inside: avoid; height: 200px\">dont break me </div><div style=\"border: 10px solid red; break-inside: avoid; height: 200px\">dont break me </div><div style=\"border: 10px solid red; break-inside: avoid; height: 200px\">dont break me </div>";
HtmlFragment textFragment = new HtmlFragment(html)
{
HtmlLoadOptions = options
};
var page = pdfDocument.Pages.Add();
page.Paragraphs.Add(textFragment);
pdfDocument.Save("html_test.PDF");
Example while it breaks:
Full source code: GitHub - JoostVanVelthoven/AsposeAvoidElementBreak
Is their any workaround possible?