Java Tutorial/PDF/Background Color — различия между версиями

Материал из Java эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:21, 1 июня 2010

Set backgroundcolor to cornflower blue

   <source lang="java">

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();
   }

}</source>