當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。