iTextSharp.text.pdf.parser.TextRenderInfo.GetSingleSpaceWidth C# (CSharp) Метод

GetSingleSpaceWidth() публичный Метод

public GetSingleSpaceWidth ( ) : float
Результат float
        public float GetSingleSpaceWidth()
        {
            return ConvertWidthFromTextSpaceToUserSpace(GetUnscaledFontSpaceWidth());
        }

Usage Example

        /**
         * Captures text using a simplified algorithm for inserting hard returns and spaces
         * @param   renderInfo  render info
         */
        public virtual void RenderText(TextRenderInfo renderInfo)
        {
            bool firstRender = result.Length == 0;
            bool hardReturn  = false;

            LineSegment segment = renderInfo.GetBaseline();
            Vector      start   = segment.GetStartPoint();
            Vector      end     = segment.GetEndPoint();

            if (!firstRender)
            {
                Vector x0 = start;
                Vector x1 = lastStart;
                Vector x2 = lastEnd;

                // see http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
                float dist = (x2.Subtract(x1)).Cross((x1.Subtract(x0))).LengthSquared / x2.Subtract(x1).LengthSquared;

                float sameLineThreshold = 1f; // we should probably base this on the current font metrics, but 1 pt seems to be sufficient for the time being
                if (dist > sameLineThreshold)
                {
                    hardReturn = true;
                }

                // Note:  Technically, we should check both the start and end positions, in case the angle of the text changed without any displacement
                // but this sort of thing probably doesn't happen much in reality, so we'll leave it alone for now
            }

            if (hardReturn)
            {
                //System.out.Println("<< Hard Return >>");
                AppendTextChunk('\n');
            }
            else if (!firstRender)
            {
                if (result[result.Length - 1] != ' ' && renderInfo.GetText().Length > 0 && renderInfo.GetText()[0] != ' ') // we only insert a blank space if the trailing character of the previous string wasn't a space, and the leading character of the current string isn't a space
                {
                    float spacing = lastEnd.Subtract(start).Length;
                    if (spacing > renderInfo.GetSingleSpaceWidth() / 2f)
                    {
                        AppendTextChunk(' ');
                        //System.out.Println("Inserting implied space before '" + renderInfo.GetText() + "'");
                    }
                }
            }
            else
            {
                //System.out.Println("Displaying first string of content '" + text + "' :: x1 = " + x1);
            }

            //System.out.Println("[" + renderInfo.GetStartPoint() + "]->[" + renderInfo.GetEndPoint() + "] " + renderInfo.GetText());
            AppendTextChunk(renderInfo.GetText());

            lastStart = start;
            lastEnd   = end;
        }
All Usage Examples Of iTextSharp.text.pdf.parser.TextRenderInfo::GetSingleSpaceWidth