Fonts are missing in pdf after word to pdf conversion

we have created one azure web app which convert word to pdf using aspose but after conversion “Source sans pro” font is missing in pdf.
same issue we were reproduce it on local but after installation of “Source sans pro” font on local it worked, but on azure web app we can’t install fonts.
how can we resolve this issue.

@Somnath.kamthe

Cause

The issue of missing fonts in the PDF after converting a Word document is due to the “Source Sans Pro” font not being available in the Azure web app environment. Unlike your local machine, where you can install fonts, Azure web apps do not allow direct installation of fonts.

Solution

To resolve this issue, you can embed the font directly into the PDF during the conversion process. This ensures that the font is included in the PDF file, regardless of whether it is installed on the server.

Code

Here’s a code snippet that demonstrates how to embed fonts when converting a Word document to PDF using Aspose.Words:

// Load the document
Document doc = new Document("input.docx");

// Create PdfSaveOptions and set the font embedding options
PdfSaveOptions options = new PdfSaveOptions();
options.setEmbedFullFonts(true); // Embed all font glyphs

// Save the document as PDF
doc.save("output.pdf", options);

Make sure to replace "input.docx" with the path to your Word document and "output.pdf" with the desired output path for the PDF.

Next Steps

  1. Implement the above code in your Azure web app.
  2. Test the conversion to ensure that the “Source Sans Pro” font appears correctly in the generated PDF.
  3. If you encounter any further issues, check the font licensing to ensure it allows embedding.

Please proceed with these steps, and let me know if you need any further assistance!

@Somnath.kamthe Please see our documentation to learn where Aspose.Words looks for fonts:

You should put these font in the environment where the document will be processed. For example you can put them into a separate folder and use this folder with fonts as fonts source as described in the article above.

Hi Team,
We have azure web app and below is code we have used to resolve the font issue but still not resolved.

attached input and output pdf.
Post - EOC_H1099009000 (8) 1.Docx (357.3 KB)

Converted_Post - EOC_H1099009000 (08) (1).pdf (4.5 MB)

This is working fine on local windows machine but after deployment on web app issue not resolved.
Do we have any other solution to fix web app font issue.

@Somnath.kamthe You can check following code:

FontSettings.DefaultInstance.SetFontsSources(new FontSourceBase[]
{
    new SystemFontSource(), new FolderFontSource("/path/to/fonts/", true, 1)
});

Also, you can load fonts one by one and pass them to Aspose.Words using StreamFontSource or MemoryFontSource .

Following links can be helpfull: