抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

使用 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')'

解决办法

  1. 安装 NuGet 包:System.Text.Encoding.CodePages

  2. 在调用的库前先执行这一句:

    using System.Text;
    public void Action()
    {
    
        Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
        using (PDFFile pdfFile = PDFFile.Open(pdfFullPath))
        {
            ...   
        }
    }

评论