Exemplo n.º 1
0
        public virtual void StructureDestination01Test()
        {
            String                  srcFile          = sourceFolder + "customRolesMappingPdf2.pdf";
            String                  outFile          = destinationFolder + "structureDestination01Test.pdf";
            String                  cmpFile          = sourceFolder + "cmp_structureDestination01Test.pdf";
            PdfDocument             document         = new PdfDocument(new PdfReader(srcFile), new PdfWriter(outFile));
            PdfStructElem           imgElement       = new PdfStructElem((PdfDictionary)document.GetPdfObject(13));
            PdfStructureDestination dest             = PdfStructureDestination.CreateFit(imgElement);
            PdfPage                 secondPage       = document.AddNewPage();
            PdfLinkAnnotation       linkExplicitDest = new PdfLinkAnnotation(new Rectangle(35, 785, 160, 15));

            linkExplicitDest.SetAction(PdfAction.CreateGoTo(dest));
            secondPage.AddAnnotation(linkExplicitDest);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFile, destinationFolder, "diff_"
                                                                             ));
        }
Exemplo n.º 2
0
        public virtual void StructureDestinationWithoutRemoteIdTest()
        {
            String        srcFile    = sourceFolder + "customRolesMappingPdf2.pdf";
            PdfDocument   document   = new PdfDocument(new PdfReader(srcFile), new PdfWriter(new MemoryStream()));
            PdfStructElem imgElement = new PdfStructElem((PdfDictionary)document.GetPdfObject(13));

            try {
                PdfAction.CreateGoToR(new PdfStringFS("Some fake destination"), PdfStructureDestination.CreateFit(imgElement
                                                                                                                  ));
                NUnit.Framework.Assert.Fail("Exception not thrown");
            }
            catch (ArgumentException e) {
                NUnit.Framework.Assert.AreEqual("Structure destinations shall specify structure element ID in remote go-to actions. Structure element that has no ID is specified instead"
                                                , e.Message);
            }
            document.Close();
        }