PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Jul 13, 2024 9:27 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Nov 22, 2010 7:25 am 
Offline

Joined: Fri Nov 19, 2010 11:03 pm
Posts: 3
Hi,

I've created an XImage object and trying to use it on DrawImage function. I used WebClient to read http image as in stream.

Code:
           
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(new Uri(@"http://myserver/myimage.png"));

void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
  if (e.Error != null)
    MessageBox.Show(e.Error.Message);
  else
    globalStream = e.Result; /*gloablStream is a global "Stream" object
}


When using the stream to create XImage and draw:
Code:
XImage myImage = XImage.FromStream(globalStream); /*globalStream has length and is not null*/
gfx.DrawImage(myImage, 0, 0, 150, 300);/*Error from here */


Am I missing something when using DrawImag function? I am getting an error:
Code:
Value cannot be null. Parameter name: value

Thanks..


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 22, 2010 12:52 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
ansdhr wrote:
I am getting an error:
Code:
Value cannot be null. Parameter name: value

You should try your code in debugger and tell VS to break when an exception is thrown (select Debug => Exceptions from the menu).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 22, 2010 7:29 pm 
Offline

Joined: Fri Nov 19, 2010 11:03 pm
Posts: 3
Could you point me to the reference or sample code to draw png or jpeg image to PDF page? All the sample code I've found uses FromFile() which shows obsolete and does not work in Silverlight.

Thanks..


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 30, 2010 10:33 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
PDFsharp does not work under Silverlight yet (this will come in the future).

So the FromFile() method is just the tip of the iceberg because many parts of current versions of PDFsharp will not work under Silverlight.

You can easily avoid the FromFile() method e. g. by loading images from resources.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 69 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