Reputation: 28275
I have a whole bunch of 2D graphics that is being used for both rendering controls on screen and used to print, it's pretty custom graphics that couldn't be done by any 3rd party reporting tools or off the shelf controls.
The program can generate PDF files of the printed content but when I wrote it I cheated and just print the Graphics
object to an in memory image and then embed that into the PDF page.
Since the users are emailing the documents they're finding they are too large.
I've started writing the PDF from scratch using iText, however is there a way to get System.Drawing.Graphics
content directly into PDF? The way iText works and Graphics works is completely different.
Upvotes: 4
Views: 9347
Reputation: 2990
try this library http://www.pdfsharp.com/PDFsharp/
Edit: Above library has been moved to http://www.pdfsharp.net/
Upvotes: 4
Reputation: 19004
One (hacky) way would be to simply use a PDF printer driver like this one. You can reuse the same GDI+ code through the printing API.
Upvotes: 0
Reputation: 55447
Do you mean that you have a System.Drawing.Image
? If so you can pass that directly to iTextSharp.text.Image.GetInstance()
which will give you an iTextSharp Image
object. Otherwise you can draw directly to the PDF canvas, see this post for more.
Upvotes: 1
Reputation: 9244
You can direct what your drawing with Graphics to a WMF (EMF) and then hand that to iText.
Upvotes: 1