微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iText 7.1.14 'SymbolEncoding' 不是受支持的编码名称

如何解决iText 7.1.14 'SymbolEncoding' 不是受支持的编码名称

我正在 PowerShell 中使用 iText7 读取一些 Chase 银行对帐单,使用以下代码

$path = .\blabla.pdf
Add-Type -Path "$PSScriptRoot\dll\itext.kernel.dll" #dll loads nicely.
$pdfDoc  = [iText.Kernel.Pdf.PdfDocument]::new([iText.Kernel.Pdf.PdfReader]::new($path))
$text = for ($a = 1; $a -le $pdfdoc.GetNumberOfPages(); $a++) {
    [iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor]::GetTextFromPage($pdfDoc.GetPage($a))
}

iText7 可以很好地读取大多数语句,但从某些语句中我得到以下错误

ErrorRecord                 : Exception calling "GetTextFromPage" with "1" argument(s): "'SymbolEncoding' is not a supported encoding name. For       
                              information on defining a custom encoding,see the documentation for the Encoding.RegisterProvider method.
                              Parameter name: name"
WasThrownFromThrowStatement : False
Message                     : Exception calling "GetTextFromPage" with "1" argument(s): "'SymbolEncoding' is not a supported encoding name. For       
                              information on defining a custom encoding,see the documentation for the Encoding.RegisterProvider method.
                              Parameter name: name"
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              : System.ArgumentException: 'SymbolEncoding' is not a supported encoding name. For information on defining a custom       
                              encoding,see the documentation for the Encoding.RegisterProvider method.
                              Parameter name: name
                                 at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
                                 at System.Globalization.EncodingTable.GetCodePageFromName(String name)
                                 at iText.IO.Util.IanaEncodings.GetEncodingEncoding(String name)
                                 at iText.IO.Util.EncodingUtil.ConvertToBytes(Char[] chars,String encoding)
                                 at iText.IO.Font.PdfEncodings.ConvertToBytes(String text,String encoding)
                                 at iText.IO.Font.FontEncoding.FillNamedEncoding()
                                 at iText.IO.Font.FontEncoding.CreateFontEncoding(String baseEncoding)
                                 at iText.Kernel.Font.PdfType1Font..ctor(PdfDictionary fontDictionary)
                                 at iText.Kernel.Font.PdfFontFactory.CreateFont(PdfDictionary fontDictionary)
                                 at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.GetFont(PdfDictionary fontDict)
                                 at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.SetTextFontOperator.Invoke(PdfCanvasProcessor processor,PdfLiteral operator,IList`1 operands)
                                 at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.InvokeOperator(PdfLiteral operator,IList`1 operands)
                                 at iText.Kernel.Pdf.Canvas.Parser.PdfCanvasProcessor.ProcessContent(Byte[] contentBytes,PdfResources resources)
                                 at iText.Kernel.Pdf.Canvas.Parser.PdfTextExtractor.GetTextFromPage(pdfpage page,ITextExtractionStrategy strategy,IDictionary`2 additionalContentOperators)
                                 at CallSite.Target(Closure,CallSite,Type,Object )
TargetSite                  : Void ConvertToMethodInvocationException(System.Exception,System.Type,System.String,Int32,System.Reflection.MemberInfo)
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception,Type    
                              typetoThrow,String methodName,Int32 numArgs,MemberInfo memberInfo)
                                 at CallSite.Target(Closure,Object )
                                 at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087

我完全不知所措。我不是程序员,我一生都无法弄清楚如何解决这个问题。我什至找不到几乎所有与 iText 相关的帖子都带有此错误 (One post)。我可以在 PowerShell 中做些什么来解决这个问题?

我希望我能够提供可以重现此错误的 PDF,但我在 Chase 银行对帐单上遇到了此错误,所以......是的。作为参考,我在 (07,2015 - 10,2016 和一些 2018 年) 的银行对帐单中发现了错误

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。