Esempio n. 1
0
        public override void Draw(DrawContext drawContext)
        {
            base.Draw(drawContext);
            bool isRelativePosition = IsRelativePosition();

            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(false);
            }
            PdfLinkAnnotation linkAnnotation = ((Link)modelElement).GetLinkAnnotation();

            linkAnnotation.SetRectangle(new PdfArray(occupiedArea.GetBBox()));
            Border border = this.GetProperty <Border>(Property.BORDER);

            if (border != null)
            {
                linkAnnotation.SetBorder(new PdfArray(new float[] { 0, 0, border.GetWidth() }));
            }
            else
            {
                linkAnnotation.SetBorder(new PdfArray(new float[] { 0, 0, 0 }));
            }
            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(true);
            }
            PdfPage page = drawContext.GetDocument().GetPage(occupiedArea.GetPageNumber());

            page.AddAnnotation(linkAnnotation);
        }
Esempio n. 2
0
        public override void Draw(DrawContext drawContext)
        {
            base.Draw(drawContext);
            bool isRelativePosition = IsRelativePosition();

            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(false);
            }
            PdfLinkAnnotation linkAnnotation = ((Link)modelElement).GetLinkAnnotation();
            Rectangle         pdfBBox        = CalculateAbsolutePdfBBox();

            linkAnnotation.SetRectangle(new PdfArray(pdfBBox));
            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(true);
            }
            PdfPage page = drawContext.GetDocument().GetPage(occupiedArea.GetPageNumber());

            page.AddAnnotation(linkAnnotation);
        }
Esempio n. 3
0
        public virtual void LinkWithCustomRectangleTest01()
        {
            String            outFileName = destinationFolder + "linkWithCustomRectangleTest01.pdf";
            String            cmpFileName = sourceFolder + "cmp_linkWithCustomRectangleTest01.pdf";
            PdfDocument       pdfDocument = new PdfDocument(new PdfWriter(outFileName));
            Document          doc         = new Document(pdfDocument);
            String            text        = "Hello World";
            PdfAction         action      = PdfAction.CreateURI("http://itextpdf.com");
            PdfLinkAnnotation annotation  = new PdfLinkAnnotation(new Rectangle(1, 1)).SetAction(action);
            Link linkByAnnotation         = new Link(text, annotation);

            doc.Add(new Paragraph(linkByAnnotation));
            annotation.SetRectangle(new PdfArray(new Rectangle(100, 100, 20, 20)));
            Link linkByChangedAnnotation = new Link(text, annotation);

            doc.Add(new Paragraph(linkByChangedAnnotation));
            Link linkByAction = new Link(text, action);

            doc.Add(new Paragraph(linkByAction));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             ));
        }