背景
开发工具:Visual Studio 2019。
创建Console App(.NET Framework4.6.1),使用Nuget下载了iText7组件,用于生成pdf文件。
错误场景
创建iText.Kernel.Pdf.PdfWriter时遇到以下报错:
iText.Kernel.Exceptions.PdfException: 'Unknown PdfException.'
NotSupportedException: Either com.itextpdf:bouncy-castle-adapter or com.itextpdf:bouncy-castle-fips-adapter dependency must be added in order to use BouncyCastleFactoryCreator
按照字面意思理解是,为了使用BouncyCastleFactoryCreator,需要下载com.itextpdf:bouncy-castle-adapter或com.itextpdf:bouncy-castle-fips-adapter中的一个。
解决方法
如果下载 Itext7.bouncy-castle-fips-adapter,仍然会报错。
最后通过下载itext7.bouncy-castle-adapter解决了问题。