Skip to content
ComPDF

Background

Set Background Color

java
div.setBackgroundColor(new CColor(240, 240, 240, 255));

Set Background Image

java
// Create a background image
CBackgroundImage bgImage = new CBackgroundImage();

// Set a single image source
bgImage.setSource("path/to/background.png");

ArrayList<String> sources = new ArrayList<>();
sources.add("path/to/image1.png");
sources.add("path/to/image2.png");
// Or set multiple image sources
bgImage.setSources(sources);

// Apply the background image
div.setBackgroundImage(bgImage);