Search code examples
c#.netpdfsharp

How to display the PictureBox image into PDF file with the help of PDFsharp in c#?


I'm developing a Windows application in c#. In my application I have developed PDF file with the help of PDFsharp. I have to display the image in the PDF file from the PictureBox.


Solution

  • When using the GDI+ of PDFsharp, you can simply call XImage.FromGdiPlusImage:

    XImage img = XImage.FromGdiPlusImage(pb.Image);
    

    pb is the PictureBox.

    This answer is for PDFsharp.

    Sample code that adds images to a PDF file using PDFsharp (demonstrating the use of the XImage class) can be found here:
    http://pdfsharp.net/wiki/Graphics-sample.ashx#Images_35