コード例 #1
0
        /// <summary>
        /// Draws a background layer if it is defined by a key
        /// <see cref="Property.BACKGROUND"/>
        /// in either the layout element or this
        /// <see cref="IRenderer"/>
        /// itself.
        /// </summary>
        /// <param name="drawContext">the context (canvas, document, etc) of this drawing operation.
        ///     </param>
        public virtual void DrawBackground(DrawContext drawContext)
        {
            Background background = this.GetProperty <Background>(Property.BACKGROUND);

            if (background != null)
            {
                Rectangle bBox     = GetOccupiedAreaBBox();
                bool      isTagged = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement;
                if (isTagged)
                {
                    drawContext.GetCanvas().OpenTag(new CanvasArtifact());
                }
                Rectangle backgroundArea = ApplyMargins(bBox, false);
                if (backgroundArea.GetWidth() <= 0 || backgroundArea.GetHeight() <= 0)
                {
                    ILogger logger = LoggerFactory.GetLogger(typeof(iText.Layout.Renderer.AbstractRenderer
                                                                    ));
                    logger.Error(String.Format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES
                                               , "background"));
                    return;
                }
                drawContext.GetCanvas().SaveState().SetFillColor(background.GetColor()).Rectangle
                    (backgroundArea.GetX() - background.GetExtraLeft(), backgroundArea.GetY() - background
                    .GetExtraBottom(), backgroundArea.GetWidth() + background.GetExtraLeft() + background
                    .GetExtraRight(), backgroundArea.GetHeight() + background.GetExtraTop() + background
                    .GetExtraBottom()).Fill().RestoreState();
                if (isTagged)
                {
                    drawContext.GetCanvas().CloseTag();
                }
            }
        }
コード例 #2
0
        public override void Draw(DrawContext drawContext)
        {
            if (occupiedArea == null)
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.TabRenderer));
                logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED,
                                                      "Drawing won't be performed."));
                return;
            }
            ILineDrawer leader = this.GetProperty <ILineDrawer>(Property.TAB_LEADER);

            if (leader == null)
            {
                return;
            }
            bool isTagged = drawContext.IsTaggingEnabled();

            if (isTagged)
            {
                drawContext.GetCanvas().OpenTag(new CanvasArtifact());
            }
            BeginElementOpacityApplying(drawContext);
            leader.Draw(drawContext.GetCanvas(), occupiedArea.GetBBox());
            EndElementOpacityApplying(drawContext);
            if (isTagged)
            {
                drawContext.GetCanvas().CloseTag();
            }
        }
コード例 #3
0
ファイル: TabRenderer.cs プロジェクト: leofidus/itext7-dotnet
        public override void Draw(DrawContext drawContext)
        {
            ILineDrawer leader = this.GetProperty <ILineDrawer>(Property.TAB_LEADER);

            if (leader == null)
            {
                return;
            }
            bool isTagged = drawContext.IsTaggingEnabled();

            if (isTagged)
            {
                drawContext.GetCanvas().OpenTag(new CanvasArtifact());
            }
            leader.Draw(drawContext.GetCanvas(), occupiedArea.GetBBox());
            if (isTagged)
            {
                drawContext.GetCanvas().CloseTag();
            }
        }
コード例 #4
0
        /// <summary><inheritDoc/></summary>
        public override void DrawChildren(DrawContext drawContext)
        {
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);

            if (lineDrawer != null)
            {
                PdfCanvas canvas   = drawContext.GetCanvas();
                bool      isTagged = drawContext.IsTaggingEnabled();
                if (isTagged)
                {
                    canvas.OpenTag(new CanvasArtifact());
                }
                Rectangle area = GetOccupiedAreaBBox();
                ApplyMargins(area, false);
                lineDrawer.Draw(canvas, area);
                if (isTagged)
                {
                    canvas.CloseTag();
                }
            }
        }
コード例 #5
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;
        }
