예제 #1
0
        public virtual void RenderText(TextRenderInfo renderInfo)
        {
            LineSegment segment  = renderInfo.GetBaseline();
            TextChunk   location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());

            var _with1 = location;

            //Chunk Location:
            //			Debug.Print(renderInfo.GetText);
            _with1.PosLeft   = renderInfo.GetDescentLine().GetStartPoint()[Vector.I1];
            _with1.PosRight  = renderInfo.GetAscentLine().GetEndPoint()[Vector.I1];
            _with1.PosBottom = renderInfo.GetDescentLine().GetStartPoint()[Vector.I2];
            _with1.PosTop    = renderInfo.GetAscentLine().GetEndPoint()[Vector.I2];
            //Chunk Font Size: (Height)
            _with1.curFontSize = _with1.PosTop - segment.GetStartPoint()[Vector.I2];
            //Use Font name  and Size as Key in the SortedList
            string StrKey = renderInfo.GetFont().PostscriptFontName + _with1.curFontSize.ToString();

            //Add this font to ThisPdfDocFonts SortedList if it's not already present
            if (!ThisPdfDocFonts.ContainsKey(StrKey))
            {
                ThisPdfDocFonts.Add(StrKey, renderInfo.GetFont());
            }
            //Store the SortedList index in this Chunk, so we can get it later
            _with1.FontIndex = ThisPdfDocFonts.IndexOfKey(StrKey);
            locationalResult.Add(location);
        }
        /// <summary>
        /// Render text.
        /// </summary>
        /// <param name="renderInfo">render text information</param>
        public void RenderText(TextRenderInfo renderInfo)
        {
            var segment  = renderInfo.GetBaseline();
            var location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth())
            {
                PosLeft     = renderInfo.GetDescentLine().GetStartPoint()[Vector.I1],
                PosRight    = renderInfo.GetAscentLine().GetEndPoint()[Vector.I1],
                PosBottom   = renderInfo.GetDescentLine().GetStartPoint()[Vector.I2],
                PosTop      = renderInfo.GetAscentLine().GetEndPoint()[Vector.I2],
                FillColor   = renderInfo.GetFillColor(),
                StrokeColor = renderInfo.GetStrokeColor(),
                Font        = renderInfo.GetFont()
            };

            // Chunk Font Size: (Height)
            location.CurFontSize = location.PosTop - segment.GetStartPoint()[Vector.I2];

            // Use Font name  and Size as Key in the SortedList
            var strKey = renderInfo.GetFont().PostscriptFontName + location.CurFontSize;

            // Add this font to ThisPdfDocFonts SortedList if it's not already present
            if (!_thisPdfDocFonts.ContainsKey(strKey))
            {
                _thisPdfDocFonts.Add(strKey, renderInfo.GetFont());
            }

            // Store the SortedList index in this Chunk, so we can get it later
            location.FontIndex = _thisPdfDocFonts.IndexOfKey(strKey);

            _locationalResult.Add(location);
        }
예제 #3
0
        public CharacterRenderInfo(TextRenderInfo tri)
            : base(tri == null ? "" : tri.GetText(), tri == null ? null : GetLocation(tri))
        {
            if (tri == null)
            {
                throw new ArgumentException("TextRenderInfo argument is not nullable.");
            }
            // determine bounding box
            float x0 = tri.GetDescentLine().GetStartPoint().Get(0);
            float y0 = tri.GetDescentLine().GetStartPoint().Get(1);
            float h  = tri.GetAscentLine().GetStartPoint().Get(1) - tri.GetDescentLine().GetStartPoint().Get(1);
            float w  = Math.Abs(tri.GetBaseline().GetStartPoint().Get(0) - tri.GetBaseline().GetEndPoint().Get(0));

            this.boundingBox = new Rectangle(x0, y0, w, h);
        }
