Answers for "itext 7 add image to existing pdf"

0

itext 7 add image to existing pdf

// Modify PDF located at "source" and save to "target"
PdfDocument pdfDocument = new PdfDocument(new PdfReader(source), new PdfWriter(target));
// Document to add layout elements: paragraphs, images etc
Document document = new Document(pdfDocument);

// Load image from disk
ImageData imageData = ImageDataFactory.Create(imageSource);
// Create layout image object and provide parameters. Page number = 1
Image image = new Image(imageData).ScaleAbsolute(100, 200).SetFixedPosition(1, 25, 25);
// This adds the image to the page
document.Add(image);

// Don't forget to close the document.
// When you use Document, you should close it rather than PdfDocument instance
document.Close();
Posted by: Guest on June-07-2021

Browse Popular Code Answers by Language