コード例 #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);
        }
コード例 #2
0
        public virtual void Draw(DrawContext drawContext)
        {
            ApplyDestination(drawContext.GetDocument());
            ApplyAction(drawContext.GetDocument());
            bool relativePosition = IsRelativePosition();

            if (relativePosition)
            {
                ApplyAbsolutePositioningTranslation(false);
            }
            DrawBackground(drawContext);
            DrawBorder(drawContext);
            DrawChildren(drawContext);
            if (relativePosition)
            {
                ApplyAbsolutePositioningTranslation(true);
            }
            flushed = true;
        }
コード例 #3
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);
        }
コード例 #4
0
        public override void Draw(DrawContext drawContext)
        {
            PdfDocument document = drawContext.GetDocument();

            ApplyDestination(document);
            ApplyAction(document);
            bool               isTagged          = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement;
            TagTreePointer     tagPointer        = null;
            IAccessibleElement accessibleElement = null;

            if (isTagged)
            {
                accessibleElement = (IAccessibleElement)GetModelElement();
                PdfName role = accessibleElement.GetRole();
                if (role != null && !PdfName.Artifact.Equals(role))
                {
                    tagPointer = document.GetTagStructureContext().GetAutoTaggingPointer();
                    if (!tagPointer.IsElementConnectedToTag(accessibleElement))
                    {
                        AccessibleAttributesApplier.ApplyLayoutAttributes(role, this, document);
                        if (role.Equals(PdfName.TD))
                        {
                            AccessibleAttributesApplier.ApplyTableAttributes(this);
                        }
                        if (role.Equals(PdfName.List))
                        {
                            AccessibleAttributesApplier.ApplyListAttributes(this);
                        }
                    }
                    tagPointer.AddTag(accessibleElement, true);
                }
                else
                {
                    isTagged = false;
                }
            }
            bool isRelativePosition = IsRelativePosition();

            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(false);
            }
            BeginRotationIfApplied(drawContext.GetCanvas());
            DrawBackground(drawContext);
            DrawBorder(drawContext);
            DrawChildren(drawContext);
            EndRotationIfApplied(drawContext.GetCanvas());
            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(true);
            }
            if (isTagged)
            {
                tagPointer.MoveToParent();
                if (isLastRendererForModelElement)
                {
                    document.GetTagStructureContext().RemoveElementConnectionToTag(accessibleElement);
                }
            }
            flushed = true;
        }
コード例 #5
0
        public override void Draw(DrawContext drawContext)
        {
            base.Draw(drawContext);
            PdfDocument    document   = drawContext.GetDocument();
            bool           isTagged   = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement;
            bool           isArtifact = false;
            TagTreePointer tagPointer = null;

            if (isTagged)
            {
                tagPointer = document.GetTagStructureContext().GetAutoTaggingPointer();
                IAccessibleElement accessibleElement = (IAccessibleElement)GetModelElement();
                PdfName            role = accessibleElement.GetRole();
                if (role != null && !PdfName.Artifact.Equals(role))
                {
                    AccessibleAttributesApplier.ApplyLayoutAttributes(accessibleElement.GetRole(), this, document);
                    tagPointer.AddTag(accessibleElement);
                }
                else
                {
                    isTagged = false;
                    if (PdfName.Artifact.Equals(role))
                    {
                        isArtifact = true;
                    }
                }
            }
            ApplyMargins(occupiedArea.GetBBox(), false);
            bool isRelativePosition = IsRelativePosition();

            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(false);
            }
            if (fixedYPosition == null)
            {
                fixedYPosition = occupiedArea.GetBBox().GetY() + pivotY;
            }
            if (fixedXPosition == null)
            {
                fixedXPosition = occupiedArea.GetBBox().GetX();
            }
            PdfCanvas canvas = drawContext.GetCanvas();

            if (isTagged)
            {
                canvas.OpenTag(tagPointer.GetTagReference());
            }
            else
            {
                if (isArtifact)
                {
                    canvas.OpenTag(new CanvasArtifact());
                }
            }
            PdfXObject xObject = ((Image)(GetModelElement())).GetXObject();

            canvas.AddXObject(xObject, matrix[0], matrix[1], matrix[2], matrix[3], (float)fixedXPosition + deltaX, (float
                                                                                                                    )fixedYPosition);
            if (true.Equals(GetPropertyAsBoolean(Property.FLUSH_ON_DRAW)))
            {
                xObject.Flush();
            }
            if (isTagged || isArtifact)
            {
                canvas.CloseTag();
            }
            if (isRelativePosition)
            {
                ApplyAbsolutePositioningTranslation(true);
            }
            ApplyMargins(occupiedArea.GetBBox(), true);
            if (isTagged)
            {
                tagPointer.MoveToParent();
            }
        }
コード例 #6
0
        public override void Draw(DrawContext drawContext)
        {
            bool           isTagged   = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement;
            TagTreePointer tagPointer = null;

            if (isTagged)
            {
                tagPointer = drawContext.GetDocument().GetTagStructureContext().GetAutoTaggingPointer();
                IAccessibleElement modelElement = (IAccessibleElement)GetModelElement();
                PdfName            role         = modelElement.GetRole();
                if (role != null && !PdfName.Artifact.Equals(role))
                {
                    bool lBodyTagIsCreated = tagPointer.IsElementConnectedToTag(modelElement);
                    if (!lBodyTagIsCreated)
                    {
                        tagPointer.AddTag(PdfName.LI);
                    }
                    else
                    {
                        tagPointer.MoveToTag(modelElement).MoveToParent();
                    }
                }
                else
                {
                    isTagged = false;
                }
            }
            base.Draw(drawContext);
            // It will be null in case of overflow (only the "split" part will contain symbol renderer.
            if (symbolRenderer != null)
            {
                symbolRenderer.SetParent(parent);
                float x = occupiedArea.GetBBox().GetX();
                if (childRenderers.Count > 0)
                {
                    float?yLine = ((AbstractRenderer)childRenderers[0]).GetFirstYLineRecursively();
                    if (yLine != null)
                    {
                        if (symbolRenderer is TextRenderer)
                        {
                            ((TextRenderer)symbolRenderer).MoveYLineTo((float)yLine);
                        }
                        else
                        {
                            symbolRenderer.Move(0, (float)yLine - symbolRenderer.GetOccupiedArea().GetBBox().GetY());
                        }
                    }
                    else
                    {
                        symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - (symbolRenderer
                                                                                                                     .GetOccupiedArea().GetBBox().GetY() + symbolRenderer.GetOccupiedArea().GetBBox().GetHeight()));
                    }
                }
                else
                {
                    symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - symbolRenderer
                                        .GetOccupiedArea().GetBBox().GetHeight() - symbolRenderer.GetOccupiedArea().GetBBox().GetY());
                }
                ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment)parent.GetProperty <ListSymbolAlignment?>(Property
                                                                                                                         .LIST_SYMBOL_ALIGNMENT, ListSymbolAlignment.RIGHT);
                float xPosition = x - symbolRenderer.GetOccupiedArea().GetBBox().GetX();
                if (listSymbolAlignment == ListSymbolAlignment.RIGHT)
                {
                    xPosition += symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth();
                }
                symbolRenderer.Move(xPosition, 0);
                if (isTagged)
                {
                    tagPointer.AddTag(0, PdfName.Lbl);
                }
                symbolRenderer.Draw(drawContext);
                if (isTagged)
                {
                    tagPointer.MoveToParent();
                }
            }
            if (isTagged)
            {
                tagPointer.MoveToParent();
            }
        }