Embed uninstalled fonts by font document when convert word to PDF

2016-01-21 08:27:32 Written by  support iceblue
Rate this item
(0 votes)

We have already shown you how to use uninstalled font by font document when converting word to PDF. Now starts from Spire.Doc 5.6.3, Spire.Doc newly supports to set the font styles for the uninstalled fonts when convert word documents to PDF. Here comes to the code snippets of how to set the font styles for embed the uninstalled fonts by font documents:

Note: Before Start, please download the latest version of Spire.XLS and add Spire.xls.dll in the bin folder as the reference of Visual Studio.

Step 1: Create a new workbook and load from file.

Document document = new Document();
document.LoadFromFile("Testing.docx");

Step 2: Create an instance for class ToPdfParameterList named parms.

ToPdfParameterList parms = new ToPdfParameterList();

Step 3: Define the path of the uninstalled fonts.

   {
      new PrivateFontPath("Century Gothic",FontStyle.Regular,"fonts\\GOTHIC.TTF"),
      new PrivateFontPath("Century Gothic",FontStyle.Bold,"fonts\\GOTHICB.TTF"),
      new PrivateFontPath("Century Gothic",FontStyle.Italic,"fonts\\GOTHICI.TTF") ,
      new PrivateFontPath("Century Gothic",FontStyle.Bold|FontStyle.Italic,"fonts\\GOTHICBI.TTF")
                                                
   };

Step 4: Save the document to file and launch to preview it.

document.SaveToFile("Testing.pdf", parms);
System.Diagnostics.Process.Start("Testing.pdf");

Effective screenshot of the embedded uninstalled fonts by setting the font style after converts to PDF:

How to embed uninstalled fonts by font document when convert word to PDF

Additional Info

  • tutorial_title:
Last modified on Friday, 03 September 2021 03:59