示例#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);
        }
        protected internal virtual void ApplyAction(PdfDocument document)
        {
            PdfAction action = this.GetProperty <PdfAction>(Property.ACTION);

            if (action != null)
            {
                PdfLinkAnnotation link = new PdfLinkAnnotation(GetOccupiedArea().GetBBox());
                link.SetAction(action);
                Border border = this.GetProperty <Border>(Property.BORDER);
                if (border != null)
                {
                    link.SetBorder(new PdfArray(new float[] { 0, 0, border.GetWidth() }));
                }
                else
                {
                    link.SetBorder(new PdfArray(new float[] { 0, 0, 0 }));
                }
                document.GetPage(GetOccupiedArea().GetPageNumber()).AddAnnotation(link);
            }
        }