PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Unable to convert image from stream
http://forum.pdfsharp.de/viewtopic.php?f=2&t=4294
Page 1 of 1

Author:  Drake [ Wed Oct 20, 2021 3:10 pm ]
Post subject:  Unable to convert image from stream

Hi,

I'm trying to include an image from a SQL database into a pdf file with the following code (C# MVC):

Code:
        private PdfDocument openImageFromByteArray(byte[] ImageStream)
        {
            MemoryStream stream = new MemoryStream(ImageStream);
            PdfDocument OutputDocument = new PdfDocument();
            OutputDocument.Pages.Add(new PdfPage());

            XGraphics xgr = XGraphics.FromPdfPage(OutputDocument.Pages[0]);
            XImage img = XImage.FromStream(stream);
            xgr.DrawImage(img, 0, 0);

            return OutputDocument;
        }

if I save OutputDocument locally it works fine, but as soon as the code runs from the server I get the error that the image was not decoded properly.
Using PdfSharp version 1.50.5147

Thanks :)

Author:  TH-Soft [ Thu Oct 21, 2021 11:51 am ]
Post subject:  Re: Unable to convert image from stream

The question with more details and an answer can be found here:
https://stackoverflow.com/a/69661455/162529

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/