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

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

public GetFont ( ) : DocumentFont
Результат DocumentFont
        public DocumentFont GetFont()
        {
            return gs.GetFont();
        }

Usage Example

Пример #1
0
        public void RenderText(iTextSharp.text.pdf.parser.TextRenderInfo renderInfo)
        {
            //to check the components , you can use to print line by line
            //DataModel dataModel = new DataModel(); //1.1.18
            string curDataItself = renderInfo.GetText();
            //Console.WriteLine(curDataItself);
            string curDataFontStyle = "";
            string curFont          = renderInfo.GetFont().PostscriptFontName; // http://itextsupport.com/apidocs/itext5/5.5.9/com/itextpdf/text/pdf/parser/TextRenderInfo.html#getFont--

            if ((renderInfo.GetTextRenderMode() == 2 /*(int)TextRenderMode.FillThenStrokeText*/))
            {
                curDataFontStyle = "BOLD";

                curFont += "-Bold";
            }

            //This code assumes that if the baseline changes then we're on a newline
            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]);
            Single curFontSize             = rect.Height;

            //dataModel.fontSize = curFontSize;


            if (lastBaseLine != null && lastBaseLine[Vector.I2] != curBaseline[Vector.I2])
            {
                DataModel aDataModel = new DataModel();
                aDataModel.dataItself    = lastDataItself;
                aDataModel.fontSize      = lastFontSize;
                aDataModel.dataFontStyle = lastDataFontStyle;
                aDataModel.fontName      = lastFont;
                listOfData.Add(aDataModel);


                lastDataItself    = curDataItself;
                lastFont          = curFont;
                lastDataFontStyle = curDataFontStyle;
                lastFontSize      = curFontSize;
            }
            else
            {
                lastDataItself   += curDataItself;
                lastFont          = curFont;
                lastFontSize      = curFontSize;
                lastDataFontStyle = curDataFontStyle;
            }

            if (lastBaseLine == null)
            {
                lastDataItself    = curDataItself;
                lastFont          = curFont;
                lastFontSize      = curFontSize;
                lastDataFontStyle = curDataFontStyle;
            }

            this.lastBaseLine = curBaseline;
        }
All Usage Examples Of iTextSharp.text.pdf.parser.TextRenderInfo::GetFont