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

Free Support Forum - aspose.com

Unable change the font name to "Arial" for entire pdf document

Hi,

We have a requirement to display the text in pdf document in "Arial". We have multiple text paragrahs (added 20 paragraphs) added to section. If we set "FoneName" of pdf object, it is not reflecting. We tried to set this property for both pdf and section objects. If we set the same property to individual Text object, then it is reflecting in the generated pdf.

Aspose.Pdf.Generator.Pdf testPdf = new Pdf();
Aspose.Pdf.Generator.Section testsec = testPdf.Sections.Add();

testPdf.TextInfo.FontName = "Arial"; -------- not reflecting in pdf document
testsec.TextInfo.FontName = "Arial"l; -------- not reflecting in pdf document


Text text1 = new Text("this is sample test");
text1.TextInfo.FontName = "Arial"l; ----------reflecting in pdf document
testsec.Paragraphs.Add(text1);

Could you please suggest a solution to set font name to all text paragraphs (20 paragraphs) in single line code?

Regards,
Surya
We have a requirement to display the text in pdf document in "Arial". We have multiple text paragrahs (added 20 paragraphs) added to section. If we set "FoneName" of pdf object, it is not reflecting. We tried to set this property for both pdf and section objects. If we set the same property to individual Text object, then it is reflecting in the generated pdf.

Aspose.Pdf.Generator.Pdf testPdf = new Pdf();
Aspose.Pdf.Generator.Section testsec = testPdf.Sections.Add();

testPdf.TextInfo.FontName = "Arial"; -------- not reflecting in pdf document
testsec.TextInfo.FontName = "Arial"l; -------- not reflecting in pdf document


Text text1 = new Text("this is sample test");
text1.TextInfo.FontName = "Arial"l; ----------reflecting in pdf document
testsec.Paragraphs.Add(text1);

Could you please suggest a solution to set font name to all text paragraphs (20 paragraphs) in single line code?

Regards,
Surya

Hi Surya,

Thank you for the sample code. I tried using your code to test your issue but unable to find any issue using below mentioned source code. Kindly use the below mentioned source code and test the issue at your end.

[C#]
Aspose.Pdf.Generator.Pdf testPdf = new Pdf();
Aspose.Pdf.Generator.Section testsec = testPdf.Sections.Add();

testPdf.TextInfo.FontName = "Arial";
testsec.TextInfo.FontName = "Arial";

testsec.Paragraphs.Add(new Aspose.Pdf.Generator.Text(testsec, "This text is used for testing"));

testPdf.Save(@"d:\pdffiles\test.pdf");

You may check the following documentation link for details and code snippets as per your requirement.

Text Formatting

Please do let us know if you need any further assistance.

Thanks & Regards,