Java Programing laungage

iText Projects

iText Project 1

Concatenate two PDF file with each other
Previous Home Next

By the help of this program I am trying to show you how we can Set the background color in PDF file. For performing this task firstly we are import to the iText.jar file and some packages like com.lowagie.text.pdf.*, com.lowagie.text.*. After import of the package we are going to initialized to the document into the PDF file. Then apply the setBackground(Color color) method for changing the color.


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

public class setbackgroundtest 
public static void main(String[] args) throws Exception
Rectangle pSize = new Rectangle(400, 400);
pSize.setBackgroundColor(new java.awt.Color
(0xDF, 0xFF, 0xDE));
Document doc = new Document(pSize);
PdfWriter.getInstance(doc,new FileOutputStream
Paragraph par=new Paragraph
("Page Size and Background color");
doc.add(new Paragraph("Background color"));
Previous Home Next