Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用MigraDoc在PDF中添加流(无文件)图像?_C#_Pdf_Migradoc - Fatal编程技术网

C# 如何使用MigraDoc在PDF中添加流(无文件)图像?

C# 如何使用MigraDoc在PDF中添加流(无文件)图像?,c#,pdf,migradoc,C#,Pdf,Migradoc,当我使用以下代码时,它在PDF中不显示任何图像。 这是我的密码 private static void RenderHtmlToImage(string html, Paragraph paragraph, int pageCnt) { System.Drawing.Image image = HtmlRender.RenderToImageGdiPlus(html); //var tempImagefile = tempImagePath + "

当我使用以下代码时,它在PDF中不显示任何图像。
这是我的密码

    private static void RenderHtmlToImage(string html, Paragraph paragraph, int pageCnt)
    {
        System.Drawing.Image image = HtmlRender.RenderToImageGdiPlus(html);
        //var tempImagefile = tempImagePath + "\\tempImage_" + pageCnt + ".png";
        //image.Save(tempImagefile, ImageFormat.Png);
        //paragraph.AddImage(tempImagefile);

        byte[] imageArray = imageToByteArray(image);
        string imageFilename = "base64:" + Convert.ToBase64String(imageArray);
        paragraph.AddImage(imageFilename);
    }

    public static byte[] imageToByteArray(System.Drawing.Image imageIn)
    {
        MemoryStream ms = new MemoryStream();
        imageIn.Save(ms, ImageFormat.Png);
        return ms.ToArray();
    }
当我将图像保存到本地文件夹时,效果非常好。

我也关注了这个链接,但它对我不起作用。

链接站点的代码运行良好


确保您使用的是最新版本(目前为1.50 RC2)。1.32或更高版本不支持无文件图像。

如果无法使用,请提供MCVE,而不仅仅是代码片段。