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

Free Support Forum - aspose.com

Install Fonts used in Word Document for Perfect Word to PDF Rendering on Azure using C# .NET API

We have been using Aspose.Words for years to save Word documents to PDF format for archiving purpose on our Web server.

We recently migrated hosting companies to use Microsoft Azure VM’s running Windows Server 2019 Datacenter. Since then, the formatting on the PDF output is changed. The font width remains unchanged but the line spacing is incresaed so that multiple lines are moved to the next page.

However, this behaviour does not occur on my development PC. The output PDF format is correct. I have now tried 2 different Azure VM’s and the format change occurs on both.

Aspose.Words 18.9 was being used originally but I have now upgraded it to 19.12. The result is the same - works on the dev PC and fails on the Azure Server.

It fails using either .doc or .docx word files.

The code to demonstrate this is simple :

// Open Word Doc
string docfile = @“C:\Testing\Format Test.docx”;
string pdffile = @“C:\Testing\Format Test.pdf”;

Aspose.Words.Document wordDoc = new Aspose.Words.Document(docfile);

// Save as PDF
wordDoc.Save(pdffile, SaveFormat.Pdf);

// free up the document
wordDoc = null;

Is there a new setting required fro Azure Servers?

@bobrog,

Please ZIP and upload your sample input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Thank you for your prompt response Awais. The issue has been resolved.

The word documents were using Lucida Sans Font. By default, the server has Lucida Sans Unicode Regular font installed. The other Lucida Sans fonts had been copied to the \Windows\Fonts folder but were not being recognised, instead being replaced by the Unicode font when the document was converted to PDF.

Deleting the newly copied Lucida Sans fonts from \Winfodws\Fonts and then using the correct “Add New Font” process with permissions for “All users” resolved the problem, but only after IIS was restarted.

@bobrog,

It is great that you were able to resolve this issue on your end. Please let us know any time you have any further queries in future.

Also, please check the following article:

1 Like