コード例 #6
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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
0
        public override void Draw(DrawContext drawContext)
        {
            if (occupiedArea == null)
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ImageRenderer));
                logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED,
                                                      "Drawing won't be performed."));
                return;
            }
            bool isRelativePosition = IsRelativePosition();

            if (isRelativePosition)
            {
                ApplyRelativePositioningTranslation(false);
            }
            bool isTagged = drawContext.IsTaggingEnabled();
            LayoutTaggingHelper taggingHelper = null;
            bool           isArtifact         = false;
            TagTreePointer tagPointer         = null;

            if (isTagged)
            {
                taggingHelper = this.GetProperty <LayoutTaggingHelper>(Property.TAGGING_HELPER);
                if (taggingHelper == null)
                {
                    isArtifact = true;
                }
                else
                {
                    isArtifact = taggingHelper.IsArtifact(this);
                    if (!isArtifact)
                    {
                        tagPointer = taggingHelper.UseAutoTaggingPointerAndRememberItsPosition(this);
                        if (taggingHelper.CreateTag(this, tagPointer))
                        {
                            tagPointer.GetProperties().AddAttributes(0, AccessibleAttributesApplier.GetLayoutAttributes(this, tagPointer
                                                                                                                        ));
                        }
                    }
                }
            }
            BeginTransformationIfApplied(drawContext.GetCanvas());
            float?angle = this.GetPropertyAsFloat(Property.ROTATION_ANGLE);

            if (angle != null)
            {
                drawContext.GetCanvas().SaveState();
                ApplyConcatMatrix(drawContext, angle);
            }
            base.Draw(drawContext);
            bool clipImageInAViewOfBorderRadius = ClipBackgroundArea(drawContext, ApplyMargins(GetOccupiedAreaBBox(),
                                                                                               false), true);

            ApplyMargins(occupiedArea.GetBBox(), false);
            ApplyBorderBox(occupiedArea.GetBBox(), GetBorders(), false);
            if (fixedYPosition == null)
            {
                fixedYPosition = occupiedArea.GetBBox().GetY() + pivotY;
            }
            if (fixedXPosition == null)
            {
                fixedXPosition = occupiedArea.GetBBox().GetX();
            }
            if (angle != null)
            {
                fixedXPosition += rotatedDeltaX;
                fixedYPosition -= rotatedDeltaY;
                drawContext.GetCanvas().RestoreState();
            }
            PdfCanvas canvas = drawContext.GetCanvas();

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

            BeginElementOpacityApplying(drawContext);
            canvas.AddXObject(xObject, matrix[0], matrix[1], matrix[2], matrix[3], (float)fixedXPosition + deltaX, (float
                                                                                                                    )fixedYPosition);
            EndElementOpacityApplying(drawContext);
            EndTransformationIfApplied(drawContext.GetCanvas());
            if (true.Equals(GetPropertyAsBoolean(Property.FLUSH_ON_DRAW)))
            {
                xObject.Flush();
            }
            if (isTagged)
            {
                canvas.CloseTag();
            }
            if (clipImageInAViewOfBorderRadius)
            {
                canvas.RestoreState();
            }
            if (isRelativePosition)
            {
                ApplyRelativePositioningTranslation(true);
            }
            ApplyBorderBox(occupiedArea.GetBBox(), GetBorders(), true);
            ApplyMargins(occupiedArea.GetBBox(), true);
            if (isTagged && !isArtifact)
            {
                taggingHelper.FinishTaggingHint(this);
                taggingHelper.RestoreAutoTaggingPointerPosition(this);
            }
        }
