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

Free Support Forum - aspose.com

Custom font isn't coming through

I have the following code:

WordDocument document = new WordDocument(documentStream);
FontSettings settings = new FontSettings();
ArrayList fontSources = new ArrayList(settings.GetFontsSources());

FolderFontSource folderFontSource = new FolderFontSource((UtilityExtensions.GetAssemblyDirectory() + "\\Fonts\\"), true);

fontSources.Add(folderFontSource);

FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));

settings.SetFontsSources(updatedFontSources);
document.Save(updatedDocument, Aspose.Pdf.SaveFormat.Pdf);

FontFolderSource is getting an MICR TT font and it is indeed present in the folder that is being added to the list. However when I view my saved PDF the font isn’t showing. I don’t have it installed on my computer right now because this will be deployed to an Azure worker and I want to make sure it will process correctly if not installed.

@jimmyv,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach (upload) the following resources here for testing:

  • Your input Word document
  • Font file(s) used in this Word file
  • Aspose.Words 18.5 generated output PDF file showing the undesired behavior.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information.

Thanks, here are the requested documents.Test Sample Apsose.zip (119.3 KB)

Tagging reply, see above.

@jimmyv,

After an initial test, we are also unable to set custom defined fonts folder to be used during rendering on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-16905. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Thanks.

Do you have an ETA on this? Documentation clearly shows I should be able to do what I intend and this is crucial for the business. We bought a Total license on good faith that everything would work as expected.

@jimmyv,

We have noted your concerns.

Currently this issue (WORDSNET-16905) is pending for analysis and is in the queue. There are no estimates available at the moment. Once the analysis of this issue is completed, we may then be able to share estimates with you. Rest assured, we will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.

@jimmyv,

Please either use static font settings instance FontSettings.DefaultInstance or specify per-document instance doc.FontSettings = fontSettings. Creating new instance of FontSettings class and not assigning it to the document do not change anything. For example, the following code works fine on our end:

Document doc = new Document(@"D:\Temp\Test Sample Apsose\New Check.docx");
            
// Retrieve the array of environment-dependent font sources that are searched by default. For example this will contain a "Windows\Fonts\" source on a Windows machines.
// We add this array to a new ArrayList to make adding or removing font entries much easier.
FontSettings fontSettings = new FontSettings();
ArrayList fontSources = new ArrayList(fontSettings.GetFontsSources());

// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts. 
FolderFontSource folderFontSource = new FolderFontSource(@"D:\Temp\Test Sample Apsose\Test Sample\Fonts\", true);

// Add the custom folder which contains our fonts to the list of existing font sources.
fontSources.Add(folderFontSource);

// Convert the Arraylist of source back into a primitive array of FontSource objects.
FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));

// Apply the new set of font sources to use.
fontSettings.SetFontsSources(updatedFontSources);

doc.FontSettings = fontSettings;

doc.Save(@"D:\Temp\Test Sample Apsose\18.5.pdf");

GOT IT! Thanks!