Java Programing laungage

iText Projects

iText Project 1

adplus-dvertising
Set Back Ground Color
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.

Examples

package r4r;
import java.io.*;
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
("setbackgroundColor.pdf"));
doc.open();
Paragraph par=new Paragraph
("Page Size and Background color");
doc.add(par);
doc.add(new Paragraph("Background color"));
doc.close();
}
}
Previous Home Next