Under Review
Last Updated: 10 Feb 2025 14:43 by ADMIN
gerry
Created on: 17 Jan 2025 12:10
Category: PdfProcessing
Type: Bug Report
0
System.IO.IOException: I/O error when opening file 'C:\WINDOWS\FONTS\MSYH.TTC'.

As Ghiath reported in the forum thread, I am seeing this same error.

I am using RadFixedDocument and am generating a PdfFormatProvider. As Ghiath mentioned it will work fine (weeks, months) and then it seems the the font file is locked and it cannot export.

System.IO.IOException: I/O error when opening file 'C:\WINDOWS\FONTS\MSYH.TTC'.

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.IOException: I/O error when opening file 'C:\WINDOWS\FONTS\MSYH.TTC'.
   at MS.Internal.FontCache.FileMapping.OpenFile(String fileName)
   at MS.Internal.FontCache.FontSource.GetUnmanagedStream()
   at System.Windows.Media.GlyphTypeface.ComputeSubset(ICollection`1 glyphs)
   at Telerik.Windows.Documents.Fixed.Model.Fonts.CidType2Font.ComputeSubset(IEnumerable`1 usedCharacters)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontStream.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontStream.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.CreateFontFile(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.ExportFontFile(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.FontDescriptor.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.CidFontObject.CopyPropertiesFrom(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.Fonts.Type0FontObject.CopyPropertiesFromOverride(IPdfExportContext context, FontBase font)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.WriteFontsFromContext(PdfWriter writer, IPdfExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
 

It will throw the exception on the line where it is doing the export. The document is typically a multi-page document with images, etc. As I mentioned it might work fine for weeks and then once it fails the only solution is to recycle the web service.

5 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 10 Feb 2025 14:43

Hi, Gerry,

Thank you for confirming that you are not using a multi-threading scenario and the exception always point to the same MSYH.TTC font.

I have installed the Microsoft YaHei & Microsoft YaHei UI font family on my machine:

I have prepared a sample project and created a RadFixedDocument that uses the font. The document is successfully exported on my end:

I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem? Feel free to modify the project in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

Off topic, please have in mind that Telerik Document Processing libraries are compatible across different .NET implementations, including .NET Framework, .NET Standard .NET Core, .NET 6, .NET 8, and newer versions. However, the libraries are distributed with different Telerik UI products. Depending on the target framework of your project (NET Framework, .NET Standard .NET Core, .NET 6, etc.), you should pick the library version accordingly.

For web services, I would recommend you using the .NET Standard version of the assemblies. However, if you choose to follow this approach further, there are some limitations with the .NET Standard version. The PdfProcessing library needs to have access to the specific font's data so that it can read it and add it to the PDF file. That is why, to allow the library to create and use fonts, you will need to provide an implementation of the FontsProviderBase abstract class and set this implementation to the FontsProvider property of FixedExtensibilityManager:

I believe that you are currently using RadPdfProcessing in a .NET Framework project.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

gerry
Posted on: 05 Feb 2025 14:39

<<

Usually such unexpected and random errors occur in multi-threaded scenarios. Is this the same case you have?>>

It is a single-threaded web request to create a document. However, as you know IIS can handle many such requests and some could be simultaneously. But each request is very simple--no multithreading in the request.

<<

I have noticed that the error indicates the following font:  C:\WINDOWS\FONTS\MSYH.TTC. Is the exception each time caused by the same font or is it a random font?

>>

It is always just that font.

<<Would it be possible to provide a sample document? Could you please confirm that you are using the latest version of RadPdfProcessing?

>>

I will see what I can do on providing a sample. I think the only way to reproduce it would be to put the document processing under a load tester of some sort on a web service.

We are not running the latest version of https://www.telerik.com/document-processing-libraries. We are using 2 DLLs - telerik.windows.documents.core and telerik.windows.document.fixed. From reading the release notes it doesn't appear that much has changed in the releases between what we're running and the current version. We also don't want to push a new version out until we can verify if this bug is addressed first.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 30 Jan 2025 12:09

Hello, Gerry,

Indeed, looking into the source code is a valid part of the investigation process while troubleshooting a potential issue. I can assure you that we have already performed such a step and discussed with the team if any potential problematic points exist. However, sometimes a specific part of a certain document or a certain glyph may be the difference that causes the unexpected behavior. Would it be possible to provide a sample document? Could you please confirm that you are using the latest version of RadPdfProcessing? 

Usually such unexpected and random errors occur in multi-threaded scenarios. Is this the same case you have?

I have noticed that the error indicates the following font:  C:\WINDOWS\FONTS\MSYH.TTC. Is the exception each time caused by the same font or is it a random font?

I understand that reproducing such a specific behavior that occurs randomly is not easy. However, it is an important part to validate any potential fix candidates.

Thank you in advance for your understanding and cooperation.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

gerry
Posted on: 23 Jan 2025 16:21

Hello--I did not expect that you would be able to reproduce the problem with a simple test. As has been shown by multiple people the error occurs randomly.

I would ask that you look at the source code for PdfFormatProvider Export to see how it is failing on trying to open the font. Under what circumstances could the font file open fail?

Thank you,

Gerry

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 17 Jan 2025 12:57

Hi, Gerry,

I am sorry to hear that you are facing any difficulties with the RadFixedDocument when using RadPdfProcessing.

Following the provided information, I was unable to reproduce the issue you are facing. Please refer to the attached gif file illustrating the behavior on my end with the specified version. I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem? Feel free to modify the project in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

Off topic, I would like to provide some useful details to avoid any confusion. 

Telerik Document Processing Libraries offer PdfFormatProvider which makes it easy to import/export a RadFixedDocument from/to PDF format, preserving the entire document structure and formatting. It is available for:

RadWordsProcessing: The PdfFormatProvider class of RadWordsProcessing is located in the Telerik.Windows.Documents.Flow.FormatProviders.Pdf namespace. RadFlowDocument supports only the export option to PDF format. Importing a PDF document to RadFlowDocument is not supported.

RadSpreadProcessing: The PdfFormatProvider class of RadSpreadProcessing is located in the Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf namespace. The Workbook supports only the export to PDF format. Importing a PDF document to Workbook is not supported.

RadPdfProcessing: The PdfFormatProvider class of RadPdfProcessing is located in the Telerik.Windows.Documents.Fixed.FormatProviders.Pdf namespace.

On the other hand, RadRichTextBox from the UI for WPF suite also offers a PdfFormatProvider class located in the Telerik.Windows.Documents.FormatProviders.Pdf namespace.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Attached Files: