PdfLayer extends PdfObjectWrapper<PdfDictionary> implements IPdfOCG { public Collection<PdfName> getIntents() { final PdfObject intent = getPdfObject().get(PdfName.Intent); if (intent instanceof PdfName) return Collections.singletonList((PdfName) intent); else if (intent instanceof PdfArray) { PdfArray intentArr = (PdfArray) intent; Collection<PdfName> intentsCollection = new ArrayList<>(intentArr.size()); for (PdfObject i : intentArr) { if (i instanceof PdfName) { intentsCollection.add((PdfName) i); } } return intentsCollection; } return Collections.singletonList(PdfName.View); } 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 layerDefaultIntents() { PdfLayer pdfLayer = PdfLayerTestUtils.prepareNewLayer(); Collection<PdfName> defaultIntents = pdfLayer.getIntents(); Assert.assertArrayEquals(new PdfName[] {PdfName.View}, defaultIntents.toArray(new PdfName[1])); }
@Test public void layerSetSingleIntent() { PdfLayer pdfLayer = PdfLayerTestUtils.prepareLayerDesignIntent(); Collection<PdfName> defaultIntents = pdfLayer.getIntents(); Assert.assertArrayEquals(new PdfName[] {PdfName.Design}, defaultIntents.toArray(new PdfName[1])); }
@Test public void layerSetSeveralIntents() { PdfName custom = new PdfName("Custom"); PdfLayer pdfLayer = PdfLayerTestUtils.prepareLayerDesignAndCustomIntent(custom); Collection<PdfName> defaultIntents = pdfLayer.getIntents(); Assert.assertArrayEquals(new PdfName[] {PdfName.Design, custom}, defaultIntents.toArray(new PdfName[2])); }