Set backgroundcolor to cornflower blue : Background Color « PDF « Java Tutorial






import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;


public class SetBackgroundColorBlue {

   public static void main(String[] args) throws Exception{
        Rectangle pagesize = new Rectangle(612, 792);
        pagesize.setBackgroundColor(new Color(0x64, 0x95, 0xed));
        Document document = new Document(pagesize);
        try {
            PdfWriter.getInstance(
                    document,
                    new FileOutputStream("HelloWorldBlue.pdf"));
            document.open();
            document.add(new Paragraph("Hello World"));
        document.close();
    }
}








29.17.Background Color
29.17.1.Set backgroundcolor to cornflower blue