Aspose.Pdf for .NET feature's list also include to set the background image for a [Section]. In Aspose.Pdf for .NET a [Section] can be composed of multiple pages. So, if we set the background image for a [Section] then that background image will be displayed on all pages (that belong to the same [Section]). " How does one do this? Specifically, I would like to take an existing PDF, put all of the pages in a Section, and then set the background image for that section. |
Hi Keith,
Thanks for your inquiry. Please check the following code snippet to set page background. Hopefully, it will help you to accomplish.
Document doc = new Document(myDir + "input.pdf");
// Background
BackgroundArtifact background = new BackgroundArtifact();
background.BackgroundImage = System.IO.File.OpenRead(myDir + "image.png");
foreach(Page page in doc.Pages)
page.Artifacts.Add(background);
doc.Save(myDir + "Document_background1.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
tilal.ahmad: Hi Keith,
Thanks for your inquiry. Please check the following code snippet to set the page background. Hopefully, it will help you > accomplish your task.
Document doc = new Document(myDir + "input.pdf"); // Background BackgroundArtifact background = new BackgroundArtifact(); background.BackgroundImage = System.IO.File.OpenRead(myDir + "image.png"); foreach(Page page in doc.Pages) { page.Artifacts.Add(background)
}
doc.Save(myDir + “Document_background1.pdf”);
Please feel free to contact us for any further assistance. Best Regards,
I tried this technique earlier. It did put the background image on each page, but at a high cost. For our 8-page test document with a 300 PPI TIFF image, it took 15 seconds on average to output the document versus 9.5 seconds for an existing “draw the image on each page method” we have using PDFSharp. Furthermore, the resulting PDF was 4.52 MB using this technique versus 246 KB for our existing method.
So, is there not a way to do what that support page advised, applying a background image to a section consisting of multiple pages? If not that, is there any more efficient way to do this?
Hi Keith,
Hi Keith,keithkurak:
I tried this technique earlier. It did put the background image on each page but at a high cost. For our 8 page test document overlayed with a 300 PPI TIFF image, it took 15 seconds on average to output the document, vs 9.5 seconds for an existing “draw the image on each page method” we have using PDFSharp. Furthermore, the resulting PDF was 4.52 MB using this technique, vs. 246 KB for our existing method.So, is there not a way to do what that support page advised, applying a background image to a Section consisting of multiple pages? If not that, is there any more efficient way to do this?