コード例 #9
0
 public override void Draw(DrawContext drawContext)
 {
     if (occupiedArea == null)
     {
         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED,
                                               "Drawing won't be performed."));
         return;
     }
     if (drawContext.IsTaggingEnabled())
     {
         LayoutTaggingHelper taggingHelper = this.GetProperty <LayoutTaggingHelper>(Property.TAGGING_HELPER);
         if (taggingHelper != null)
         {
             if (symbolRenderer != null)
             {
                 LayoutTaggingHelper.AddTreeHints(taggingHelper, symbolRenderer);
             }
             if (taggingHelper.IsArtifact(this))
             {
                 taggingHelper.MarkArtifactHint(symbolRenderer);
             }
             else
             {
                 TaggingHintKey hintKey    = LayoutTaggingHelper.GetHintKey(this);
                 TaggingHintKey parentHint = taggingHelper.GetAccessibleParentHint(hintKey);
                 if (parentHint != null && !(StandardRoles.LI.Equals(parentHint.GetAccessibleElement().GetAccessibilityProperties
                                                                         ().GetRole())))
                 {
                     TaggingDummyElement    listItemIntermediate = new TaggingDummyElement(StandardRoles.LI);
                     IList <TaggingHintKey> intermediateKid      = JavaCollectionsUtil.SingletonList <TaggingHintKey>(LayoutTaggingHelper
                                                                                                                      .GetOrCreateHintKey(listItemIntermediate));
                     taggingHelper.ReplaceKidHint(hintKey, intermediateKid);
                     if (symbolRenderer != null)
                     {
                         taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(symbolRenderer
                                                                                                                       ));
                     }
                     taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(this));
                 }
             }
         }
     }
     base.Draw(drawContext);
     // It will be null in case of overflow (only the "split" part will contain symbol renderer.
     if (symbolRenderer != null && !symbolAddedInside)
     {
         bool isRtl = BaseDirection.RIGHT_TO_LEFT.Equals(this.GetProperty <BaseDirection?>(Property.BASE_DIRECTION));
         symbolRenderer.SetParent(this);
         float x = isRtl ? occupiedArea.GetBBox().GetRight() : occupiedArea.GetBBox().GetLeft();
         ListSymbolPosition symbolPosition = (ListSymbolPosition)ListRenderer.GetListItemOrListProperty(this, parent
                                                                                                        , Property.LIST_SYMBOL_POSITION);
         if (symbolPosition != ListSymbolPosition.DEFAULT)
         {
             float?symbolIndent = this.GetPropertyAsFloat(Property.LIST_SYMBOL_INDENT);
             if (isRtl)
             {
                 x += (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent));
             }
             else
             {
                 x -= (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent));
             }
             if (symbolPosition == ListSymbolPosition.OUTSIDE)
             {
                 if (isRtl)
                 {
                     UnitValue marginRightUV = this.GetPropertyAsUnitValue(Property.MARGIN_RIGHT);
                     if (!marginRightUV.IsPointValue())
                     {
                         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
                         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property
                                                               .MARGIN_RIGHT));
                     }
                     x -= marginRightUV.GetValue();
                 }
                 else
                 {
                     UnitValue marginLeftUV = this.GetPropertyAsUnitValue(Property.MARGIN_LEFT);
                     if (!marginLeftUV.IsPointValue())
                     {
                         ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer));
                         logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property
                                                               .MARGIN_LEFT));
                     }
                     x += marginLeftUV.GetValue();
                 }
             }
         }
         ApplyMargins(occupiedArea.GetBBox(), false);
         ApplyBorderBox(occupiedArea.GetBBox(), false);
         if (childRenderers.Count > 0)
         {
             float?yLine = null;
             for (int i = 0; i < childRenderers.Count; i++)
             {
                 if (childRenderers[i].GetOccupiedArea().GetBBox().GetHeight() > 0)
                 {
                     yLine = ((AbstractRenderer)childRenderers[i]).GetFirstYLineRecursively();
                     if (yLine != null)
                     {
                         break;
                     }
                 }
             }
             if (yLine != null)
             {
                 if (symbolRenderer is LineRenderer)
                 {
                     symbolRenderer.Move(0, (float)yLine - ((LineRenderer)symbolRenderer).GetYLine());
                 }
                 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
         {
             if (symbolRenderer is TextRenderer)
             {
                 ((TextRenderer)symbolRenderer).MoveYLineTo(occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight
                                                                () - CalculateAscenderDescender()[0]);
             }
             else
             {
                 symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - symbolRenderer
                                     .GetOccupiedArea().GetBBox().GetHeight() - symbolRenderer.GetOccupiedArea().GetBBox().GetY());
             }
         }
         ApplyBorderBox(occupiedArea.GetBBox(), true);
         ApplyMargins(occupiedArea.GetBBox(), true);
         ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment)parent.GetProperty <ListSymbolAlignment?>(Property
                                                                                                                  .LIST_SYMBOL_ALIGNMENT, isRtl ? ListSymbolAlignment.LEFT : ListSymbolAlignment.RIGHT);
         float dxPosition = x - symbolRenderer.GetOccupiedArea().GetBBox().GetX();
         if (listSymbolAlignment == ListSymbolAlignment.RIGHT)
         {
             if (!isRtl)
             {
                 dxPosition += symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth();
             }
         }
         else
         {
             if (listSymbolAlignment == ListSymbolAlignment.LEFT)
             {
                 if (isRtl)
                 {
                     dxPosition -= (symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth());
                 }
             }
         }
         if (symbolRenderer is LineRenderer)
         {
             if (isRtl)
             {
                 symbolRenderer.Move(dxPosition - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth(), 0);
             }
             else
             {
                 symbolRenderer.Move(dxPosition, 0);
             }
         }
         else
         {
             symbolRenderer.Move(dxPosition, 0);
         }
         if (symbolRenderer.GetOccupiedArea().GetBBox().GetRight() > parent.GetOccupiedArea().GetBBox().GetLeft())
         {
             BeginElementOpacityApplying(drawContext);
             symbolRenderer.Draw(drawContext);
             EndElementOpacityApplying(drawContext);
         }
     }
 }
