Skip to content
Open
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
Expand Up @@ -422,6 +422,9 @@ public LayoutResult layout(LayoutContext layoutContext) {
splitRenderer = createSplitRenderer(layoutResult);
splitRenderer.childRenderers = new ArrayList<>(childRenderers);
replaceSplitRendererKidFloats(waitingFloatsSplitRenderers, splitRenderer);
if (overflowRenderer != null) {
handlePositionedRenderers(layoutResult, splitRenderer, overflowRenderer);
}

float usedHeight = occupiedArea.getBBox().getHeight();
if (!includeFloatsInOccupiedArea) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,40 @@ public void absolutePositionedChildIsNotDroppedWhenParentSplitsTest() throws Exc
Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER));
}

@Test
public void absolutePositionedChildIsAnchoredToFirstFragmentWhenFloatSplitsTest() throws Exception {
String cmpFileName = SOURCE_FOLDER + "cmp_absolutePositionedChildIsAnchoredToFirstFragmentWhenFloatSplits.pdf";
String outFile = DESTINATION_FOLDER + "absolutePositionedChildIsAnchoredToFirstFragmentWhenFloatSplits.pdf";

try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outFile));
Document doc = new Document(pdfDoc)) {
Div container = new Div();
container.setProperty(Property.POSITION, LayoutPosition.RELATIVE);

// Float that is taller than a page, so it is split and its remainder overflows to the next page
StringBuilder floatText = new StringBuilder();
for (int i = 0; i < 150; ++i) {
floatText.append("Float line ").append(i).append(". ");
}
Div floatingDiv = new Div().add(new Paragraph(floatText.toString()));
floatingDiv.setProperty(Property.FLOAT, FloatPropertyValue.LEFT);
floatingDiv.setWidth(100);

Div positioned = new Div().add(new Paragraph("PositionedMarker"));
positioned.setProperty(Property.POSITION, LayoutPosition.ABSOLUTE);
positioned.setProperty(Property.RIGHT, 6f);
positioned.setProperty(Property.TOP, 6f);

container.add(floatingDiv);
container.add(new Paragraph("Short text next to the float"));
container.add(positioned);

doc.add(container);
}

Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER));
}

public static class WrongParentTreeDivRenderer extends DivRenderer {
public WrongParentTreeDivRenderer(Div modelElement) {
super(modelElement);
Expand Down
Binary file not shown.