This project has moved and is read-only. For the latest updates, please go here.

Bug or incorrect usage? Problem with fonts in table

Aug 11, 2010 at 8:01 PM

I'm having some problem with setting right FontFamily for text inside tables. When I'm using just Formatting for InsertText everything except font family is applied correctly (underline, size etc). So it seems like Family Font in formatting is not setting itself.


        private static readonly Formatting formattingTabelaTytul = new Formatting { FontFamily = fontCalibri, Bold = true, Italic = true, UnderlineStyle = UnderlineStyle.singleLine, Size = 9 };
        private static readonly Formatting formattingTabelaContent = new Formatting {FontFamily = fontCalibri , Size = 9 };
        private static readonly FontFamily fontCalibri = new FontFamily("Calibri");

        Table tabelaAkcji = document.InsertTable(4, rowsCountAll);
                //tabelaAkcji.AutoFit = AutoFit.Window;
                // tabelaAkcji.Design = TableDesign.LightShadingAccent1;
                tabelaAkcji.Design = TableDesign.LightListAccent3;
                tabelaAkcji.Alignment =;
                tabelaAkcji.Rows[0].Cells[0].Paragraphs[0].InsertText("Data", false, formattingTabelaTytul);
                tabelaAkcji.Rows[0].Cells[1].Paragraphs[0].InsertText("Kwota obciążenia rachunku", false, formattingTabelaTytul);
                tabelaAkcji.Rows[0].Cells[2].Paragraphs[0].InsertText("Kwota uznania rachunku", false, formattingTabelaTytul);
                tabelaAkcji.Rows[0].Cells[3].Paragraphs[0].InsertText("Opis", false, formattingTabelaTytul);
                tabelaAkcji.Rows[0].Cells[0].Paragraphs[0].Alignment = Alignment.left;
                tabelaAkcji.Rows[0].Cells[1].Paragraphs[0].Alignment = Alignment.left;
                tabelaAkcji.Rows[0].Cells[2].Paragraphs[0].Alignment = Alignment.left;
                tabelaAkcji.Rows[0].Cells[3].Paragraphs[0].Alignment = Alignment.left;
                tabelaAkcji.Rows[0].Cells[0].Width = 50;
                tabelaAkcji.Rows[0].Cells[1].Width = 70;
                tabelaAkcji.Rows[0].Cells[2].Width = 70;
                tabelaAkcji.Rows[0].Cells[3].Width = 300;


When I've added


just to test things up and see if this way it works error pops out on this: Object reference not set to an instance of an object.

This also seems a case for  Paragraph paragraphWycena = document.InsertParagraph("test", false, formatBoldTwelve); which as well doesn't have applied font.

Jun 11, 2012 at 6:33 PM
Edited Jun 11, 2012 at 6:33 PM

I also have this issue, I tried to import a new font with this code

var p = table.Rows[0].Cells[0].InsertParagraph();
var f = new PrivateFontCollection();