PdfContentByte cb = writer.getDirectContent();
LwgPhrase explanation = new LwgPhrase("Layer grouping", new LwgFont(
LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50,
650, 0);
PdfLayer l1 = new PdfLayer("Layer 1", writer);
PdfLayer l2 = new PdfLayer("Layer 2", writer);
PdfLayer l3 = new PdfLayer("Layer 3", writer);
PdfLayerMembership m1 = new PdfLayerMembership(writer);
m1.addMember(l2);
m1.addMember(l3);
LwgPhrase p1 = new LwgPhrase("Text in layer 1");
LwgPhrase p2 = new LwgPhrase("Text in layer 2 or layer 3");
LwgPhrase p3 = new LwgPhrase("Text in layer 3");
cb.beginLayer(l1);
ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p1, 50, 600, 0);
cb.endLayer();
cb.beginLayer(m1);
ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p2, 50, 550, 0);
cb.endLayer();
cb.beginLayer(l3);
ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p3, 50, 500, 0);
cb.endLayer();
PdfOCProperties p = writer.getOCProperties();
PdfArray order = new PdfArray();
order.add(l1.getRef());
PdfArray group = new PdfArray();
group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE));
group.add(l2.getRef());
group.add(l3.getRef());
order.add(group);
PdfDictionary d = new PdfDictionary();
d.put(PdfName.ORDER, order);
p.put(PdfName.D, d);
} catch (DocumentException de) {