PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Sep 23, 2020 11:21 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: XImage from stream
PostPosted: Sat Apr 04, 2020 11:23 am 
Offline

Joined: Wed Mar 25, 2020 2:34 pm
Posts: 5
Hi,
Hope you all are well!

With this simple code:
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);
                    }
                    else
                      return null;
                }
                else
                    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!
regards


Top
 Profile  
Reply with quote  
 Post subject: Re: XImage from stream
PostPosted: Mon Apr 06, 2020 2:02 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 569
Location: CCAA
Maybe you have to set the file pointer of the MemoryStream to 0 if the library does not do it.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: XImage from stream
PostPosted: Mon Apr 06, 2020 3:28 pm 
Offline

Joined: Wed Mar 25, 2020 2:34 pm
Posts: 5
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,

Carles


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 9 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