Beispiel #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_"
                                                                             ));
        }
Beispiel #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);
            }
        }
Beispiel #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_"
                                                                             ));
        }