Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java PDF: Dessiner un cercle dans un document PDF

Java PDF:  Dessiner un cercle dans un document PDF
{filelink=10377}

/***** Code de MesExemples.com *******/
/**
 * @(#)ExempleCerclesPDF.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/26
 */
 
 
 
import java.io.FileOutputStream;
 
import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
 
public class ExempleCerclesPDF {
  public static void main(String[] args) {
    Document document = new Document();
 
    try {
      PdfWriter pdf_writer = PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/ExempleCerclesPDF.pdf"));
      document.open();
 
      PdfContentByte cb = pdf_writer.getDirectContent();
      // Dessiner trois cercles
      cb.circle(250.0f, 500.0f, 200.0f);
      cb.circle(250.0f, 500.0f, 150.0f);
      cb.circle(350.0f, 300.0f, 150.0f);
      cb.stroke();
 
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}