PdfTarget extends PdfObjectWrapper<PdfDictionary> { public static PdfTarget createChildTarget() { return PdfTarget.create(PdfName.C); } private  PdfTarget(PdfDictionary pdfObject); static PdfTarget create(PdfDictionary pdfObject); static PdfTarget createParentTarget(); static PdfTarget createChildTarget(); static PdfTarget createChildTarget(String embeddedFileName); static PdfTarget createChildTarget(String namedDestination, String annotationIdentifier); static PdfTarget createChildTarget(int pageNumber, int annotationIndex); PdfTarget setName(String name); String getName(); PdfTarget setAnnotation(PdfFileAttachmentAnnotation pdfAnnotation, PdfDocument pdfDocument); PdfFileAttachmentAnnotation getAnnotation(PdfDocument pdfDocument); PdfTarget setTarget(PdfTarget target); PdfTarget getTarget(); PdfTarget put(PdfName key, PdfObject value);  }
@Test public void createChildInstanceTest() { PdfTarget target = PdfTarget.createChildTarget(); PdfDictionary dictionary = target.getPdfObject(); Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); }
@Test public void createChildInstanceWithEmbeddedFileTest() { final String embeddedFileName = "EmbeddedFileName.file"; PdfTarget target = PdfTarget.createChildTarget(embeddedFileName); PdfDictionary dictionary = target.getPdfObject(); Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); Assert.assertEquals(new PdfString(embeddedFileName), dictionary.get(PdfName.N)); }
@Test public void createChildInstanceWithNamedDestinationTest() { final String namedDestination = "namedDestination"; final String annotationIdentifier = "annotationIdentifier"; PdfTarget target = PdfTarget.createChildTarget(namedDestination, annotationIdentifier); PdfDictionary dictionary = target.getPdfObject(); Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); Assert.assertEquals(new PdfString(namedDestination), dictionary.get(PdfName.P)); Assert.assertEquals(new PdfString(annotationIdentifier), dictionary.get(PdfName.A)); }
@Test public void createChildInstanceWithPageNumberTest() { final int pageNumber = 23; final int annotationIndex = 7; PdfTarget target = PdfTarget.createChildTarget(pageNumber, annotationIndex); PdfDictionary dictionary = target.getPdfObject(); Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); Assert.assertEquals(new PdfNumber(pageNumber - 1), dictionary.get(PdfName.P)); Assert.assertEquals(new PdfNumber(annotationIndex), dictionary.get(PdfName.A)); }