Java PDF: Dessiner des lignes à l’aide des coordonnées

Author:

Java PDF: Dessiner des lignes à l'aide des coordonnées
{filelink=10386}

/***** Code de MesExemples.com *******/
/**
 * @(#)LigneCoordonne.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/27
 */

import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfTemplate;
import com.itextpdf.text.pdf.PdfWriter;

public class LigneCoordonne {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter pdf_writer = PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/LigneCoordonne.pdf"));
      document.open();
      PdfContentByte cb = pdf_writer.getDirectContent();

      cb.moveTo(216, 720);
      cb.lineTo(360, 360);
      cb.lineTo(360, 504);
      cb.lineTo(72, 144);
      cb.lineTo(144, 288);
      cb.stroke();

    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *