How do I embed normal Courier New font and NOT CourierNewPSMT

I need to embed either the “Courier” or “Courier New” font within saved PDF documents, as the font “CourierNewPSMT” that Aspose.Words replaces them with is NOT a true monospaced font.

We are converting plain text, or RTF, documents to PDF that come from hundreds of individual sources that use spaces to align columns of tabular data that have clinical significance.

The replacement of the font has the result that the data is no longer properly aligned (due to the spaces being narrower), and as such presents a potential clinical risk to patient health.

I have attempted to resolve in both Aspose.Words version 17.7 and 19.1, but it appears impossible to save a PDF with a true monospaced font.

Please advise on how to resolve, or we will not be able to use your product.

@greg.chappell

Thanks for your inquiry. Please note that the CourierNewPSMT is a PostScript name of the “Courier New” font which should be written to PDF according to specification. Aspose.Words follows the specification. This is reason you are getting this font in output PDF.

If you are using different fonts, you can use FontSettings.SetFontSubstitutes method to substitute (alternative) font names for given original font name. Please check the following code snippet. We suggest you please check the members of FontSettings class. Hope this helps you.

FontSettings fontSettings = new FontSettings();
fontSettings.SetFontSubstitutes("original font name", new String[] { "alternative font name" });

Thanks for your reply.

I don’t think you fully understand the problem.

CourierNewPSMT is NOT a monospaced font, and as such is useless.

Courier New is a monospaced true type font, and is available on millions of devices.

You cannot use font substitution to replace CourierNewPSMT with Courier New within the PDF, as it simply uses CourierNewPSMT again.

Is there an option to prevent the embedding of CourierNewPSMT as the replacement for Courier New?

If not, then your product is unsuitable for the millions of documents per year that we have to process.

@greg.chappell

Thanks for your inquiry. Please ZIP and attach your input Word document along with problematic and expected output PDF files here for testing. We will investigate the issue on our side and provide you more information.

Thanks for the reply Tahir.

Please find attached a ZIP of a solution that converts our example RTF to PDF using Aspose.Words.
TEST Aspose.Words CourierNew.zip (1.7 MB)

If you open the example source RTF file “CourierNewTabulatedData.rtf” using:
WordPad – Margins and Colours/Styles and Font are preserved, and the tabulated data is correctly aligned
MS Word – Margins and Colours/Styles and Font are preserved, and the tabulated data is correctly aligned

If you open the Aspose.Words generated result PDF file “CourierNewTabulatedData.pdf” using:
Adobe Reader – Margins and Colours/Styles are preserved BUT the Font is replaced with CourierNewPSMT, and the tabulated data is NOT aligned due to the character being narrower
PDF-Viewer – Margins and Colours/Styles are preserved BUT the Font is replaced with CourierNewPSMT, and the tabulated data is NOT aligned due to the character being narrower

Although the alignment discrepancy appears minor, in a more complex report it has the potential to be misinterpreted by the Doctor, which can then lead to dangerous clinical outcomes for the patient.

The expected result:
The PDF generated displays almost identical to the original RTF. In other words, uses the same monospaced font as the RTF.

@greg.chappell

Thanks for sharing the detail. Please note that Aspose.Words mimics the behavior of MS Word. If you convert your RTF to PDF using MS Word, you will get the same output. Please check the attached output PDF files generated by Aspose.Words and MS Word 2016.output PDF.zip (109.1 KB)

We have logged this feature request as WORDSNET-18022 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Thanks Tahir, much appreciated.
We would have preferred to remain within a single product to transform the RTF to PDF, but for now we have resorted to using a free library to get from RTF to HTML, and then another commercial product to get from HTML to PDF to obtain the correct formatting.

@greg.chappell

Thanks for your inquiry. Please share your expected output PDF file. This will help us to implement the requested feature. Thanks for your cooperation.

@greg.chappell

Thanks for your patience. Your issue is not related to embedded fonts, but rather it is related to Word’s setup. We suggest you please use the CompatibilityOptions.BalanceSingleByteDoubleByteWidth property as shown below to get the desired output. Hope this helps you.

Document workDocument = new Document(MyDir + @"CourierNewTabulateData.rtf");
workDocument.CompatibilityOptions.BalanceSingleByteDoubleByteWidth = false;
wordDocument.Save(@"output.pdf");

Thanks @tahir.manzoor
I’m re-architecting our implementation now, so that I can run our 800 files through and verify the results, but at first glance things are looking good.

@greg.chappell

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.