📜  itext 7 将图像添加到现有 pdf - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:12.478000             🧑  作者: Mango

代码示例1
// 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();