Java PDF: Souligner un texte

Author:

Java PDF: Souligner un texte
{filelink=10352}

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



import java.io.FileOutputStream;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

public class SoulignerTextePDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/TexteSoulignePDF.pdf"));
      document.open();
  
      // créer un chunk
      Chunk underlined = new Chunk("souligné");
      underlined.setUnderline(0.2f, -2f);
      
      // Souligner le chunk
      Paragraph p = new Paragraph("Le chunk suivant est ");
      p.add(underlined);
      
      document.add(p);
    } catch (Exception ioe) {
      System.err.println(ioe.getMessage());
    }
    document.close();
  }
}

Leave a Reply

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