예제 #4
0
            //--------------------------------------------------------------------------------------------------
            public void RenderText(TextRenderInfo renderInfo)
            {
                LineSegment segment  = renderInfo.GetBaseline();
                TextChunk   location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());

                location.iPage = Page;

                int renderInfoTextLength = new StringInfo(renderInfo.GetText()).LengthInTextElements;

                if (renderInfoTextLength == 1)
                {
                    location.AscentLines.Add(renderInfo.GetAscentLine());
                    location.DescentLines.Add(renderInfo.GetDescentLine());
                }
                else
                {
                    IList <TextRenderInfo> infos = renderInfo.GetCharacterRenderInfos();
                    System.Diagnostics.Debug.Assert(infos != null);
                    System.Diagnostics.Debug.Assert(renderInfoTextLength == infos.Count);
                    foreach (TextRenderInfo info in infos)
                    {
                        location.AscentLines.Add(info.GetAscentLine());
                        location.DescentLines.Add(info.GetDescentLine());
                    }
                }
                m_LocationalResult.Add(location);
            }
        private Rectangle GetRectangleFromReaderInfo(TextRenderInfo renderInfo)
        {
            var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
            var topRight   = renderInfo.GetAscentLine().GetEndPoint();

            return(new Rectangle(bottomLeft[Vector.I1], bottomLeft[Vector.I2], topRight[Vector.I1], topRight[Vector.I2]));
        }
예제 #6
0
        /**
         *
         * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo)
         */
        public virtual void RenderText(TextRenderInfo renderInfo)
        {
            LineSegment segment = renderInfo.GetBaseline();

            if (renderInfo.GetRise() != 0)
            { // remove the rise from the baseline - we do this because the text from a super/subscript render operations should probably be considered as part of the baseline of the text the super/sub is relative to
                Matrix riseOffsetTransform = new Matrix(0, -renderInfo.GetRise());
                segment = segment.TransformBy(riseOffsetTransform);
            }
            //TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());
            //locationalResult.Add(location);

            //base.RenderText(renderInfo);


            //Get the bounding box for the chunk of text
            var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
            var topRight   = renderInfo.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]
                );

            TextChunk location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth(), rect);

            locationalResult.Add(location);
        }
        /// <summary>
        /// Obtiene el texto contenido en un pdf en función del parámetro facilitado.
        /// </summary>
        /// <param name="renderInfo">Información para la obtención del texto.</param>
        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);

            LineSegment segment = renderInfo.GetBaseline();

            if (renderInfo.GetRise() != 0)
            {
                // remove the rise from the baseline - we do this because the text from a
                // super /subscript render operations should probably be considered as part
                // of the baseline of the text the super/sub is relative to
                Matrix riseOffsetTransform = new Matrix(0, -renderInfo.GetRise());
                segment = segment.TransformBy(riseOffsetTransform);
            }

            var ll = renderInfo.GetDescentLine().GetStartPoint();         // lower left
            var ur = renderInfo.GetAscentLine().GetEndPoint();            // upper right

            string text = renderInfo.GetText();                           //mirando

            string fillColor   = renderInfo.GetFillColor()?.ToString();   // Color del texto.
            string strokeColor = renderInfo.GetStrokeColor()?.ToString(); // Color del texto.

            Vector curBaseline = renderInfo.GetBaseline().GetStartPoint();
            Vector topRight    = renderInfo.GetAscentLine().GetEndPoint();

            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(curBaseline[Vector.I1], curBaseline[Vector.I2], topRight[Vector.I1], topRight[Vector.I2]);
            double fontSize = Math.Round(rect.Height);                  // Tamaño de la fuente a partir del rectángulo extraído.

            string fontName = renderInfo.GetFont()?.PostscriptFontName; //Nombre de la fuente.

            //base._PdfTextChunks.Add(new PdfTextChunk(renderInfo.GetText(), base.tclStrat.CreateLocation(renderInfo, segment), ll, ur));
            _PdfColorFontTextChunks.Add(new PdfColorFontTextChunk(renderInfo.GetText(), base.tclStrat.CreateLocation(renderInfo, segment), ll, ur, fillColor, strokeColor, fontName, fontSize));
        }
예제 #8
0
 public LineInfo(TextRenderInfo info, string text)
 {
     this.Text    = text;
     this.Font    = info.GetFont().GetFontProgram().GetFontNames();
     this.Object  = info.GetPdfString();
     this.Ascent  = info.GetAscentLine();
     this.Descent = info.GetDescentLine();
 }
 public void RenderText(TextRenderInfo renderInfo)
 {
     Chunks.Add(new Chunk
     {
         TopLeft     = renderInfo.GetAscentLine().GetStartPoint(),
         BottomRight = renderInfo.GetDescentLine().GetEndPoint(),
         Text        = renderInfo.GetText(),
     });
 }
