简体   繁体   中英

How can I add page background color of pdf using iText in java

I am new to iText pdf library. Can any one guide me how to add background color to entire page (not for chunk or paragraph) using iText pdf in java.

This code will do the job:

Rectangle pageSize = new Rectangle(216, 720);
pageSize.setBackgroundColor(new BaseColor(0xFF, 0xFF, 0xDE));
Document document = new Document(pageSize);

Use this code:

Rectangle pageSize = new Rectangle(400, 720); 
pageSize.setBackgroundColor(BaseColor.YELLOW);
Document document = new Document(pageSize);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM