Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I have a project on C#, WPF. I want to pass image from image.source to pdf. How can I do that? On WinForm applications and picturebox, I can do that:

iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(pictureBox1.Image, System.Drawing.Imaging.ImageFormat.Jpeg);
doc.Add(png);


What about WPF applications and Image sources?

What I have tried:

ImageSource img = image1.Source;
                BitmapSource bmp = (BitmapSource)img;
                iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Bmp);
Posted
Updated 5-Feb-19 18:00pm
Comments
Member 14083000 6-Feb-19 13:38pm    
Isn't there anyone who can help? How can i convert image source to itextsharp image?

1 solution

Since you already know how to do this in Windows Forms, "call" that form from you WPF app. You can move it off screen or hide it if that's an issue.

Nothing wrong with using a (static) method in a form or user control if it's not convenient to make it a "library" function.
 
Share this answer
 
Comments
Member 14083000 6-Feb-19 9:34am    
But I can do that with picture box(on WinForm app), but I want to do it with Image Source(WPF app). PictureBox and image source are not same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900