System.out.println("layer radio group and zoom");
try {
// step 1
LwgDocument document = new LwgDocument(LwgPageSize.A4, 50, 50, 50, 50);
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("layers.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_5);
writer.setViewerPreferences(PdfWriter.PageModeUseOC);
// step 3
document.open();
// step 4
PdfContentByte cb = writer.getDirectContent();
LwgPhrase explanation = new LwgPhrase("Layer radio group and zoom", new LwgFont(LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50, 650, 0);
PdfLayer title = PdfLayer.createTitle("Layer radio group", writer);
PdfLayer l1 = new PdfLayer("Layer 1", writer);
PdfLayer l2 = new PdfLayer("Layer 2", writer);
PdfLayer l3 = new PdfLayer("Layer 3", writer);
PdfLayer l4 = new PdfLayer("Layer 4", writer);
title.addChild(l1);
title.addChild(l2);
title.addChild(l3);
l4.setZoom(2, -1);
l4.setOnPanel(false);
l4.setPrint("Print", true);
l2.setOn(false);
l3.setOn(false);
ArrayList radio = new ArrayList();
radio.add(l1);
radio.add(l2);
radio.add(l3);
writer.addOCGRadioGroup(radio);
LwgPhrase p1 = new LwgPhrase("Text in layer 1");
LwgPhrase p2 = new LwgPhrase("Text in layer 2");
LwgPhrase p3 = new LwgPhrase("Text in layer 3");
LwgPhrase p4 = new LwgPhrase("Text in layer 4");
cb.beginLayer(l1);