PDFsharp & MigraDoc Foundation

XImage from stream
Page 1 of 1

Author:  kaliand [ Sat Apr 04, 2020 11:23 am ]
Post subject:  XImage from stream

Hope you all are well!

With this simple code:
        public XImage GetXImage(string remotepath)
                MemoryStream ms = new MemoryStream();
                if (connect())
                    if (CallRemoteExists(remotepath, EntryType.File))
                        objDart.Get(remotepath, 0, ms);

                        return XImage.FromStream(ms);
                      return null;
                    return null;

I'm getting the exception : "The parameter is not valid" in XImage.FromStream method.
The library objDart gets a pdf file from a remote server via FTP and writes it onto a stream. Works fine, but when i try to use the XImage.FromStream it throwns the above exception. I've used this library to get stream files from remote server, and always has worked flawlessly with the stream that you get. But seams that PdfSharp.Drawing.XImage.FromStream() doesn´t support the stream i'm getting from that library.

Am i missing something from that method?
What i'm doing wrong?

Thank you so much!

Author:  TH-Soft [ Mon Apr 06, 2020 2:02 pm ]
Post subject:  Re: XImage from stream

Maybe you have to set the file pointer of the MemoryStream to 0 if the library does not do it.

Author:  kaliand [ Mon Apr 06, 2020 3:28 pm ]
Post subject:  Re: XImage from stream

Hi Thomas,

It's weird because i tried this workaround a few days ago and didn't work, and now does... Maybe i did some changes while trying to make it work out.

Thanks anyway!

best regards,


Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group