Byte[] of PDF into image
-
Hi, I need to convert a byte[] array generated from PDF into image and show it in the UI. I dnt want to store the image file anywhere in the disk.Conversion should be using in-built memory. I tried to convert byte into bitmap image using the following code. But image is not rendered in the UI. using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { BitmapImage im = new BitmapImage(); im.SetSource(ms); this.pdfImage.Source = im; } Is there anyother way to do this? Tools are also acceptable.
Gomathi R
-
Hi, I need to convert a byte[] array generated from PDF into image and show it in the UI. I dnt want to store the image file anywhere in the disk.Conversion should be using in-built memory. I tried to convert byte into bitmap image using the following code. But image is not rendered in the UI. using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { BitmapImage im = new BitmapImage(); im.SetSource(ms); this.pdfImage.Source = im; } Is there anyother way to do this? Tools are also acceptable.
Gomathi R
You can't convert a PDF into an image simply by converting it into a byte array. Without the conversion to an image, the
BitmapImage
identifies that it cannot display the byte array, so it doesn't attempt to display it. You might want to try this[^] library for the actual conversion (there's even a small sample on saving a PDF to a png file).*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
You can't convert a PDF into an image simply by converting it into a byte array. Without the conversion to an image, the
BitmapImage
identifies that it cannot display the byte array, so it doesn't attempt to display it. You might want to try this[^] library for the actual conversion (there's even a small sample on saving a PDF to a png file).*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Hi Pete, I have tried this. But i am unable to add the dll in my Silverlight Application.
Gomathi R
You don't add it to the Silverlight side - you add it to the ASP.NET side, and send the byte array to the Silverlight app. That is, after all, where you are getting the PDF from isn't it?
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
You don't add it to the Silverlight side - you add it to the ASP.NET side, and send the byte array to the Silverlight app. That is, after all, where you are getting the PDF from isn't it?
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier