Package com.lowagie.examples.objects.tables.pdfptable

Source Code of com.lowagie.examples.objects.tables.pdfptable.SplitTable

/*
* $Id$
*
* This code is part of the 'iText Tutorial'.
* You can find the complete tutorial at the following address:
* http://itextdocs.lowagie.com/tutorial/
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* itext-questions@lists.sourceforge.net
*/
package com.lowagie.examples.objects.tables.pdfptable;


import com.lowagie.text.LwgDocument;
import com.lowagie.text.LwgPageSize;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.LwgPdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import org.geoforge.demo.GfrFileOutputStream;

/**
* Break a large table up into different smaller tables in order to save memory.
*/
public class SplitTable {
  /**
   * Break a large table up into several smaller tables for memory management
   * purposes.
   *
   * @param args
   *            the number of rows for each table fragment.
   */
  public static void main(String[] args) {

    System.out.println("Split Table");
    // step1
    LwgDocument document = new LwgDocument(LwgPageSize.A4, 10, 10, 10, 10);
    try {
      // step2
      PdfWriter writer = PdfWriter.getInstance(document,
                 new GfrFileOutputStream("com.lowagie.examples.objects.tables.pdfptable.SplitTable.pdf"));
      // step3
      document.open();
      // step4

            PdfContentByte cb = writer.getDirectContent();
            LwgPdfPTable table = new LwgPdfPTable(10);
            for (int k = 1; k <= 100; ++k) {
                table.add("The number " + k);
            }
            table.setTotalWidth(800);
            table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
            document.newPage();
            table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
            document.close();
    } catch (Exception de) {
      de.printStackTrace();
    }
    // step5
    document.close();
  }
}
TOP

Related Classes of com.lowagie.examples.objects.tables.pdfptable.SplitTable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.