示例#1
0
        public virtual void RemoteGoToDestinationTest01()
        {
            String      cmpFile = sourceFolder + "cmp_remoteGoToDestinationTest01.pdf";
            String      outFile = destinationFolder + "remoteGoToDestinationTest01.pdf";
            PdfDocument @out    = new PdfDocument(new PdfWriter(outFile));

            @out.AddNewPage();
            IList <PdfDestination> destinations = new List <PdfDestination>(7);

            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFit(1));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitH(1, 10));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitV(1, 10));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitR(1, 10, 10, 10, 10));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitB(1));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitBH(1, 10));
            destinations.Add(PdfExplicitRemoteGoToDestination.CreateFitBV(1, 10));
            int y = 785;

            foreach (PdfDestination destination in destinations)
            {
                PdfLinkAnnotation linkExplicitDest = new PdfLinkAnnotation(new Rectangle(35, y, 160, 15));
                PdfAction         action           = PdfAction.CreateGoToR(new PdfStringFS("Some fake destination"), destination);
                linkExplicitDest.SetAction(action);
                @out.GetFirstPage().AddAnnotation(linkExplicitDest);
                y -= 20;
            }
            @out.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFile, destinationFolder, "diff_"
                                                                             ));
        }
示例#2
0
        /// <summary>
        /// process list as last page of creating PDF
        /// </summary>
        /// <param name="toc"></param>
        /// <param name="doc"></param>
        private static void processDocumentLinkedList(List <KeyValuePair <string, int> > toc, Document doc)
        {
            PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);
            PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
            Paragraph p = new Paragraph().SetFont(bold).Add("Obsah");

            doc.Add(p);

            List <TabStop> tabStops = new List <TabStop>();

            tabStops.Add(new TabStop(580, TabAlignment.RIGHT, new iText.Kernel.Pdf.Canvas.Draw.DottedLine()));
            foreach (KeyValuePair <string, int> entry in toc)
            {
                p = new iText.Layout.Element.Paragraph()
                    .AddTabStops(tabStops)
                    .Add(entry.Key)
                    .Add(new Tab())
                    .Add(entry.Value.ToString())
                    .SetAction(PdfAction.CreateGoTo(PdfExplicitRemoteGoToDestination.CreateFit(entry.Value)));

                doc.Add(p);
            }
        }
示例#3
0
        public virtual void RemoteGoToNotValidExplicitDestinationTest()
        {
            String      cmpFile  = sourceFolder + "cmp_remoteGoToNotValidExplicitDestinationTest.pdf";
            String      outFile  = destinationFolder + "remoteGoToNotValidExplicitDestinationTest.pdf";
            PdfDocument document = new PdfDocument(new PdfWriter(outFile));

            document.AddNewPage();
            PdfLinkAnnotation linkExplicitDest = new PdfLinkAnnotation(new Rectangle(35, 785, 160, 15));

            linkExplicitDest.SetAction(PdfAction.CreateGoTo(PdfExplicitRemoteGoToDestination.CreateFit(1)));
            document.GetFirstPage().AddAnnotation(linkExplicitDest);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFile, destinationFolder, "diff_"
                                                                             ));
        }
示例#4
0
        public virtual void RemoteGoToDestinationTest02()
        {
            String      cmpFile = sourceFolder + "cmp_remoteGoToDestinationTest02.pdf";
            String      outFile = destinationFolder + "remoteGoToDestinationTest02.pdf";
            PdfDocument @out    = new PdfDocument(new PdfWriter(outFile));

            @out.AddNewPage();
            @out.AddNewPage();
            PdfLinkAnnotation linkExplicitDest = new PdfLinkAnnotation(new Rectangle(35, 785, 160, 15));
            PdfAction         action           = PdfAction.CreateGoToR(new PdfStringFS("Some fake destination"), PdfExplicitRemoteGoToDestination
                                                                       .CreateFitR(2, 10, 10, 10, 10), true);

            linkExplicitDest.SetAction(action);
            @out.GetFirstPage().AddAnnotation(linkExplicitDest);
            @out.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFile, destinationFolder, "diff_"
                                                                             ));
        }
示例#5
0
 /// <summary>Creates a GoToR action, or remote action (section 12.6.4.3 of ISO 32000-1).</summary>
 /// <param name="filename">the remote destination file to jump to</param>
 /// <param name="pageNum">the remote destination document page to jump to</param>
 /// <param name="newWindow">a flag specifying whether to open the destination document in a new window</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(String filename, int pageNum, bool newWindow)
 {
     return(CreateGoToR(new PdfStringFS(filename), PdfExplicitRemoteGoToDestination.CreateFitH(pageNum, 10000),
                        newWindow));
 }