예제 #10
0
        /// <summary>Get the bounding box of a TextRenderInfo object</summary>
        /// <param name="renderInfo">input TextRenderInfo object</param>
        private Point[] GetTextRectangle(TextRenderInfo renderInfo)
        {
            LineSegment ascent  = renderInfo.GetAscentLine();
            LineSegment descent = renderInfo.GetDescentLine();

            return(new Point[] { new Point(ascent.GetStartPoint().Get(0), ascent.GetStartPoint().Get(1)), new Point(ascent
                                                                                                                    .GetEndPoint().Get(0), ascent.GetEndPoint().Get(1)), new Point(descent.GetEndPoint().Get(0), descent.GetEndPoint
                                                                                                                                                                                       ().Get(1)), new Point(descent.GetStartPoint().Get(0), descent.GetStartPoint().Get(1)) });
        }
예제 #11
0
            // x-height?
            // cap-height?

            public bool TrySet(TextRenderInfo renderInfo)
            {
                var p1 = renderInfo.GetBaseline().GetStartPoint();
                var p2 = renderInfo.GetBaseline().GetEndPoint();

                if (p1[1] != p2[1] ||
                    p1[2] != p2[2] ||
                    p1[2] != 1)
                {
                    return(false);
                }
                OriginX     = p1[0];
                OriginY     = p1[1];
                Advancement = p2[0] - p1[0];
                p1          = renderInfo.GetAscentLine().GetStartPoint();
                p2          = renderInfo.GetAscentLine().GetEndPoint();
                if (p1[1] != p2[1] ||
                    p1[2] != p2[2] ||
                    p1[2] != 1 ||
                    Advancement != p2[0] - p1[0])
                {
                    return(false);
                }
                Ascent = p1[1] - OriginY;
                if (Ascent < 0)
                {
                    return(false);
                }
                p1 = renderInfo.GetDescentLine().GetStartPoint();
                p2 = renderInfo.GetDescentLine().GetEndPoint();
                if (p1[1] != p2[1] ||
                    p1[2] != p2[2] ||
                    p1[2] != 1 ||
                    Advancement != p2[0] - p1[0])
                {
                    return(false);
                }
                Descent = OriginY - p1[1];
                if (Descent < 0)
                {
                    return(false);
                }
                return(true);
            }
        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);
            string    text       = renderInfo.GetText();
            Vector    bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
            Vector    topRight   = renderInfo.GetAscentLine().GetEndPoint();
            Rectangle rectangle  = new Rectangle(bottomLeft[Vector.I1], bottomLeft[Vector.I2], topRight[Vector.I1], topRight[Vector.I2]);

            Chunks.Add(new TableTextChunk(rectangle, text));
        }
예제 #13
0
파일: Program.cs 프로젝트: kahn520/wordtest
        private RectangleF getRenderRectangleF(TextRenderInfo renderInfo)
        {
            var ascentLine  = renderInfo.GetAscentLine();
            var descentLine = renderInfo.GetDescentLine();

            return(new RectangleF(ascentLine.GetStartPoint()[0]
                                  , ascentLine.GetStartPoint()[1]
                                  , ascentLine.GetEndPoint()[0] - ascentLine.GetStartPoint()[0]
                                  , descentLine.GetStartPoint()[1] - ascentLine.GetStartPoint()[1]));
        }
    public override void RenderText(TextRenderInfo renderInfo)
    {
        LineSegment segment  = renderInfo.GetBaseline();
        TextChunk   location = new TextChunk(renderInfo.GetText(), segment.GetStartPoint(), segment.GetEndPoint(), renderInfo.GetSingleSpaceWidth());

        location.PosLeft     = renderInfo.GetDescentLine().GetStartPoint()[Vector.I1];
        location.PosRight    = renderInfo.GetAscentLine().GetEndPoint()[Vector.I1];
        location.PosBottom   = renderInfo.GetDescentLine().GetStartPoint()[Vector.I2];
        location.PosTop      = renderInfo.GetAscentLine().GetEndPoint()[Vector.I2];
        location.curFontSize = location.PosTop - segment.GetStartPoint()[Vector.I2];
        string StrKey = renderInfo.GetFont().PostscriptFontName + location.curFontSize.ToString();

        if (!ThisPdfDocFonts.ContainsKey(StrKey))
        {
            ThisPdfDocFonts.Add(StrKey, renderInfo.GetFont());
        }
        location.FontIndex = ThisPdfDocFonts.IndexOfKey(StrKey);
        locationalResult.Add(location);
    }
