In general if you want to use the layout engine, easily set color borders and stuff like that you should be able to do this with the following example: https://github.com/itext/itext-java/blob/aeb7140b9e026cf949e405b1420d639c896f4618/layout/src/test/java/com/itextpdf/layout/CanvasTest.java#L254
try (PdfDocument pdf = new PdfDocument(new PdfWriter(out))) {
pdf.addNewPage();
Canvas canvas = new Canvas(new PdfCanvas(pdf.getFirstPage()),
new Rectangle(120, 650, 60, 80));
Div notFittingDiv = new Div().setWidth(100)
.add(new Paragraph("Paragraph in Div with Not set position"));
canvas.add(notFittingDiv);
Div divWithPosition = new Div().setFixedPosition(120, 300, 80);
divWithPosition.add(new Paragraph("Paragraph in Div with set position"));
canvas.add(divWithPosition);
canvas.close();
}
Also you can just use fixed position on the paragraph without the div. but it's nice to have a container in an absolute position and then use the layout engine to take care of the inner content in example Please let me know if this helps your usecase.