/// <summary> /// Returns a <code>Shape</code> whose interior corresponds to the /// visual representation of the specified glyph /// within this <code>GlyphVector</code>, offset to x, y. /// The outline returned by this method is positioned around the /// origin of each individual glyph. </summary> /// <param name="glyphIndex"> the index into this <code>GlyphVector</code> </param> /// <param name="x"> the X coordinate of the location of this {@code GlyphVector} </param> /// <param name="y"> the Y coordinate of the location of this {@code GlyphVector} </param> /// <returns> a <code>Shape</code> that is the outline of the glyph /// at the specified <code>glyphIndex</code> of this /// <code>GlyphVector</code> when rendered at the specified /// coordinates. </returns> /// <exception cref="IndexOutOfBoundsException"> if <code>glyphIndex</code> /// is less than 0 or greater than or equal to the number /// of glyphs in this <code>GlyphVector</code> /// @since 1.4 </exception> public virtual Shape GetGlyphOutline(int glyphIndex, float x, float y) { Shape s = GetGlyphOutline(glyphIndex); AffineTransform at = AffineTransform.GetTranslateInstance(x, y); return(at.CreateTransformedShape(s)); }
public virtual void MixedWhiteSpace() { AffineTransform actual = TransformUtils.ParseTransform(" translate(1) translate(2) "); AffineTransform expected = AffineTransform.GetTranslateInstance(2.25, 0); NUnit.Framework.Assert.AreEqual(expected, actual); }
/// <exception cref="System.Exception"/> private static byte[] CreatePdfWithRotatedText(String text1, String text2, float rotation, bool moveTextToNextLine , float moveTextDelta) { MemoryStream byteStream = new MemoryStream(); PdfDocument document = new PdfDocument(new PdfWriter(byteStream)); document.SetDefaultPageSize(new PageSize(612, 792)); PdfCanvas canvas = new PdfCanvas(document.AddNewPage()); PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA); float x = document.GetDefaultPageSize().GetWidth() / 2; float y = document.GetDefaultPageSize().GetHeight() / 2; canvas.ConcatMatrix(AffineTransform.GetTranslateInstance(x, y)); canvas.MoveTo(-10, 0).LineTo(10, 0).MoveTo(0, -10).LineTo(0, 10).Stroke(); canvas.BeginText().SetFontAndSize(font, 12).ConcatMatrix(AffineTransform.GetRotateInstance((float)(rotation / 180f * Math.PI))).ShowText(text1); if (moveTextToNextLine) { canvas.MoveText(0, moveTextDelta); } else { canvas.ConcatMatrix(AffineTransform.GetTranslateInstance(moveTextDelta, 0)); } canvas.ShowText(text2); canvas.EndText(); document.Close(); return(byteStream.ToArray()); }
private static byte[] CreatePdfWithArrayText(String directContentTj) { MemoryStream byteStream = new MemoryStream(); Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, byteStream); document.SetPageSize(PageSize.LETTER); document.Open(); PdfContentByte cb = writer.DirectContent; BaseFont font = BaseFont.CreateFont(); cb.Transform(AffineTransform.GetTranslateInstance(100, 500)); cb.BeginText(); cb.SetFontAndSize(font, 12); cb.InternalBuffer.Append(directContentTj + "\n"); cb.EndText(); document.Close(); byte[] pdfBytes = byteStream.ToArray(); return(pdfBytes); }
private void DrawText(PdfWriter writer, string text, int fontSize, BaseColor color, double x, double y, bool vertical) { AffineTransform textTransform = AffineTransform.GetTranslateInstance(x, y); if (vertical) { textTransform.Rotate(Math.PI / 2); } //writer.DirectContent.Transform(rotate90); PdfContentByte cb = writer.DirectContent; cb.BeginText(); ////BaseFont textFont = BaseFont.CreateFont("Arial", BaseFont.CP1252, true); cb.SetColorStroke(color); cb.SetColorFill(color); cb.SetFontAndSize(SearchTextFont.GetCalculatedBaseFont(false), fontSize); cb.SetTextMatrix(textTransform); //(xPos, yPos) cb.ShowText(text); cb.EndText(); }
protected void ManipulatePdf(String dest) { PdfDocument srcDoc = new PdfDocument(new PdfReader(SRC)); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest)); float a4Width = PageSize.A4.GetWidth(); float a4Height = PageSize.A4.GetHeight(); PageSize pagesize = new PageSize(a4Width * 4, a4Height * 2); pdfDoc.SetDefaultPageSize(pagesize); int numberOfPages = srcDoc.GetNumberOfPages(); int p = 1; PdfCanvas canvas = new PdfCanvas(pdfDoc.AddNewPage()); while ((p - 1) <= numberOfPages) { CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 3, 0); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 12, a4Width); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 15, a4Width * 2); CopyPageToDoc(canvas, srcDoc, pdfDoc, p, a4Width * 3); canvas.SaveState(); // Rotate on 180 degrees and copy pages to the top row. AffineTransform at = AffineTransform.GetRotateInstance((float)-Math.PI); at.Concatenate(AffineTransform.GetTranslateInstance(0, -a4Height * 2)); canvas.ConcatMatrix(at); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 4, -a4Width); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 11, -a4Width * 2); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 8, -a4Width * 3); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 7, -a4Width * 4); canvas.RestoreState(); canvas = new PdfCanvas(pdfDoc.AddNewPage()); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 1, 0); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 14, a4Width); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 13, a4Width * 2); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 2, a4Width * 3); canvas.SaveState(); // Rotate on 180 degrees and copy pages to the top row. canvas.ConcatMatrix(at); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 6, -a4Width); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 9, -a4Width * 2); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 10, -a4Width * 3); CopyPageToDoc(canvas, srcDoc, pdfDoc, p + 5, -a4Width * 4); canvas.RestoreState(); if ((p - 1) / 16 < numberOfPages / 16) { canvas = new PdfCanvas(pdfDoc.AddNewPage()); } p += 16; } pdfDoc.Close(); srcDoc.Close(); }
/// <summary>Calculate the transformation for the viewport based on the context.</summary> /// <remarks> /// Calculate the transformation for the viewport based on the context. Only used by elements that can create /// viewports /// </remarks> /// <param name="context">the SVG draw context</param> /// <returns>the transformation that needs to be applied to this renderer</returns> internal virtual AffineTransform CalculateViewPortTranslation(SvgDrawContext context) { Rectangle viewPort = context.GetCurrentViewPort(); AffineTransform transform; transform = AffineTransform.GetTranslateInstance(viewPort.GetX(), viewPort.GetY()); return(transform); }
private static AffineTransform CreateGradientTransform(Rectangle2D r) { double cx = r.CenterX; double cy = r.CenterY; AffineTransform xform = AffineTransform.GetTranslateInstance(cx, cy); xform.Scale(r.Width / 2, r.Height / 2); xform.Translate(-cx, -cy); return(xform); }
private static Point[] GetRotatedSquareVertices(Point[] orthogonalSquareVertices, double angle, Point squareCenter ) { Point[] rotatedSquareVertices = new Point[orthogonalSquareVertices.Length]; AffineTransform.GetRotateInstance((float)angle).Transform(orthogonalSquareVertices, 0, rotatedSquareVertices , 0, rotatedSquareVertices.Length); AffineTransform.GetTranslateInstance((float)squareCenter.GetX(), (float)squareCenter.GetY()).Transform(rotatedSquareVertices , 0, rotatedSquareVertices, 0, orthogonalSquareVertices.Length); return(rotatedSquareVertices); }
/// <summary>Creates a translate transformation.</summary> /// <param name="values">values of the transformation</param> /// <returns>AffineTransform for the translate operation</returns> private static AffineTransform CreateTranslateTransformation(IList <String> values) { if (values.Count == 0 || values.Count > 2) { throw new SvgProcessingException(SvgLogMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES); } float translateX = CssUtils.ParseAbsoluteLength(values[0]); float translateY = values.Count == 2 ? CssUtils.ParseAbsoluteLength(values[1]) : 0; return(AffineTransform.GetTranslateInstance(translateX, translateY)); }
private void ApplyCoordinatesTranslation(SvgDrawContext context) { float xScale = 1; float yScale = 1; if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.VIEWBOX)) { //Parse viewbox parameters stuff String viewBoxValues = attributesAndStyles.Get(SvgConstants.Attributes.VIEWBOX); IList <String> valueStrings = SvgCssUtils.SplitValueList(viewBoxValues); float[] viewBox = GetViewBoxValues(); xScale = context.GetCurrentViewPort().GetWidth() / viewBox[2]; yScale = context.GetCurrentViewPort().GetHeight() / viewBox[3]; } float moveX = DEFAULT_REF_X; if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.REFX)) { String refX = this.attributesAndStyles.Get(SvgConstants.Attributes.REFX); if (CssUtils.IsPercentageValue(refX)) { moveX = CssUtils.ParseRelativeValue(refX, context.GetRootViewPort().GetWidth()); } else { moveX = ParseFontRelativeOrAbsoluteLengthOnMarker(refX); } //Apply scale moveX *= -1 * xScale; } float moveY = DEFAULT_REF_Y; if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.REFY)) { String refY = this.attributesAndStyles.Get(SvgConstants.Attributes.REFY); if (CssUtils.IsPercentageValue(refY)) { moveY = CssUtils.ParseRelativeValue(refY, context.GetRootViewPort().GetHeight()); } else { moveY = ParseFontRelativeOrAbsoluteLengthOnMarker(refY); } moveY *= -1 * yScale; } AffineTransform translation = AffineTransform.GetTranslateInstance(moveX, moveY); if (!translation.IsIdentity()) { context.GetCurrentCanvas().ConcatMatrix(translation); } }
internal virtual AffineTransform CalculateTransformation(SvgDrawContext context) { Rectangle viewPort = context.GetCurrentViewPort(); float horizontal = viewPort.GetX(); float vertical = viewPort.GetY() + viewPort.GetHeight(); // flip coordinate space vertically and translate on the y axis with the viewport height AffineTransform transform = AffineTransform.GetTranslateInstance(0, 0); //Identity-transform transform.Concatenate(AffineTransform.GetTranslateInstance(horizontal, vertical)); transform.Concatenate(new AffineTransform(1, 0, 0, -1, 0, 0)); return(transform); }
// --------------------------------------------------------------------------- /** * Creates a PDF document. */ public byte[] CreatePdf() { // step 1 Rectangle rect = new Rectangle(-595, -842, 595, 842); using (MemoryStream ms = new MemoryStream()) { using (Document document = new Document(rect)) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, ms); // step 3 document.Open(); // step 4 PdfContentByte canvas = writer.DirectContent; // draw coordinate system canvas.MoveTo(-595, 0); canvas.LineTo(595, 0); canvas.MoveTo(0, -842); canvas.LineTo(0, 842); canvas.Stroke(); // read the PDF with the logo PdfReader reader = new PdfReader(RESOURCE); PdfTemplate template = writer.GetImportedPage(reader, 1); // add it canvas.SaveState(); canvas.AddTemplate(template, 0, 0); AffineTransform af = new AffineTransform(); af.Translate(-595, 0); af.Scale(0.5f, 0.5f); canvas.Transform(af); canvas.AddTemplate(template, 0, 0); canvas.ConcatCTM(AffineTransform.GetTranslateInstance(595, 595)); canvas.AddTemplate(template, 0, 0); canvas.RestoreState(); canvas.SaveState(); af = new AffineTransform(1f, 0f, 0.4f, 1f, -750f, -650f); canvas.AddTemplate(template, af); canvas.RestoreState(); canvas.SaveState(); af = new AffineTransform(0, -1, -1, 0, 650, 0); canvas.AddTemplate(template, af); af = new AffineTransform(0, -0.2f, -0.5f, 0, 350, 0); canvas.AddTemplate(template, af); canvas.RestoreState(); } return(ms.ToArray()); } }
public virtual void BuilderWithNoneSpreadingAndCanvasTransformTest() { AbstractLinearGradientBuilder gradientBuilder = new StrategyBasedLinearGradientBuilder().SetGradientDirectionAsStrategy (StrategyBasedLinearGradientBuilder.GradientStrategy.TO_RIGHT).SetSpreadMethod(GradientSpreadMethod.NONE ).AddColorStop(new GradientColorStop(ColorConstants.RED.GetColorValue(), 0d, GradientColorStop.OffsetType .RELATIVE)).AddColorStop(new GradientColorStop(ColorConstants.GREEN.GetColorValue(), 0.5, GradientColorStop.OffsetType .RELATIVE)).AddColorStop(new GradientColorStop(ColorConstants.BLUE.GetColorValue(), 1d, GradientColorStop.OffsetType .RELATIVE)); AffineTransform canvasTransform = AffineTransform.GetTranslateInstance(50, -50); canvasTransform.Scale(0.8, 1.1); canvasTransform.Rotate(Math.PI / 3, 400f, 550f); GenerateAndComparePdfs("builderWithNoneSpreadingAndCanvasTransformTest.pdf", canvasTransform, gradientBuilder ); }
/// <summary> /// This method creates /// <see cref="iText.Kernel.Geom.AffineTransform"/> /// instance that could be used /// to rotate content inside the occupied area. Be aware that it should be used only after /// layout rendering is finished and correct occupied area for the rotated element is calculated. /// </summary> /// <returns> /// /// <see cref="iText.Kernel.Geom.AffineTransform"/> /// that rotates the content and places it inside occupied area. /// </returns> protected internal virtual AffineTransform CreateRotationTransformInsideOccupiedArea() { float? angle = this.GetProperty <float?>(Property.ROTATION_ANGLE); AffineTransform rotationTransform = AffineTransform.GetRotateInstance((float)angle); Rectangle contentBox = this.GetOccupiedAreaBBox(); IList <Point> rotatedContentBoxPoints = TransformPoints(RectangleToPointsList(contentBox), rotationTransform ); // Occupied area for rotated elements is already calculated on layout in such way to enclose rotated content; // therefore we can simply rotate content as is and then shift it to the occupied area. float[] shift = CalculateShiftToPositionBBoxOfPointsAt(occupiedArea.GetBBox().GetLeft(), occupiedArea.GetBBox ().GetTop(), rotatedContentBoxPoints); rotationTransform.PreConcatenate(AffineTransform.GetTranslateInstance(shift[0], shift[1])); return(rotationTransform); }
private static byte[] CreatePdfWithRotatedText(String text1, String text2, float rotation, bool moveTextToNextLine, float moveTextDelta) { MemoryStream byteStream = new MemoryStream(); Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, byteStream); document.SetPageSize(PageSize.LETTER); document.Open(); PdfContentByte cb = writer.DirectContent; BaseFont font = BaseFont.CreateFont(); float x = document.PageSize.Width / 2; float y = document.PageSize.Height / 2; cb.Transform(AffineTransform.GetTranslateInstance(x, y)); cb.MoveTo(-10, 0); cb.LineTo(10, 0); cb.MoveTo(0, -10); cb.LineTo(0, 10); cb.Stroke(); cb.BeginText(); cb.SetFontAndSize(font, 12); cb.Transform(AffineTransform.GetRotateInstance(rotation / 180f * Math.PI)); cb.ShowText(text1); if (moveTextToNextLine) { cb.MoveText(0, moveTextDelta); } else { cb.Transform(AffineTransform.GetTranslateInstance(moveTextDelta, 0)); } cb.ShowText(text2); cb.EndText(); document.Close(); byte[] pdfBytes = byteStream.ToArray(); return(pdfBytes); }
private static AffineTransform GetTextTransform(float[][] absolutePositions, SvgDrawContext context) { AffineTransform tf = new AffineTransform(); //If x is not specified, but y is, we need to correct for preceding text. if (absolutePositions[0] == null && absolutePositions[1] != null) { absolutePositions[0] = new float[] { context.GetTextMove()[0] }; } //If y is not present, we can replace it with a neutral transformation (0.0f) if (absolutePositions[1] == null) { absolutePositions[1] = new float[] { 0.0f }; } tf.Concatenate(TEXTFLIP); tf.Concatenate(AffineTransform.GetTranslateInstance(absolutePositions[0][0], -absolutePositions[1][0])); return(tf); }
private void AddLinearGradientITextAPIApproach(PdfDocument pdfDoc) { AbstractLinearGradientBuilder gradientBuilder = new StrategyBasedLinearGradientBuilder() .SetGradientDirectionAsStrategy(StrategyBasedLinearGradientBuilder.GradientStrategy.TO_TOP_RIGHT) .SetSpreadMethod(GradientSpreadMethod.PAD) .AddColorStop(new GradientColorStop(ColorConstants.CYAN.GetColorValue())) .AddColorStop(new GradientColorStop(ColorConstants.GREEN.GetColorValue())) .AddColorStop(new GradientColorStop(new float[] { 1f, 0f, 0f }, 0.5f, GradientColorStop.OffsetType.RELATIVE)); AffineTransform canvasTransform = AffineTransform.GetTranslateInstance(50, -50); canvasTransform.Scale(0.8, 1.1); canvasTransform.Rotate(Math.PI / 3, 400f, 550f); Rectangle rectangleToDraw = new Rectangle(50f, 450f, 500f, 300f); GeneratePdf(pdfDoc, canvasTransform, gradientBuilder, rectangleToDraw); }
protected void ManipulatePdf(String dest) { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); ImageData image = ImageDataFactory.Create(IMG); // Translation defines the position of the image on the page and scale transformation sets image dimensions // Please also note that image without scaling is drawn in 1x1 rectangle. And here we draw image on page using // its original size in pixels. AffineTransform affineTransform = AffineTransform.GetTranslateInstance(36, 300); // Make sure that the image is visible by concatenating a scale transformation affineTransform.Concatenate(AffineTransform.GetScaleInstance(image.GetWidth(), image.GetHeight())); PdfCanvas canvas = new PdfCanvas(pdfDoc.GetFirstPage()); float[] matrix = new float[6]; affineTransform.GetMatrix(matrix); canvas.AddImageWithTransformationMatrix(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); pdfDoc.Close(); }
public void BarcodeTest01() { String filename = "barcodeDataMatrix01.pdf"; String code = "AAAAAAAAAA;BBBBAAAA3;00028;BBBAA05;AAAA;AAAAAA;1234567;AQWXSZ;JEAN;;;;7894561;AQWXSZ;GEO;;;;1;1;1;1;0;0;1;0;1;0;0;0;1;0;1;0;0;0;0;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 01")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Generate(code); barcode.PlaceBarcode(cb, BaseColor.GREEN, 5, 5); document.Close(); CompareDocuments(filename); }
private AffineTransform CreateTransform(PdfImportedPage page, int rotation, Rectangle initialPageSize, bool autoResize) { var docWidth = _docContent.Right - _docContent.Left; var docHeight = _docContent.Top - _docContent.Bottom; AffineTransform rotate = AffineTransform.GetRotateInstance((Math.PI * (360 - rotation)) / 180, 0, 0); AffineTransform scale = AffineTransform.GetScaleInstance(docWidth / page.Width, docHeight / page.Height); AffineTransform translateMargin = AffineTransform.GetTranslateInstance(_docContent.LeftMargin - page.BoundingBox.Left + initialPageSize.Left, _docContent.BottomMargin - page.BoundingBox.Bottom + initialPageSize.Bottom); AffineTransform translateRotate = AffineTransform.GetTranslateInstance(0, 0); if (rotation % 180 == 90) { scale = AffineTransform.GetScaleInstance(docWidth / page.Height, docHeight / page.Width); translateRotate = AffineTransform.GetTranslateInstance((rotation % 360 == 270) ? page.Height : 0, (rotation % 360 == 90) ? page.Width : 0); } else if (rotation % 360 == 180) { translateRotate = AffineTransform.GetTranslateInstance(page.Width, page.Height);; } AffineTransform transform = AffineTransform.GetTranslateInstance(0, 0); if (autoResize) { transform.preConcatenate(translateMargin); } transform.preConcatenate(rotate); transform.preConcatenate(translateRotate); if (autoResize) { transform.preConcatenate(scale); } return(transform); }
public void BarcodeTest02() { String filename = "barcodeDataMatrix02.pdf"; String code = "дима"; String encoding = "UTF-8"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 02")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Generate(code, encoding); barcode.PlaceBarcode(cb, BaseColor.GREEN, 5, 5); document.Close(); CompareDocuments(filename); }
public void BarcodeTest04() { String filename = "barcodeDataMatrix04.pdf"; String code = "01AbcdefgAbcdefg123451231231234"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 04")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Width = 36; barcode.Height = 12; barcode.Generate(code); barcode.PlaceBarcode(cb, BaseColor.BLACK, 5, 5); document.Close(); CompareDocuments(filename); }
protected internal override void DoDraw(SvgDrawContext context) { if (this.attributesAndStyles != null) { String elementToReUse = this.attributesAndStyles.Get(SvgConstants.Attributes.XLINK_HREF); if (elementToReUse == null) { elementToReUse = this.attributesAndStyles.Get(SvgConstants.Attributes.HREF); } if (elementToReUse != null && !String.IsNullOrEmpty(elementToReUse) && IsValidHref(elementToReUse)) { String normalizedName = SvgTextUtil.FilterReferenceValue(elementToReUse); if (!context.IsIdUsedByUseTagBefore(normalizedName)) { ISvgNodeRenderer template = context.GetNamedObject(normalizedName); //Clone template ISvgNodeRenderer namedObject = template == null ? null : template.CreateDeepCopy(); //Resolve parent inheritance SvgNodeRendererInheritanceResolver iresolver = new SvgNodeRendererInheritanceResolver(); iresolver.ApplyInheritanceToSubTree(this, namedObject); if (namedObject != null) { if (namedObject is AbstractSvgNodeRenderer) { ((AbstractSvgNodeRenderer)namedObject).SetPartOfClipPath(partOfClipPath); } PdfCanvas currentCanvas = context.GetCurrentCanvas(); float x = 0f; float y = 0f; if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.X)) { x = CssUtils.ParseAbsoluteLength(this.attributesAndStyles.Get(SvgConstants.Attributes.X)); } if (this.attributesAndStyles.ContainsKey(SvgConstants.Attributes.Y)) { y = CssUtils.ParseAbsoluteLength(this.attributesAndStyles.Get(SvgConstants.Attributes.Y)); } AffineTransform inverseMatrix = null; if (!CssUtils.CompareFloats(x, 0) || !CssUtils.CompareFloats(y, 0)) { AffineTransform translation = AffineTransform.GetTranslateInstance(x, y); currentCanvas.ConcatMatrix(translation); if (partOfClipPath) { try { inverseMatrix = translation.CreateInverse(); } catch (NoninvertibleTransformException ex) { LogManager.GetLogger(typeof(UseSvgNodeRenderer)).Warn(SvgLogMessageConstant.NONINVERTIBLE_TRANSFORMATION_MATRIX_USED_IN_CLIP_PATH , ex); } } } // setting the parent of the referenced element to this instance namedObject.SetParent(this); namedObject.Draw(context); // unsetting the parent of the referenced element namedObject.SetParent(null); if (inverseMatrix != null) { currentCanvas.ConcatMatrix(inverseMatrix); } } } } } }