예제 #15
0
        public CharacterRenderInfo(TextRenderInfo tri)
            : base(tri == null ? "" : tri.GetText(), tri == null ? null : GetLocation(tri))
        {
            if (tri == null)
            {
                throw new ArgumentException("TextRenderInfo argument is not nullable.");
            }
            // determine bounding box
            IList <Point> points = new List <Point>();

            points.Add(new Point(tri.GetDescentLine().GetStartPoint().Get(0), tri.GetDescentLine().GetStartPoint().Get
                                     (1)));
            points.Add(new Point(tri.GetDescentLine().GetEndPoint().Get(0), tri.GetDescentLine().GetEndPoint().Get(1))
                       );
            points.Add(new Point(tri.GetAscentLine().GetStartPoint().Get(0), tri.GetAscentLine().GetStartPoint().Get(1
                                                                                                                     )));
            points.Add(new Point(tri.GetAscentLine().GetEndPoint().Get(0), tri.GetAscentLine().GetEndPoint().Get(1)));
            this.boundingBox = Rectangle.CalculateBBox(points);
        }
예제 #16
0
            public virtual void RenderText(TextRenderInfo renderInfo)
            {
                Vector startPoint = renderInfo.GetDescentLine().GetStartPoint();
                Vector endPoint   = renderInfo.GetAscentLine().GetEndPoint();
                float  x1         = Math.Min(startPoint[0], endPoint[0]);
                float  x2         = Math.Max(startPoint[0], endPoint[0]);
                float  y1         = Math.Min(startPoint[1], endPoint[1]);
                float  y2         = Math.Max(startPoint[1], endPoint[1]);

                rectangles.Add(new Rectangle(x1, y1, x2, y2));
            }
예제 #17
0
 public virtual void EventOccurred(IEventData data, EventType type)
 {
     if (type == EventType.RENDER_TEXT)
     {
         TextRenderInfo info = (TextRenderInfo)data;
         if (textRectangle == null)
         {
             textRectangle = info.GetDescentLine().GetBoundingRectangle();
         }
         else
         {
             textRectangle = Rectangle.GetCommonRectangle(textRectangle, info.GetDescentLine().GetBoundingRectangle());
         }
         textRectangle = Rectangle.GetCommonRectangle(textRectangle, info.GetAscentLine().GetBoundingRectangle());
     }
     else
     {
         throw new InvalidOperationException(MessageFormatUtil.Format("Event type not supported: {0}", type));
     }
 }
예제 #18
0
        public CharacterRenderInfo(TextRenderInfo tri)
            : base(tri == null ? "" : tri.GetText(), tri == null ? null : GetLocation(tri))
        {
            if (tri == null)
            {
                throw new ArgumentException("TextRenderInfo argument is not nullable.");
            }
            if (tri.GetText().Length != 1)
            {
                throw new ArgumentException("CharacterRenderInfo objects represent a single character. They should not be made from TextRenderInfo objects containing more than a single character of text."
                                            );
            }
            // determine bounding box
            float x0 = tri.GetDescentLine().GetStartPoint().Get(0);
            float y0 = tri.GetDescentLine().GetStartPoint().Get(1);
            float h  = tri.GetAscentLine().GetStartPoint().Get(1) - tri.GetDescentLine().GetStartPoint().Get(1);
            float w  = Math.Abs(tri.GetBaseline().GetStartPoint().Get(0) - tri.GetBaseline().GetEndPoint().Get(0));

            this.boundingBox = new Rectangle(x0, y0, w, h);
        }
예제 #19
0
        /// <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));
        }
        /**
         * Checks if the text is inside render filter region.
         *
         * @param renderInfo
         * @return
         */
        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]);
            Rectangle r2 = rectangle;

            return(Intersect(r1, r2));
        }
