Backgrounds & Foregrounds
For adding specific background or foreground elements to your PDF documents, IronPDF provides the addBackground
and addForeground
methods. These methods enable developers to use the content of one PDF as the background or the foreground of another PDF. These methods are particularly useful for generating groups of PDFs based on a common design template.
Since these methods work with PdfDocument
objects, developers can source them from existing files using the fromFile
method, or generate them anew using one of the available PDF rendering methods.
addBackground
and addForeground
will utilize the first page of multipage PDF documents as the background or foreground by default. To use a different page from PDFs containing multiple pages, add the index of the desired page as the second argument to the method call.
For overlaying a PDF as the background or foreground on specific pages of a working PDF, specify the pages to be overlayed using a PageSelection
object. The example below shows how to do this for a single page and for a range of pages of a PDF document.
For watermarking your PDF documents, use the addWatermark
method as an alternative to using addBackground
for easier control over background positioning and opacity.
For more information on PDF manipulation, visit IronPDF's Features and Documentation.
Unlock the power of PDF manipulation with our Background & Foreground Editing Guide for Java!