使用 PDFRender4NET 插件读取 PDF 文件的时候提示错误 ❌:
System.ArgumentException: ''windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')'
解决办法
安装 NuGet 包:
System.Text.Encoding.CodePages
在调用的库前先执行这一句:
using System.Text; public void Action() { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); using (PDFFile pdfFile = PDFFile.Open(pdfFullPath)) { ... } }