Introduction
This article describes how to add an image to a runtime generated PDF file. For generating the PDF file, you need to use a PDF generator library.
Note: I will use the "iTextSharp.dll" as a PDF generator library. You can download it from the following
http://sourceforge.net/projects/itextsharp
https://www.nuget.org/packages/iTextSharp/
Or
- You can download the attached file of this article.
To explain this article, I will use the following procedure:
- Add a reference of the downloaded "iTextSharp.dll" to the project/website.
- Write some code in the ".cs" file to generate the PDF file with some text for the "button click" event.
The following are the details of the preceding procedure.
Step 1
- Run the page that will be like:
- Click on the "Generate PDF" button and save the "Image.pdf" file.
Result: Open the PDF file and see the image in the PDF file.