How to Start Convert PDF Read PDF Build PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

Using C# PDF SDK
C# PDF Builder: How to add an image to PDF file


C# Demo Code to add an image to adobe pdf file













Add an image to the document


String outputFilePath = Program.RootPath + "\\" + "Sample21.pdf";

String imageFilePath = Program.RootPath + "\\" + "Image001.bmp";

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

document.Add(new Paragraph("Sample: add an image."));

//  load an image from the source file.
Image image = new Image(imageFilePath);
document.Add(image);

document.Add(new Paragraph("Image Width: " + image.Width + " pt.; Image Height: " + image.Height + " pt."));

//  close document and save to the output file
document.Close();




Add an image with the specified size


String outputFilePath = Program.RootPath + "\\" + "Sample22.pdf";

String imageFilePath = Program.RootPath + "\\" + "Image001.bmp";

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

document.Add(new Paragraph("Scale image size to: width = 500 pt.; height = 50 pt."));

Image image1 = new Image(imageFilePath);
//  scale image width to 500 pt. (72 ppi) 
image1.ScaleAbsoluteWidth(500);
//  scale image height to 50 pt. (72 ppi)
image1.ScaleAbsoluteHeight(50);

document.Add(image1);