'Open type font collections are causing errors with PdfPrintingCore "Font has no usable platform or encoding ID. It cannot be used with PDFEdit."
When printing any text in font type Cambria (or another .ttc font type) on Windows I get the following error message:
Font has no usable platform or encoding ID. It cannot be used with PDFEdit.
What should I do differently with printing to change this?
With the NuGet package PdfPrintingCore. The website is pdfprinting.netThe specific line of code that throws the exception is on creating an XFont:
var pdfFont = new XFont("Cambria", 10, XFontStyle.Regular, XPdfFontOptions.UnicodeDefault);
I've tried to create the XPdfFontOptions to have embed always:
var options = new XPdfFontOptions(XPdfFontOptions.UnicodeDefault, PdfFontEmbedding.Always);
Hoping the font can be used when it's embedded. But this constructor has been deprecated and it cannot be compiled anymore. There's no alternative provided in the documentation.
I've tried converting the .ttc to a .ttf file with a website. Since the c stands for collection, it should be possible to unpack the fonts into their separate files. This produces a Cambria-01.ttf and a CambriaMath-02.ttf file. Using them instead causes the same error.
Steps taken to implement the extraction option: Copy the font to a regular folder (the fonts folder behaves differently), which results in several files, extracting the ttc, renaming the extracted files to remove the enumeration, copy them back (the additional files and the extracted files), Windows displays 'installing font' popup, I can still use the font in Word.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|