PdfLayer extends PdfObjectWrapper<PdfDictionary> implements IPdfOCG { public void setLocked(boolean locked) { if (this.isLocked() != locked) fetchOCProperties().setModified(); this.locked = locked; } PdfLayer(PdfDictionary layerDictionary);  PdfLayer(String name, PdfDocument document); private  PdfLayer(PdfDocument document); static PdfLayer createTitle(String title, PdfDocument document); static void addOCGRadioGroup(PdfDocument document, List<PdfLayer> group); void addChild(PdfLayer childLayer); PdfLayer getParent(); void setName(String name); boolean isOn(); void setOn(boolean on); boolean isLocked(); void setLocked(boolean locked); boolean isOnPanel(); void setOnPanel(boolean onPanel); Collection<PdfName> getIntents(); void setIntents(List<PdfName> intents); void setCreatorInfo(String creator, String subtype); void setLanguage(String lang, boolean preferred); void setExport(boolean export); void setZoom(float min, float max); void setPrint(String subtype, boolean printState); void setView(boolean view); void setUser(String type, String... names); void setPageElement(String pe); PdfIndirectReference getIndirectReference(); String getTitle(); List<PdfLayer> getChildren();  }
@Test public void lockedLayer() throws IOException { String outPdf = destinationFolder + "lockedLayer.pdf"; String cmpPdf = sourceFolder + "cmp_lockedLayer.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf)); PdfFont font = PdfFontFactory.createFont(); PdfLayer layer1 = new PdfLayer("Layer 1", pdfDoc); PdfLayer layer2 = new PdfLayer("Layer 2", pdfDoc); layer2.setLocked(true); PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setFontAndSize(font, 12); PdfLayerTestUtils.addTextInsideLayer(layer1, canvas, "Layer 1 text", 100, 700); PdfLayerTestUtils.addTextInsideLayer(layer2, canvas, "Layer 2 text", 100, 650); pdfDoc.close(); PdfLayerTestUtils.compareLayers(outPdf, cmpPdf); }