Using the Table class for reports creation

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

using PDFjet.NET;

/**
 *  Example_08.cs
 *
 */
public class Example_08 {

    public Example_08() throws Exception {
        PDF pdf = new PDF();
        Font f1 = new Font(pdf, "Helvetica-Bold");
        Font f2 = new Font(pdf, "Helvetica");
        Font f3 = new Font(pdf, "Helvetica-BoldOblique");
        // Please note:
        // All font and image objects must be created before the first page.


        Page page = new Page(pdf, Letter.PORTRAIT);
        f1.SetSize(7.0);
        f2.SetSize(7.0);
        f3.SetSize(7.0);

        Table table = new Table(f1, f2);
        table.SetData(
                "data/world-communications.txt",
                "|",
                Table.DATA_HAS_2_HEADER_ROWS);
        table.SetLineWidth(0.2);
        table.SetPosition(70.0, 30.0);
        table.SetTextColorInRow(6, RGB.BLUE);
        table.SetTextColorInRow(39, RGB.RED);
        table.SetTextFontInRow(26, f3, 7);
        table.RemoveLineBetweenRows(0, 1);
        table.AutoAdjustColumnWidths();
        table.SetWidthForColumn(0, 120);
        table.RightAlignNumbers();
        int numOfPages = table.GetNumberOfPages(page);
        while (true) {
            table.drawOn(page);
            // TO DO: Draw "Page 1 of N" here
            if (!table.HasMoreData()) break;
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Wrap();
        pdf.Save("Example_08.pdf");
    }


    public static void Main(String[] args) {
        try {
            new Example_08();
        } catch (Exception e) {
            Console.WriteLine(e.StackTrace);
        }
    }

}   // End of Example_08.cs
Example_08.pdf

© 2007 Innovatics Inc.