PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:46 am

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
PostPosted: Sat Sep 08, 2012 12:03 am 
Offline

Joined: Fri Sep 07, 2012 11:57 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 10, 2012 7:34 am 
Offline

Joined: Fri Apr 13, 2012 6:33 am
Posts: 10
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);
                    }
                }
            }


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 22, 2015 7:58 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
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.

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


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: No registered users and 142 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