DOCX to PDF conversion - how to set font path for missing fonts in .NET

I am using desktop version of the converter api in dotnet. I wish to add any missing fonts at certain path and then set it as path for fonts in PdfConvertOptions class but I didn’t found any fontPath property in this class so how can I do that.

PdfConvertOptions options = new PdfConvertOptions();
options.Watermark.Transparency = 0.60;
options.Watermark.Left = 100;
options.Watermark.Top = 550;
options.FontPath = //No Font Path Property

fontPath.PNG (19.3 KB)

1 Like

@ashishk2909

Please have a look at the following code:

GroupDocs.Conversion.Options.Load.LoadOptions getLoadOptions() => new PdfLoadOptions
{
    DefaultFont = "Open Sans",
    FontSubstitutes = new List<FontSubstitute>
    {
        FontSubstitute.Create("Algerian","Verdana")
    }
};
using (Converter converter = new Converter("test.pdf", getLoadOptions))
{
    PdfConvertOptions options = new PdfConvertOptions();
    converter.Convert("output.pptx", options);
}

This is how you manage font substitution. Let us know in case of any issue.

Thanks for your Reply but if there is any way through which instead of replacing the fonts with the fonts we have , we can copy the original fonts at some path like local drive or azure containers and get it referred with help of some properties for ex. fontPath.

1 Like

@ashishk2909

We are investigating this scenario. Your investigation ticket ID is CONVERSIONNET-4741. You’ll be notified in case of any update.

@ashishk2909

Using API version 24.3 you can follow below approach:

const string source = "sample.pdf";
// Create ConverterSettings object and add font directories
var settings = new ConverterSettings();
settings.FontDirectories.Add(@"c:\fonts"); // Specify the directory where fonts are located
settings.FontDirectories.Add(@"c:\additional-fonts"); // Additional font directories can be added if needed

// Using statement ensures proper disposal of resources
using (var converter = new Converter(source, () => settings))
{
    var options = new PresentationConvertOptions();
    converter.Convert("converted.pptx", options); // Convert the PDF to PowerPoint presentation format
}

The issues you have found earlier (filed as CONVERSIONNET-4741) have been fixed in this update. This message was posted using Bugs notification tool by nikola.yankov