Beispiel #1
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc    = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
            Document    doc       = new Document(pdfDoc);
            PdfPage     firstPage = pdfDoc.GetFirstPage();

            PdfCanvas canvas = new PdfCanvas(firstPage);

            canvas
            .MoveTo(36, 700)
            .LineTo(72, 760)
            .LineTo(144, 720)
            .LineTo(72, 730)
            .ClosePathStroke();

            Rectangle linkLocation = new Rectangle(36, 700, 144, 760);

            // Make the link destination page fit to the display
            PdfExplicitDestination destination    = PdfExplicitDestination.CreateFit(firstPage);
            PdfLinkAnnotation      linkAnnotation = new PdfLinkAnnotation(linkLocation)

                                                    // Set highlighting type which is enabled after a click on the annotation
                                                    .SetHighlightMode(PdfAnnotation.HIGHLIGHT_INVERT)

                                                    // Create a link to the first page of the document.
                                                    .SetAction(PdfAction.CreateGoTo(destination));
            PdfArray arrayOfQuadPoints = new PdfArray(new int[] { 72, 730, 144, 720, 72, 760, 36, 700 });

            linkAnnotation.Put(PdfName.QuadPoints, arrayOfQuadPoints);

            firstPage.AddAnnotation(linkAnnotation);

            doc.Close();
        }