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(); } }
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; }
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); } }