PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Dec 01, 2022 4:31 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 20, 2021 3:10 pm 

Joined: Wed Oct 20, 2021 2:58 pm
Posts: 1

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

        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 :)

Reply with quote  
PostPosted: Thu Oct 21, 2021 11:51 am 
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 747
Location: CCAA
The question with more details and an answer can be found here:

Best regards
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 11 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group