iText 7汉字并与现有pdf模板合并

iText 7 Chinese characters and merge with existing pdf template

我必须重新表述我的问题,基本上我的要求非常直接,我想在 iText7 生成的 pdf 文件中显示亚洲字符。

截至目前,我已经下载了 NotoSansCJKsc-Regular.otf 文件并分配了一个变量来保存路径,下面是我的代码:

public static string FONT = @"D:\Projects\Resources\NotoSansCJKsc-Regular.otf";

PdfWriter writer = new PdfWriter(@"C:\temp\test.pdf");
PdfDocument pdfDoc = new PdfDocument(writer);
Document doc = new Document(pdfDoc, PageSize.A4);

PdfFont fontChinese = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H);
doc.SetFont(fontChinese);

但我现在面临的问题是每当代码运行到此部分时:

PdfFont fontChinese = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H);

我总是收到此错误:由于 I/O 设备错误,无法执行请求。这个错误对我来说没有意义,我正在努力寻找解决方案,请问这里有人有类似的问题吗,代码在 C# 中。

非常感谢。

我可以确认上面的代码按预期工作,我最初下载的 .otf 文件已损坏,因此出现上述错误。