PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
How to draw an image from a byte[] or stream? https://forum.pdfsharp.net/viewtopic.php?f=2&t=2133 |
Page 1 of 1 |
Author: | omgsauce [ Sat Sep 08, 2012 12:03 am ] |
Post subject: | How to draw an image from a byte[] or stream? |
Hi, I am trying to draw an image to a pdf. The only examples I have found are using XImage, which I can only seem to find a way to create using an image file path. However, my files are saved in database as byte[], and the application that will be generating PDFs will not have permission to save files(so I cant save, open, delete). Is there a way to draw images using PDFSharp? I am hoping to avoid having to purchase asppdf, which is quite pricey. Thank you for any help. |
Author: | dheijl [ Mon Sep 10, 2012 7:34 am ] |
Post subject: | Re: How to draw an image from a byte[] or stream? |
Provided you're using pdfsharp and not migradoc: Code: // byte[] jpegdata contains the jpeg image
using (MemoryStream ms = new MemoryStream(jpegdata)) { using (Image img = Image.FromStream(ms)) { using (var xi = XImage.FromGdiPlusImage(img)) { _pdfGfx.DrawImage(xi, ip.dx, ip.dy, ip.dw, ip.dh); } } } |
Author: | TH-Soft [ Tue Sep 22, 2015 7:58 am ] |
Post subject: | Re: How to draw an image from a byte[] or stream? |
Hi! dheijl wrote: Provided you're using pdfsharp and not migradoc With version 1.50 beta 2, there is a solution for that works with MigraDoc: pass the image as a string when you call AddImage():http://pdfsharp.net/wiki/MigraDoc_FilelessImages.ashx This method applies to MigraDoc only. With PDFsharp you can create an XImage from a Stream. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |