Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<html>
<body>
<div style="height: 826px; background-color: indianred; page-break-inside: avoid;">
This is on page 1
</div>

<div style="height: 900px; background-color: purple; page-break-inside: avoid;">
This is on page 2
</div>

<div style="height: 700px; background-color: red;">
This is on page 3.
</div>

<div style="page-break-inside: avoid; height: 1500px; background-color: blue; padding: 10px;">
This is on page 4.

<div style="height: 500px; background-color: yellow;">
This is also on page 4
</div>

<div style="height: 400px; background-color: aqua; page-break-inside: avoid;">
This is on page 5
</div>
</div>

<div style="background-color: orange; padding: 10px; page-break-inside: avoid;">
<div>
This is on page 6
</div>

<div style="background-color:yellowgreen;width:90px;height: 1000px;">
</div>
</div>

</body>
</html>
2 changes: 1 addition & 1 deletion Source/Demos/HtmlRenderer.Demo.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
foreach (var htmlSample in samples)
{
////Just doing one test here. Comment this for all of them.
if (!htmlSample.FullName.Contains("37", StringComparison.OrdinalIgnoreCase)) continue;
if (!htmlSample.FullName.Contains("38")) continue;

//await skia.GenerateSampleAsync(htmlSample);
//await svgSkia.GenerateSampleAsync(htmlSample);
Expand Down
7 changes: 7 additions & 0 deletions Source/HtmlRenderer/Core/Dom/CssBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ protected virtual async Task PerformLayoutImpAsync(RGraphics g)
{
this.BreakPage(true);
}
else if (this.PageBreakInside == CssConstants.Avoid
&& ActualHeight + Location.Y > HtmlContainer.PageSize.Height
&& prevSibling != null)
{
// handle page break avoiding.
this.BreakPage(true);
}

//Start with the assumption this is zero height.
ActualBottom = Location.Y;
Expand Down