当前位置: 首页>>代码示例>>C#>>正文


C# parser.TextRenderInfo类代码示例

本文整理汇总了C#中iTextSharp.text.pdf.parser.TextRenderInfo的典型用法代码示例。如果您正苦于以下问题:C# TextRenderInfo类的具体用法?C# TextRenderInfo怎么用?C# TextRenderInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextRenderInfo类属于iTextSharp.text.pdf.parser命名空间,在下文中一共展示了TextRenderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetColor

 /// <summary>
 /// Determines the color that will mark the text snippet based on the
 /// position of the snippet (in case it's an artifact) or it's style
 /// (font name and size).
 /// </summary>
 /// <param name="textRenderInfo">the TextRenderInfo object</param>
 /// <param name="top">the Y position of the top margin</param>
 /// <returns>a color that will be used to mark the text snippet</returns>
 static BaseColor GetColor(TextRenderInfo textRenderInfo, float top)
 {
     if (textRenderInfo.GetBaseline().GetStartPoint()[1] > top)
         return artifactColor;
     TextStyle ts = new TextStyle(textRenderInfo);
     return textStyles[ts];
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:15,代码来源:TextItem.cs

示例2: RenderText

 /**
  * Applies filters, then delegates to the deleg if all filters pass
  * @param renderInfo contains info to render text
  * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo)
  */
 public void RenderText(TextRenderInfo renderInfo) {
     foreach (RenderFilter filter in filters) {
         if (!filter.AllowText(renderInfo))
             return;
     }
     deleg.RenderText(renderInfo);
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:12,代码来源:FilteredRenderListener.cs

示例3: RenderText

 /// Captures text using a simplified algorithm for inserting hard returns and spaces
 ///             @param   renderInfo  render info
 public virtual void RenderText(TextRenderInfo renderInfo)
 {
     _blocks.Add(new TextBlock
     {
         Text = renderInfo.GetText(),
         TopLeft = renderInfo.GetBaseline().GetStartPoint(),
         BottomRight = renderInfo.GetBaseline().GetEndPoint()
     });
 }
开发者ID:fsol,项目名称:Statement-Reader,代码行数:11,代码来源:TextExtractionStrategyForBlockList.cs

示例4: RenderText

        /**
         * Method invokes by the PdfContentStreamProcessor.
         * Passes a TextRenderInfo for every text chunk that is encountered.
         * We'll use this object to obtain coordinates.
         * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo)
         */
        virtual public void RenderText(TextRenderInfo renderInfo) {
            if (textRectangle == null)
                textRectangle = renderInfo.GetDescentLine().GetBoundingRectange();
            else
                textRectangle.Add(renderInfo.GetDescentLine().GetBoundingRectange());
            
            textRectangle.Add(renderInfo.GetAscentLine().GetBoundingRectange());

        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:15,代码来源:TextMarginFinder.cs

示例5: RenderText

 /// <summary>
 /// <see cref="IRenderListener.RenderText"/>
 /// </summary>
 public void RenderText(TextRenderInfo renderInfo)
 {
     output.WriteLine("    <");
     Vector start = renderInfo.GetBaseline().GetStartPoint();
     output.WriteLine(String.Format("        x: {0} y: {1} length: {2} \n        Text: {3}",
         start[Vector.I1], start[Vector.I2],
         renderInfo.GetBaseline().GetLength(),
         renderInfo.GetText()));
     output.WriteLine("    >");
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:13,代码来源:MyTextRenderListener.cs

示例6: TextStyle

 /// <summary>
 /// Creates a TextStyle object by getting the font name and font size
 /// from a TextRenderInfo object.
 /// </summary>
 /// <param name="textRenderInfo">Object that contains info about a text snippet</param>
 public TextStyle(TextRenderInfo textRenderInfo)
 {
     String font = textRenderInfo.GetFont().FullFontName[0][3];
     if (font.Contains("+"))
         font = font.Substring(font.IndexOf("+") + 1, font.Length - font.IndexOf("+") - 1);
     if (font.Contains("-"))
         font = font.Substring(0, font.IndexOf("-"));
     this.fontName = font;
     this.fontSize = textRenderInfo.GetAscentLine().GetStartPoint()[1] - textRenderInfo.GetDescentLine().GetStartPoint()[1];
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:15,代码来源:TextStyle.cs

示例7: GetRectangle

 /// <summary>
 /// Stores the start and end points and the ascent and descent info from
 /// a text snippet into a Rectangle object.
 /// </summary>
 /// <param name="textRenderInfo">Object that contains info about a text snippet</param>
 /// <returns>coordinates in the form of a Rectangle object</returns>
 static Rectangle GetRectangle(TextRenderInfo textRenderInfo)
 {
     LineSegment descentLine = textRenderInfo.GetDescentLine();
     LineSegment ascentLine = textRenderInfo.GetAscentLine();
     float x0 = descentLine.GetStartPoint()[0];
     float x1 = descentLine.GetEndPoint()[0];
     float y0 = descentLine.GetStartPoint()[1];
     float y1 = ascentLine.GetEndPoint()[1];
     return new Rectangle(x0, y0, x1, y1);
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:16,代码来源:TextItemSimple.cs

示例8: RenderText

        public void RenderText(TextRenderInfo renderInfo)
        {
            bool hardReturn = false;

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

            if (lastStart != null && lastEnd != null)
            {
                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 >>");
                result.Append('\n');
            }
            else if (lastStart != null && lastEnd != null)
            {
                if (result[result.Length - 1] != ' ' && 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)
                    {
                        result.Append('\t');
                        //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());
            result.Append(renderInfo.GetText());

            lastStart = start;
            lastEnd = end;
        }
开发者ID:Thinking-Beard,项目名称:civilsalary,代码行数:53,代码来源:TableTextExtractionStrategy.cs

示例9: AllowText

 /** 
  * @see com.itextpdf.text.pdf.parser.RenderFilter#allowText(com.itextpdf.text.pdf.parser.TextRenderInfo)
  */
 public override bool AllowText(TextRenderInfo renderInfo){
     LineSegment segment = renderInfo.GetBaseline();
     Vector startPoint = segment.GetStartPoint();
     Vector endPoint = segment.GetEndPoint();
     
     float x1 = startPoint[Vector.I1];
     float y1 = startPoint[Vector.I2];
     float x2 = endPoint[Vector.I1];
     float y2 = endPoint[Vector.I2];
     
     return filterRect.IntersectsLine(x1, y1, x2, y2);
 }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例10: TextItem

        /// <summary>
        /// Creates a TextItem based on a TextRenderInfo object.
        /// </summary>
        /// <param name="textRenderInfo">the TextRenderInfo object</param>
        /// <param name="top">the Y coordinate of the top margin</param>
        public TextItem(TextRenderInfo textRenderInfo, float top)
        {
            textStyles.Add(new TextStyle("FranklinGothic", 10.5f), BaseColor.ORANGE);
            textStyles.Add(new TextStyle("FranklinGothic", 8f), BaseColor.GREEN);
            textStyles.Add(new TextStyle("NewBaskerville", 10f), BaseColor.BLUE);
            textStyles.Add(new TextStyle("Courier", 9.5f), BaseColor.BLUE);
            textStyles.Add(new TextStyle("CombiNumerals", 13.5f), BaseColor.PINK);
        

            baseline = textRenderInfo.GetBaseline().GetStartPoint()[1];
            rectangle = GetRectangle(textRenderInfo);
            color = GetColor(textRenderInfo, top);
        }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:18,代码来源:TextItem.cs

示例11: RenderText

            public void RenderText(TextRenderInfo renderInfo)
            {
                List<TextRenderInfo> subs = renderInfo.GetCharacterRenderInfos();
                TextRenderInfo previousCharInfo = subs[0];

                for (int i = 1; i < subs.Count; i++)
                {
                    TextRenderInfo charInfo = subs[i];
                    Vector previousEndPoint = previousCharInfo.GetBaseline().GetEndPoint();
                    Vector currentStartPoint = charInfo.GetBaseline().GetStartPoint();
                    AssertVectorsEqual(previousEndPoint, currentStartPoint, charInfo.GetText());
                    previousCharInfo = charInfo;
                }

            }
开发者ID:smartleos,项目名称:itextsharp,代码行数:15,代码来源:TextRenderInfoTest.cs

示例12: RenderText

        public void RenderText(TextRenderInfo renderInfo)
        {
            bool firstRender = results.Count == 0;

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

            int currentLineKey = (int)start[1];

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

                float dist = (x2.Subtract(x1)).Cross((x1.Subtract(x0))).LengthSquared / x2.Subtract(x1).LengthSquared;

                float sameLineThreshold = 1f;
                if (dist <= sameLineThreshold)
                {
                    currentLineKey = (int)lastStart[1];
                }
            }

            currentLineKey = currentLineKey * -1;
            if (!results.ContainsKey(currentLineKey))
            {
                results.Add(currentLineKey, new StringBuilder());
            }

            if (!firstRender &&
                results[currentLineKey].Length != 0 &&
                !results[currentLineKey].ToString().EndsWith(" ") &&
                renderInfo.GetText().Length > 0 &&
                !renderInfo.GetText().StartsWith(" "))
            {
                float spacing = lastEnd.Subtract(start).Length;
                if (spacing > renderInfo.GetSingleSpaceWidth() / 2f)
                {
                    results[currentLineKey].Append(" ");
                }
            }

            results[currentLineKey].Append(renderInfo.GetText());
            lastStart = start;
            lastEnd = end;
        }
开发者ID:ribcesoftware,项目名称:Converter,代码行数:48,代码来源:PDF+Reader.cs

示例13: AllowText

        public override bool AllowText(TextRenderInfo renderInfo) {
            LineSegment ascent = renderInfo.GetAscentLine();
            LineSegment descent = renderInfo.GetDescentLine();

            Rectangle r1 = new Rectangle(Math.Min(descent.GetStartPoint()[0], descent.GetEndPoint()[0]),
                                         descent.GetStartPoint()[1],
                                         Math.Max(descent.GetStartPoint()[0], descent.GetEndPoint()[0]),
                                         ascent.GetEndPoint()[1]);

            foreach (Rectangle rectangle in rectangles) {
                if (Intersect(r1, rectangle)) {
                    return false;
                }
            }

            return true;
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:17,代码来源:PdfCleanUpRegionFilter.cs

示例14: RenderText

        //Automatically called for each chunk of text in the PDF
        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);

            //See if the current chunk contains the text
            var startPosition = System.Globalization.CultureInfo.CurrentCulture.CompareInfo.IndexOf(
                renderInfo.GetText(), this.TextToSearchFor, this.CompareOptions);

            //If not found bail
            if (startPosition < 0)
            {
                return;
            }

            if (renderInfo.PdfString.ToString() != this.TextToSearchFor)
            {
                return;
            }

            //Grab the individual characters
            var chars =
                renderInfo.GetCharacterRenderInfos().Skip(startPosition).Take(this.TextToSearchFor.Length).ToList();

            //Grab the first and last character
            var firstChar = chars.First();
            var lastChar = chars.Last();

            //Get the bounding box for the chunk of text
            var bottomLeft = firstChar.GetDescentLine().GetStartPoint();
            var topRight = lastChar.GetAscentLine().GetEndPoint();

            //Create a rectangle from it
            var rect = new iTextSharp.text.Rectangle(
                bottomLeft[Vector.I1],
                bottomLeft[Vector.I2],
                topRight[Vector.I1],
                topRight[Vector.I2]
                );

            //Add this to our main collection
            this.MyPoints.Add(new RectAndText(rect, this.TextToSearchFor));
        }
开发者ID:raviroyind,项目名称:PdfHighlighter,代码行数:43,代码来源:PdfTextHighlighter.cs

示例15: RenderText

        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);

            var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
            var topRight = renderInfo.GetAscentLine().GetEndPoint();

            var rect = new iTextSharp.text.Rectangle(
                bottomLeft[Vector.I1],
                bottomLeft[Vector.I2],
                topRight[Vector.I1],
                topRight[Vector.I2]
            );

            this.containers.Add(new TextContainer()
            {
                Container = rect,
                Text = renderInfo.GetText()
            });
        }
开发者ID:MalakhovVladislav,项目名称:practice,代码行数:20,代码来源:TextBlocksLocationStrategy.cs


注:本文中的iTextSharp.text.pdf.parser.TextRenderInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。