Java PDF: Ajouter un nouveau paragraphe dans une page

Author:

Java PDF: Ajouter un nouveau paragraphe dans une page
{filelink=10538}

/***** Code de MesExemples.com *******/
/**
 * @(#)AddParagrapheSample.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/5/29
 */

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

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.PdfWriter;

public class AddParagrapheSample {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document, 
      	new FileOutputStream("c:/AddParagrapheSample.pdf"));
      document.open();
      document.add(new Paragraph("Première Page."));
      document.setPageSize(PageSize.A3);
      document.newPage();
      document.add(new Paragraph("Nouvelle Page A3."));
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}

Leave a Reply

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