Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java PDF: Exemple GState

Java PDF: Exemple GState
{filelink=10442}

/***** Code de MesExemples.com *******/
/**
 * @(#)GStatePDF.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/30
 */
 
 
 
import java.awt.Color;
import java.io.FileOutputStream;
 
import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfGState;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.BaseColor;
 
public class GStatePDF {
  public static void main(String[] args) {
    Document document = new Document();
 
    try {
      PdfWriter writer = PdfWriter.getInstance(document,
       new FileOutputStream("c:/GStatePDF.pdf"));
      document.open();
 
      PdfContentByte cb = writer.getDirectContent();
      PdfGState gs = new PdfGState();
      gs.setFillOpacity(0.5f);
      cb.setGState(gs);
 
      cb.setColorFill(BaseColor.RED);
      cb.circle(360.0f, 500.0f, 250.0f);
      cb.fill();
      gs.setFillOpacity(0.2f);
      cb.setGState(gs);
      cb.setColorFill(BaseColor.BLUE);
      cb.circle(460.0f, 500.0f, 100.0f);
      cb.fill();
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}

A Voir sur le même Sujet:

  • code source java