public virtual void CreateChildInstanceTest()
        {
            PdfTarget     target     = PdfTarget.CreateChildTarget();
            PdfDictionary dictionary = target.GetPdfObject();

            NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R));
        }
        public virtual void CreateChildInstanceWithEmbeddedFileTest()
        {
            String        embeddedFileName = "EmbeddedFileName.file";
            PdfTarget     target           = PdfTarget.CreateChildTarget(embeddedFileName);
            PdfDictionary dictionary       = target.GetPdfObject();

            NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R));
            NUnit.Framework.Assert.AreEqual(new PdfString(embeddedFileName), dictionary.Get(PdfName.N));
        }
        public virtual void CreateChildInstanceWithNamedDestinationTest()
        {
            String        namedDestination     = "namedDestination";
            String        annotationIdentifier = "annotationIdentifier";
            PdfTarget     target     = PdfTarget.CreateChildTarget(namedDestination, annotationIdentifier);
            PdfDictionary dictionary = target.GetPdfObject();

            NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R));
            NUnit.Framework.Assert.AreEqual(new PdfString(namedDestination), dictionary.Get(PdfName.P));
            NUnit.Framework.Assert.AreEqual(new PdfString(annotationIdentifier), dictionary.Get(PdfName.A));
        }
        public virtual void CreateChildInstanceWithPageNumberTest()
        {
            int           pageNumber      = 23;
            int           annotationIndex = 7;
            PdfTarget     target          = PdfTarget.CreateChildTarget(pageNumber, annotationIndex);
            PdfDictionary dictionary      = target.GetPdfObject();

            NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R));
            NUnit.Framework.Assert.AreEqual(new PdfNumber(pageNumber - 1), dictionary.Get(PdfName.P));
            NUnit.Framework.Assert.AreEqual(new PdfNumber(annotationIndex), dictionary.Get(PdfName.A));
        }
 public virtual void GetAnnotationSetAsIntsTest()
 {
     using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
         int       pageNumber      = 1;
         int       annotationIndex = 0;
         PdfTarget target          = PdfTarget.CreateChildTarget(pageNumber, annotationIndex);
         PdfFileAttachmentAnnotation annotation = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20));
         document.AddNewPage();
         document.GetPage(1).AddAnnotation(annotation);
         NUnit.Framework.Assert.AreEqual(annotation.GetPdfObject(), target.GetAnnotation(document).GetPdfObject());
     }
 }
 public virtual void GetAnnotationSetAsStringNotAvailableTest()
 {
     using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
         String    namedDestination     = "namedDestination";
         String    annotationIdentifier = "annotationIdentifier";
         PdfTarget target = PdfTarget.CreateChildTarget(namedDestination, annotationIdentifier);
         document.AddNewPage();
         document.GetCatalog().GetNameTree(PdfName.Dests).AddEntry(namedDestination, new PdfArray(new PdfNumber(1))
                                                                   );
         PdfAnnotation annotation = target.GetAnnotation(document);
         NUnit.Framework.Assert.IsNull(annotation);
     }
 }
 public virtual void GetAnnotationSetAsStringTest()
 {
     using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) {
         String    namedDestination     = "namedDestination";
         String    annotationIdentifier = "annotationIdentifier";
         PdfTarget target = PdfTarget.CreateChildTarget(namedDestination, annotationIdentifier);
         PdfFileAttachmentAnnotation annotation = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20));
         annotation.SetName(new PdfString(annotationIdentifier));
         document.AddNewPage();
         document.GetPage(1).AddAnnotation(annotation);
         document.GetCatalog().GetNameTree(PdfName.Dests).AddEntry(namedDestination, new PdfArray(new PdfNumber(1))
                                                                   );
         PdfAnnotation retrievedAnnotation = target.GetAnnotation(document);
         NUnit.Framework.Assert.AreEqual(annotation.GetPdfObject(), retrievedAnnotation.GetPdfObject());
     }
 }