c# - iText7:无法读取许可证 key json 文件

标签 c# .net pdf itext itext7

我正在尝试在我的 Dot Net 应用程序(C# 编程语言)中加载 iText7 的许可证文件。我已经使用下面提到的语法给出了 json 文件的正确路径。

LicenseKey.LoadLicenseFile(new FileStream(@"pathtofile\iTextKey.json", FileMode.Open)); 

我收到的错误消息是:

Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at iText.License.Util.XmlWorker..ctor(Stream stream)
   at iText.License.LicenseKey.LoadLicenseFileInternal(Stream licenseIs)
   at iText.License.LicenseKey.LoadLicenseFile(Stream licenseIs)

我验证了 JSON 文件,它看起来没问题。

任何解决此问题的帮助都会有很大帮助。

最佳答案

尽管通过 nuget 包安装了 iText v7.2.4 和 iText.Licensing.Base v4.0.4,但我还是遇到了同样的错误。结果我的解决方案也有旧版本的 iText(通过导入的库),并且使用的 LoadLicenseFile 方法来自该旧库。

换句话说,请确保您调用的完全限定方法是iText.Licensing.Base.LicenseKey.LoadLicenseFile

关于c# - iText7:无法读取许可证 key json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73731062/

相关文章:

c# - 如何使用 Google API 版本 2 在 Google 日历中添加 “Where” 条目

.NET 进程内存使用 = 5x CLR 堆内存?

javascript - 在浏览器中编辑*现有* PDF

vb.net - ReportViewer.LocalReport.Render ("PDF")

c# - 使用 TPL 和进程外 COM 服务器的 C# WPF 应用程序出现奇怪问题

c# - 处理 IConnectableObservable 不会发送 OnComplete

c# - 从 ItemsControl 中的模板获取项目

c# - 如果方法名称以 "Response"结尾,WCF 会中断吗?

c# - 并发队列性能不佳

r - 使用R下载pdf文件的问题