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

在使用 Itext7 创建 pdf 时,在 xamarin 形式的 Android 中出现异常

如何解决在使用 Itext7 创建 pdf 时,在 xamarin 形式的 Android 中出现异常

我在 Xamarin 表单应用程序中使用 itext7 NuGet 来创建 PDF。以下代码在 UWP 中运行良好,但在 Android 中我收到此异常

System.ArgumentNullException: '值不能为空。 参数名称:程序集'{System.ArgumentNullException:值不能为空。参数名称:程序集在 Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(System.Reflection.Assembly 程序集) [0x00003] 在 :0 在 Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault () [0x0000a] in :0 at System.Lazy`1[T].ViaFactory(System.Threading.LazyThreadSafetyMode 模式) [0x0001c] 在 /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:327 }

        PdfWriter writer = new PdfWriter("/storage/emulated/0/Android/data/com.companyname.pdfsample/files/Sample.pdf");
        PdfDocument pdf = new PdfDocument(writer);
        Document document = new Document(pdf);
        Paragraph header = new Paragraph("HEADER1\nHEADER2");
        document.Add(header);
        document.Close();

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