/// <summary>Provides detail useful if a listener needs access to the position of each individual glyph in the text render operation /// </summary> /// <returns> /// A list of /// <see cref="TextRenderInfo"/> /// objects that represent each glyph used in the draw operation. The next effect is if there was a separate Tj opertion for each character in the rendered string /// </returns> public virtual IList <iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo> GetCharacterRenderInfos() { IList <iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo> rslt = new List <iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo >(@string.GetValue().Length); PdfString[] strings = SplitString(@string); float totalWidth = 0; foreach (PdfString str in strings) { float[] widthAndWordSpacing = GetWidthAndWordSpacing(str); iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo subInfo = new iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo (this, str, totalWidth); rslt.Add(subInfo); totalWidth += (widthAndWordSpacing[0] * gs.GetFontSize() + gs.GetCharSpacing() + widthAndWordSpacing[1]) * (gs.GetHorizontalScaling() / 100f); } foreach (iText.Kernel.Pdf.Canvas.Parser.Data.TextRenderInfo tri in rslt) { tri.GetUnscaledWidth(); } return(rslt); }
private void WriteText(String @operator, IList <PdfObject> operands, PdfArray cleanedText, PdfCanvas canvas ) { CanvasGraphicsState canvasGs = canvas.GetGraphicsState(); bool newLineShowText = "'".Equals(@operator) || "\"".Equals(@operator); if (newLineShowText) { if (canvasGs.GetLeading() != currLeading) { canvas.SetLeading((float)currLeading); } // after new line operator, removed text shift doesn't matter removedTextShift = null; } PdfTextArray tjShiftArray = null; if (removedTextShift != null) { float tjShift = (float)removedTextShift * 1000 / (canvasGs.GetFontSize() * canvasGs.GetHorizontalScaling() / 100); tjShiftArray = new PdfTextArray(); tjShiftArray.Add(new PdfNumber(tjShift)); } if (cleanedText != null) { if (newLineShowText) { // char spacing and word spacing are set via writeNotAppliedTextStateParams() method canvas.NewlineText(); } if (removedTextShift != null) { tjShiftArray.AddAll(cleanedText); cleanedText = tjShiftArray; } canvas.ShowText(cleanedText); } else { if (removedTextShift != null) { canvas.ShowText(tjShiftArray); } PdfCleanUpProcessor.WriteOperands(canvas, operands); } }