Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java PDF: Exemple d’une césure

Java PDF:  Exemple d'une césure
{filelink=10444}

/***** Code de MesExemples.com *******/
/**
 * @(#)ExempleCesurePDF.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/4/30
 */
 
 
import java.io.FileOutputStream;
import java.io.IOException;
 
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.HyphenationAuto;
import com.itextpdf.text.pdf.PdfWriter;
 
public class ExempleCesurePDF {
 
  public static void main(String[] args) {
    Document document = new Document(PageSize.A6);
    try {
      PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/CésurePDF.pdf"));
 
      document.open();
      String text = "u2014";
      Chunk ck = new Chunk(text);
      HyphenationAuto auto = new HyphenationAuto("en", "GB", 2, 2);
      ck.setHyphenation(auto);
      Paragraph p = new Paragraph(ck);
      p.setAlignment(Paragraph.ALIGN_JUSTIFIED);
      document.add(p);
    } catch (Exception ioe) {
      System.err.println(ioe.getMessage());
    }
    document.close();
  }
}

A Voir sur le même Sujet:

  • codes sources java