PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

DrawImage does not work..
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1430
Page 1 of 1

Author:  ansdhr [ Mon Nov 22, 2010 7:25 am ]
Post subject:  DrawImage does not work..

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..

Author:  Thomas Hoevel [ Mon Nov 22, 2010 12:52 pm ]
Post subject:  Re: DrawImage does not work..

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

Author:  ansdhr [ Mon Nov 22, 2010 7:29 pm ]
Post subject:  Re: DrawImage does not work..

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..

Author:  Thomas Hoevel [ Tue Nov 30, 2010 10:33 am ]
Post subject:  Re: DrawImage does not work..

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.

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