We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set default font for the PDF document to avoid specifying styling for every text fragment in Aspose.PDF for .NET

hi there

i am constructing a PDF document for a report.
the very first thing i do is to
pdf = new Pdf();
pdf.DefaultFontName = FontName; //“Arial” in this case

i then go on to build up the report and do things such as

Aspose.Pdf.Table tbl = new Aspose.Pdf.Table();
tbl.ColumnWidths = ColumnWidths;
tbl.DefaultCellPadding = something…;
etc… then
tbl.ImportDataTable(dt, true, 0, 0, dt.Rows.Count, dt.Columns.Count);
foreach (Aspose.Pdf.Row rr in tbl.Rows)
if (!odd)
rr.BackgroundColor = lb;
odd = !odd;

and things like this

TextInfo boldCol = new TextInfo();
boldCol.Alignment = AlignmentType.Left;
boldCol.IsTrueTypeFontBold = true;
boldCol.FontSize = 10;

tblHeadings.SetColumnTextInfo(0, boldCol);

however when i do the above whatever element i have styled loses the font set right at the beginning.
surely i dont have to set the font as part of every bit of styling i add to an element?

so the table is all in one font, but as i format the headings to be bold and some are then left aligned … things like that, whenever i do this, those elements revert back to time roman font.

could someone explain how to avoid this pelase




Can you please share the complete code snippet so that we can test the scenario at our end. We apologize for your inconvenience.

PS, I have tried regenerating the code at my end but I am afraid I am unable to replicate the issue at my end.


As per your initial inquiry, we would like to share with you that you can now Set Default Font Name while Saving a PDF document using Aspose.PDF for .NET.