Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java PDF: Créer un texte Multiligne

Java PDF: Créer un texte Multiligne
{filelink=10369}

/***** Code de MesExemples.com *******/
/**
 * @(#)ExempleTexteMultiLigne.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/26
 */
 
 
 
import com.itextpdf.text.BaseColor;
import java.io.FileOutputStream;
 
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
 
 
public class ExempleTexteMultiLignePDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/ExempleTexteMultiLignePDF.pdf"));
      document.open();
 
      Chunk chunk;
      chunk = new Chunk("Exemple d'un texte multiligne");
      chunk.setUnderline(new BaseColor(0xFF, 0x00, 0x00), 0.0f, 0.3f, 0.0f, 
    0.4f, 
      	PdfContentByte.LINE_CAP_ROUND);
      chunk.setUnderline(new BaseColor(0x00, 0xFF, 0x00), 3.0f, 0.0f, 0.0f, 
    -0.5f,
       PdfContentByte.LINE_CAP_PROJECTING_SQUARE);
      chunk.setUnderline(new BaseColor(0x00, 0x00, 0xFF), 0.0f, 0.2f, 15.0f, 
    0.0f, 
      	PdfContentByte.LINE_CAP_BUTT);
      document.add(chunk);
 
    } catch (Exception err) {
      System.err.println(err.getMessage());
    }
    document.close();
  }
}