문제

BaseFont Vn_Helvetica = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", 
"Identity-H", BaseFont.EMBEDDED);
Font fontNormal = new Font(Vn_Helvetica, 12, Font.NORMAL);
foreach (var t in htmlarraylist)
                {

 if (t is PdfPTable)
                    {
                        var countColumn= ((PdfPTable)t).NumberOfColumns;//is 7
                        var countRows = ((PdfPTable)t).Rows;//is 10

//I want set normalFont for all the text but defaultCell.Phrase is always null

((PdfPTable)t).DefaultCell.Phrase = new Phrase() { Font = fontNormal };

//how to find text in pdfptable to set the font?

                    }
                   document.Add(t);
도움이 되었습니까?

해결책

You are trying to set the font on the phrase for the default cell of the table. You need to set this for all cells on the table:

        // t is a PdfPTable
        foreach(var row in t.Rows)
        {
            foreach(var cell in row.GetCells())
            {
                if(cell.Phrase != null)
                {
                    cell.Phrase.Font = fontNormal;
                }
            }
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top