/// <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);
        }
예제 #2
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>
        /// 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));
        }
        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]));
        }
예제 #5
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);
        }
예제 #6
0
        public virtual void ParseText(TextRenderInfo textRenderInfo)
        {
            var         text     = textRenderInfo.GetText();
            LineSegment baseline = textRenderInfo.GetBaseline();

            if (textRenderInfo.GetRise() != 0)
            {
                Matrix m = new Matrix(0.0f, -textRenderInfo.GetRise());
                baseline = baseline.TransformBy(m);
            }
            var          start      = baseline.GetStartPoint();
            LineSegment  ascentLine = textRenderInfo.GetAscentLine();
            PdfTextBlock item       = new PdfTextBlock
            {
                Value        = text,
                Bottom       = pageContext.PageHeight - start.Get(Vector.I2),
                Top          = pageContext.PageHeight - ascentLine.GetStartPoint().Get(Vector.I2),
                Left         = start.Get(Vector.I1),
                Width        = baseline.GetEndPoint().Get(Vector.I1) - start.Get(Vector.I1),
                FontSize     = FontManager.Instance.GetFontSize(textRenderInfo, baseline, ascentLine),
                StrokeColore = ColorManager.Instance.GetColor(textRenderInfo),
                CharSpacing  = textRenderInfo.GetSingleSpaceWidth(),
                Font         = GetFont(textRenderInfo),
            };

            RightToLeftManager.Instance.AssignRtl(item, textRenderInfo.GetUnscaledWidth() < 0);
            pageContext.LinkManager.AssignLink(item);
            texts.Add(item);
        }
예제 #7
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);
            }
예제 #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);
            }
예제 #12
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);
        }
    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);
    }
        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));
        }
예제 #15
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]));
        }
예제 #16
0
            public override void RenderText(TextRenderInfo renderInfo)
            {
                base.RenderText(renderInfo);

                //Vector bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
                Vector    bottomLeft = renderInfo.GetBaseline().GetStartPoint();
                Vector    topRight   = renderInfo.GetAscentLine().GetEndPoint();
                TextChunk tc         = new TextChunk(renderInfo.GetText(), bottomLeft, topRight, renderInfo.GetSingleSpaceWidth());

                TextChunks.Add(tc);
            }
예제 #17
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));
            }
예제 #18
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));
        }
        public SearchResult(TextRenderInfo aCharcter, float fPageSizeY)
        {
            //Get position of upperLeft coordinate
            Vector vTopLeft = aCharcter.GetAscentLine().GetStartPoint();
            //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);
        }
예제 #20
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);
        }
        /**
         * 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));
        }
    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
        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);
        }
예제 #25
0
        private IBrick InfoToBrick(TextRenderInfo info)
        {
            var baseRectangle   = info.GetBaseline().GetBoundingRectangle();
            var accentRectangle = info.GetAscentLine().GetBoundingRectangle();

            var text = info.GetText();

            var brick = new Brick(text,
                                  baseRectangle.GetX(),
                                  _maxY - baseRectangle.GetY(),
                                  baseRectangle.GetWidth(),
                                  accentRectangle.GetY() - baseRectangle.GetY());

            return(brick);
        }
예제 #26
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];
        }
예제 #27
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);
        }
예제 #28
0
        public CharRenderInfo(TextRenderInfo renderInfo)
        {
            var curBaseline = renderInfo.GetBaseline().GetStartPoint();
            var topRight    = renderInfo.GetAscentLine().GetEndPoint();

            this.value = renderInfo.GetText();

            this.x = (int)curBaseline[Vector.I1];
            this.y = (int)curBaseline[Vector.I2];

            this.width  = (int)topRight[Vector.I1] - this.x;
            this.height = (int)topRight[Vector.I2] - this.y;

            var gs = (GraphicsState)GraphicStatePropInfo.GetValue(renderInfo);

            this.fontSize = (int)gs.FontSize;
        }
예제 #29
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()));
    }
예제 #30
0
        public void RenderText(TextRenderInfo renderInfo)
        {
            var curFont = renderInfo.GetFont().PostscriptFontName;

            //Check if faux bold is used
            if (renderInfo.GetTextRenderMode() == (int)TextRenderMode.FillThenStrokeText)
            {
                curFont += "-Bold";
            }

            //This code assumes that if the baseline changes then we're on a newline
            var curBaseline = renderInfo.GetBaseline().GetStartPoint();
            var topRight    = renderInfo.GetAscentLine().GetEndPoint();
            var rect        = new Rectangle(curBaseline[Vector.I1], curBaseline[Vector.I2], topRight[Vector.I1],
                                            topRight[Vector.I2]);
            var curFontSize = rect.Height;

            //See if something has changed, either the baseline, the font or the font size
            if (lastBaseLine == null || curBaseline[Vector.I2] != lastBaseLine[Vector.I2] ||
                curFontSize != lastFontSize || curFont != lastFont)
            {
                //if we've put down at least one span tag close it
                if (lastBaseLine != null)
                {
                    result.AppendLine("</span>");
                }

                //If the baseline has changed then insert a line break
                if (lastBaseLine != null && curBaseline[Vector.I2] != lastBaseLine[Vector.I2])
                {
                    result.AppendLine("<br />");
                }

                //Create an HTML tag with appropriate styles
                result.AppendFormat("<span>");
            }

            //Append the current text
            result.Append(renderInfo.GetText());

            //Set currently used properties
            lastBaseLine = curBaseline;
            lastFontSize = curFontSize;
            lastFont     = curFont;
        }