Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
以下代码片段也适用于 Aspose.PDF.Drawing 库。
图像集合的 Replace 方法允许您在现有 PDF 文件中替换图像。
图像集合可以在页面的资源集合中找到。要替换图像:
以下代码片段演示了如何在 PDF 文件中替换图像。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReplaceImageInPDF()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "ReplaceImage.pdf"))
{
// Replace a particular image in the document
using (var imageStream = new FileStream(dataDir + "NewImage.jpg", FileMode.Open))
{
document.Pages[1].Resources.Images.Replace(1, imageStream);
}
// Save PDF document
document.Save(dataDir + "ReplaceImage_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.