Font Courier New in Docx is not transferred to the pdf

I have created a Docx that contains the Courier New font. If I load this document and save it as a Pdf, this font is not adopted but converted to Times New Roman. Do I have to set certain PdfSaveOptions? After some research on the Internet, I have tried many things, but without success.

var asposePDF = new Document(this.destination);
// ???
PdfSaveOptions sv = new PdfSaveOptions();
asposePDF.Save(this.destinationPDF, sv);

Any help would be greatly appreciated.

@AWemhoff Usually, the such problems occur because the fonts used in your input document are not available on the machine where document is converted to PDF. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

If after providing the required fonts the problem still persist, please attach your input and output documents here for testing. We will check the issue and provide you more information.

Thank you for the quick reply, I will take a look at the tips.
Just a quick question afterwards: I also created the Docx with Aspose.Words. Why is there no problem when creating Docx, but there is with Pdf?

@AWemhoff Fonts are normally not embedded into DOCX documents, only font names are specified and the consumer applications, like MS Word or OpenOffice, use fonts available in the system to render the document. So the way how the document look when you open it depend on the fonts available in the environment where the document is opened.

Hello,
The problem has not been solved and I must come back to it.
The odd thing is that the Docx (in which the font is displayed correctly) and the PDF created from it, were created on the same machine at almost the same time. When I open the Docx with Word and convert it myself, the PDF looks as I would expect. I have attached the docx-file and the pdf file as well, in case it helps. The document is saved as seen on my first post.
Thank you in advance.

testOutput.docx (68.9 KB)

testOutput.pdf (127.8 KB)

@AWemhoff Thank you for additional information.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26629

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The problem occurs because font name in your document is specified as CourierNew, but actual font name is Courier New. You can work the problem around by adding custom substitution rule. For example see the following code:

FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("CourierNew", "Courier New");

Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.pdf");

Thank you very much, that has solved the problem. Strange that Word accepts the wrong name, but it goes wrong when converting to PDF.

@AWemhoff Font names is specified as simple string, so you can type any font name. But in this particular case MS Word manages to resolve the correct font.

The issues you have found earlier (filed as WORDSNET-26629) have been fixed in this Aspose.Words for .NET 24.3 update also available on NuGet.