예제 #21
0
        public virtual void RenderText(TextRenderInfo renderInfo)
        {
            LineSegment baseline     = renderInfo.GetBaseline();
            TextChunk   renderedItem = new TextChunk(renderInfo.GetText(), baseline.GetStartPoint(), baseline.GetEndPoint(), renderInfo.GetSingleSpaceWidth());
            TextChunk   foundChunk   = renderedItem;

            Debug.Print(renderInfo.GetText());
            foundChunk.PosLeft     = renderInfo.GetDescentLine().GetStartPoint()[0];
            foundChunk.PosRight    = renderInfo.GetAscentLine().GetEndPoint()[0];
            foundChunk.PosBottom   = renderInfo.GetDescentLine().GetStartPoint()[1];
            foundChunk.PosTop      = renderInfo.GetAscentLine().GetEndPoint()[1];
            foundChunk.curFontSize = foundChunk.PosTop - baseline.GetStartPoint()[1];
            string key = renderInfo.GetFont().PostscriptFontName + foundChunk.curFontSize.ToString();

            if (!this.ThisPdfDocFonts.ContainsKey(key))
            {
                this.ThisPdfDocFonts.Add(key, renderInfo.GetFont());
            }
            foundChunk.FontIndex = this.ThisPdfDocFonts.IndexOfKey(key);
            foundChunk           = null;
            this.locationalResult.Add(renderedItem);
        }
    public void RenderText(TextRenderInfo renderInfo)
    {
        LineSegment ascentLine  = renderInfo.GetAscentLine();
        LineSegment descentLine = renderInfo.GetDescentLine();

        float[] yCoords = new float[] {
            ascentLine.GetStartPoint()[Vector.I2],
                ascentLine.GetEndPoint()[Vector.I2],
                descentLine.GetStartPoint()[Vector.I2],
                descentLine.GetEndPoint()[Vector.I2]
        };
        Array.Sort(yCoords);
        addVerticalUseSection(yCoords[0], yCoords[3]);
    }
예제 #23
0
 public virtual void EventOccurred(IEventData data, EventType type)
 {
     if (type == EventType.RENDER_TEXT)
     {
         TextRenderInfo renderInfo = (TextRenderInfo)data;
         Vector         startPoint = renderInfo.GetDescentLine().GetStartPoint();
         Vector         endPoint   = renderInfo.GetAscentLine().GetEndPoint();
         float          x1         = Math.Min(startPoint.Get(0), endPoint.Get(0));
         float          x2         = Math.Max(startPoint.Get(0), endPoint.Get(0));
         float          y1         = Math.Min(startPoint.Get(1), endPoint.Get(1));
         float          y2         = Math.Max(startPoint.Get(1), endPoint.Get(1));
         rectangles.Add(new Rectangle(x1, y1, x2 - x1, y2 - y1));
     }
 }
예제 #24
0
        /// <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];
        }
예제 #25
0
        public TextInfo(TextRenderInfo renderInfo)
        {
            Text = renderInfo.GetText();

            var bottomLeftPoint = renderInfo.GetDescentLine().GetStartPoint();
            var topRightPoint   = renderInfo.GetAscentLine().GetEndPoint();

            var rectangle = new Rectangle(
                bottomLeftPoint[Vector.I1],
                bottomLeftPoint[Vector.I2],
                topRightPoint[Vector.I1],
                topRightPoint[Vector.I2]
                );

            var fontSize = Convert.ToDouble(rectangle.Height);
        }
예제 #26
0
    //Automatically called for each chunk of text in the PDF
    public override void RenderText(TextRenderInfo renderInfo)
    {
        base.RenderText(renderInfo);
        //Get the bounding box for the chunk of text
        var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
        var topRight   = renderInfo.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, renderInfo.GetText()));
    }
예제 #27
0
            public override void RenderText(TextRenderInfo renderInfo)
            {
                base.RenderText(renderInfo);

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

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

                this.myPoints.Add(new RectAndText {
                    Rect = rect, Text = renderInfo.GetText(), Page = Page
                });
            }
        public override void RenderText(TextRenderInfo renderInfo)
        {
            base.RenderText(renderInfo);

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

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

            // Add rectangle to collection
            textCoordinates.Add(new PdfTextAndPos(rectangle, renderInfo.GetText()));
        }
예제 #29
0
        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);
        }
예제 #30
0
            public SearchResult(TextRenderInfo aFirstCharcter, TextRenderInfo aLastCharcter, float fPageSizeY)
            {
                //Get position of upperLeft coordinate
                //Vector vTopLeft = aFirstCharcter.GetAscentLine().GetStartPoint();
                Vector vbottomLeft = aFirstCharcter.GetDescentLine().GetStartPoint();
                Vector vtopRight   = aLastCharcter.GetAscentLine().GetEndPoint();

                //PosX
                //float fPosX = vTopLeft[Vector.I1];

                //PosY
                //float fPosY = vTopLeft[Vector.I2];

                //Transform to mm and get y from top of page
                //iPosX = Convert.ToInt32(fPosX * PDF_PX_TO_MM);
                //iPosY = Convert.ToInt32((fPageSizeY - fPosY) * PDF_PX_TO_MM);

                rect = new iTextSharp.text.Rectangle(vbottomLeft[Vector.I1],
                                                     vbottomLeft[Vector.I2], vtopRight[Vector.I1], vtopRight[Vector.I2]);
            }