Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Tue May 07, 2019 11:50 am
Hai i need to change font family in html to pdf converting using c#
-

ceipalAdmin
-
- Posts: 92
- Joined: Mon Apr 22, 2019 6:31 am
Wed May 08, 2019 10:07 am
Hi,
Thanks for your inquiry.
Please use the code below to change font when converting HTML to PDF. Just feel free to write back if there is any question.
- Code: Select all
Document document = new Document();
document.LoadFromFile("test.html", FileFormat.Html, XHTMLValidationType.None);
foreach (Section section in document.Sections)
{
foreach (Paragraph paragraph in section.Paragraphs)
{
foreach (DocumentObject docObject in paragraph.ChildObjects)
{
if (docObject.DocumentObjectType == DocumentObjectType.TextRange)
{
TextRange text = docObject as TextRange;
text.CharacterFormat.FontName = "Calibri";
}
}
}
}
document.SaveToFile("HtmlFileToPDF.pdf", FileFormat.PDF);
Sincerely,
Nancy
E-iceblue support team
-


nancy.yang
-
- Posts: 184
- Joined: Wed Apr 03, 2019 2:33 am