Java PDF: Sélectionner les lignes d’une table

Author:

Java PDF: Sélectionner les lignes d'une table
{filelink=10655}

/***** Code de MesExemples.com *******/
/**
 * @(#)WriteSelectedRowsPDF.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.Rectangle;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

public class WriteSelectedRowsPDF {
  public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 2, 2, 2, 2);
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(
          "c:/WriteSelectedRowsPDF.pdf"));
      document.open();
      PdfPTable table = new PdfPTable(4);
      table.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.RIGHT);
      
      table.addCell("a");
      table.addCell("a");
      table.addCell("a");
      table.addCell("a");
      
      table.setTotalWidth(300f);
      table.writeSelectedRows(0, -1, 100, 600, writer.getDirectContent());
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}

Leave a Reply

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