Java PDF: Modifier l’espace d’avant la table

Author:

Java PDF: Modifier l'espace d'avant la table
{filelink=10606}

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


import java.io.FileOutputStream;

import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

public class ExempleSetSpacingAfter {
  public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {
      PdfWriter writer = PdfWriter.getInstance(document,  
      	new FileOutputStream("c:/ExempleSetSpacingAfter.pdf"));
      document.open();

      PdfPTable table = new PdfPTable(3);
      PdfPCell cell = new PdfPCell(new Paragraph("entête"));
      cell.setColspan(3);
      table.addCell(cell);
      // Modifier la marge avant la table
      table.setSpacingBefore(150f);
      document.add(table);
      document.add(table);
      document.add(table);
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}

Leave a Reply

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