- Code: Select all
Spire.Pdf.PdfDocument pdf = new Spire.Pdf.PdfDocument();
pdf.LoadFromFile(path);
var img = Image.FromFile(imgpath);
//遍历文档中所有页面
for (var i = 0; i < pdf.Pages.Count; i++)
{
var page = pdf.Pages[i];
page.BackgroundImage = img;
}
pdf.SaveToFile(path);
pdf.Close();