PdfResources extends PdfObjectWrapper<PdfDictionary> { public PdfName addExtGState(PdfExtGState extGState) { return addResource(extGState, egsNamesGen); } PdfResources(PdfDictionary pdfObject);  PdfResources(); PdfName addFont(PdfDocument pdfDocument, PdfFont font); PdfName addImage(PdfImageXObject image); PdfName addImage(PdfStream image); PdfImageXObject getImage(PdfName name); PdfName addForm(PdfFormXObject form); PdfName addForm(PdfStream form); PdfName addForm(PdfFormXObject form, PdfName name); PdfFormXObject getForm(PdfName name); PdfName addExtGState(PdfExtGState extGState); PdfName addExtGState(PdfDictionary extGState); PdfExtGState getPdfExtGState(PdfName name); PdfName addProperties(PdfDictionary properties); PdfObject getProperties(PdfName name); PdfName addColorSpace(PdfColorSpace cs); PdfName addColorSpace(PdfObject colorSpace); PdfColorSpace getColorSpace(PdfName name); PdfName addPattern(PdfPattern pattern); PdfName addPattern(PdfDictionary pattern); PdfPattern getPattern(PdfName name); PdfName addShading(PdfShading shading); PdfName addShading(PdfDictionary shading); PdfShading getShading(PdfName name); @Override PdfObjectWrapper<PdfDictionary> setModified(); void setDefaultGray(PdfColorSpace defaultCs); void setDefaultRgb(PdfColorSpace defaultCs); void setDefaultCmyk(PdfColorSpace defaultCs); PdfName getResourceName(PdfObjectWrapper<T> resource); PdfName getResourceName(PdfObject resource); Set<PdfName> getResourceNames(); PdfArray getProcSet(); void setProcSet(PdfArray array); Set<PdfName> getResourceNames(PdfName resType); PdfDictionary getResource(PdfName resType); PdfObject getResourceObject(PdfName resType, PdfName resName);  }
@Test public void resourcesTest1() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage page = document.addNewPage(); PdfExtGState egs1 = new PdfExtGState(); PdfExtGState egs2 = new PdfExtGState(); PdfResources resources = page.getResources(); PdfName n1 = resources.addExtGState(egs1); Assert.assertEquals("Gs1", n1.getValue()); PdfName n2 = resources.addExtGState(egs2); Assert.assertEquals("Gs2", n2.getValue()); n1 = resources.addExtGState(egs1); Assert.assertEquals("Gs1", n1.getValue()); document.close(); }