【问题标题】:Syncfusion Xamarin 'Value cannot be null. Parameter name: stream' during adding imageSyncfusion Xamarin '值不能为空。参数名称:添加图片时的stream'
【发布时间】:2020-09-14 06:19:02
【问题描述】:

我想从流中加载图像到 pdf。当我尝试这样做时,我得到一个错误

System.ArgumentNullException: 'Value cannot be null.
Parameter name: stream'

这是我的代码

Stream imageStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("MyApp.Resources.drawable.image.png");
            
PdfImage image = PdfImage.FromStream(imageStream);   <---- here is error

g.DrawImage(image, new PointF(20, 20));

【问题讨论】:

    标签: image pdf xamarin stream syncfusion


    【解决方案1】:

    首先,通过这种方式,您需要将图像放在 Forms 项目而不是 Android 项目中。在我的演示中,我将图像放在文件夹 Assets 中。代码应如下所示

    var assembly = this.GetType().GetTypeInfo().Assembly;
    Stream s = assembly.GetManifestResourceStream("MyApp.Assets.icon.png");
    

    另外,确保图片的构建动作是Embeddded Resource

    右击图片->属性

    【讨论】:

      【解决方案2】:

      我们已经检查了从流中将图像加载到 pdf 的问题,但它工作正常。并且图像被加载并插入到 Pdf 文档中,并确保图像的构建操作是 Embeddded Resource。请尝试以下文档中的示例并告诉我们结果。

      知识库https://www.syncfusion.com/kb/10375/how-to-insert-an-image-into-pdf-in-xamarin

      UGhttps://help.syncfusion.com/file-formats/pdf/working-with-images

      注意:我在 Syncfusion 工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-23
        • 2018-08-15
        • 1970-01-01
        • 1970-01-01
        • 2019-02-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多