コード例 #10
0
        /// <summary>
        /// Performs the drawing operation for the border of this renderer, if
        /// defined by any of the
        /// <see cref="Property.BORDER"/>
        /// values in either the layout
        /// element or this
        /// <see cref="IRenderer"/>
        /// itself.
        /// </summary>
        /// <param name="drawContext">the context (canvas, document, etc) of this drawing operation.
        ///     </param>
        public virtual void DrawBorder(DrawContext drawContext)
        {
            Border[] borders    = GetBorders();
            bool     gotBorders = false;

            foreach (Border border in borders)
            {
                gotBorders = gotBorders || border != null;
            }
            if (gotBorders)
            {
                float     topWidth    = borders[0] != null ? borders[0].GetWidth() : 0;
                float     rightWidth  = borders[1] != null ? borders[1].GetWidth() : 0;
                float     bottomWidth = borders[2] != null ? borders[2].GetWidth() : 0;
                float     leftWidth   = borders[3] != null ? borders[3].GetWidth() : 0;
                Rectangle bBox        = GetBorderAreaBBox();
                if (bBox.GetWidth() <= 0 || bBox.GetHeight() <= 0)
                {
                    ILogger logger = LoggerFactory.GetLogger(typeof(iText.Layout.Renderer.AbstractRenderer
                                                                    ));
                    logger.Error(String.Format(LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES
                                               , "border"));
                    return;
                }
                float     x1       = bBox.GetX();
                float     y1       = bBox.GetY();
                float     x2       = bBox.GetX() + bBox.GetWidth();
                float     y2       = bBox.GetY() + bBox.GetHeight();
                bool      isTagged = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement;
                PdfCanvas canvas   = drawContext.GetCanvas();
                if (isTagged)
                {
                    canvas.OpenTag(new CanvasArtifact());
                }
                if (borders[0] != null)
                {
                    canvas.SaveState();
                    borders[0].Draw(canvas, x1, y2, x2, y2, leftWidth, rightWidth);
                    canvas.RestoreState();
                }
                if (borders[1] != null)
                {
                    canvas.SaveState();
                    borders[1].Draw(canvas, x2, y2, x2, y1, topWidth, bottomWidth);
                    canvas.RestoreState();
                }
                if (borders[2] != null)
                {
                    canvas.SaveState();
                    borders[2].Draw(canvas, x2, y1, x1, y1, rightWidth, leftWidth);
                    canvas.RestoreState();
                }
                if (borders[3] != null)
                {
                    canvas.SaveState();
                    borders[3].Draw(canvas, x1, y1, x1, y2, bottomWidth, topWidth);
                    canvas.RestoreState();
                }
                if (isTagged)
                {
                    canvas.CloseTag();
                }
            }
        }