Java Tutorial/PDF/Background Color
Версия от 17:44, 31 мая 2010; (обсуждение)
Set backgroundcolor to cornflower blue
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();
}
}