Example usage for com.itextpdf.text Paragraph setTabSettings

List of usage examples for com.itextpdf.text Paragraph setTabSettings

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setTabSettings.

Prototype

public void setTabSettings(TabSettings tabSettings) 

Source Link

Document

Setter for the tab stops.

Usage

From source file:com.wesley.creche.services.pdf.createPdf.java

public void writePdfFinancialReport(String name, String startDate, String accStatus, String amountDue)
        throws DocumentException, IOException {

    createFolderIfNotExist();//w  ww  . j  av  a 2 s.c om
    SQLQueries s = new SQLQueries();

    String lastName = "";

    try {
        lastName = s.getChildSurnameByName(name);
    } catch (SQLException | ClassNotFoundException ex) {
        System.out.println(ex);
    }

    Date date = new Date();
    DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
    String today = df.format(date);
    String fileName = "C:\\creche\\reports\\" + name + today + "_.pdf";

    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName));

    document.open();

    addTitle(document);
    addLine(document);

    document.add(new Paragraph("Name : " + name + " " + lastName, italic));
    addEmptyLine(document, 2);

    Paragraph paragraph = new Paragraph();
    paragraph.add("Start Date :");
    paragraph.setTabSettings(new TabSettings());
    paragraph.add(Chunk.TABBING);
    paragraph.add(new Chunk(startDate));
    document.add(paragraph);

    addEmptyLine(document, 1);
    document.add(new Paragraph("Account Status : " + accStatus));
    addEmptyLine(document, 1);

    document.add(new Paragraph("Total Amount Outstanding : R" + amountDue));
    addEmptyLine(document, 3);

    addLine(document);
    document.add(new Paragraph("For any queries, please contact Administration : 10111"));

    document.close();
}

From source file:kafe.BayarSemuaFrame.java

private static void addContent(Document document, String id_pesanan, String bayar, String kembali)
        throws DocumentException {
    Paragraph preface = new Paragraph();
    preface.add(new Paragraph("============================================================================\n",
            smallBold));/*  w  w  w  .  j  a v  a  2 s  .com*/
    addEmptyLine(preface, 1);
    preface.setTabSettings(new TabSettings(250f));
    preface.add(Chunk.TABBING);
    preface.add(new Chunk("---------SEDAP MALAM---------", catFont));
    addEmptyLine(preface, 1);
    preface.setTabSettings(new TabSettings(150f));
    preface.add(Chunk.TABBING);
    preface.add(new Chunk("__________Jalan Informatika No.8__________", smallBold));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph("============================================================================\n",
            smallBold));
    addEmptyLine(preface, 1);
    try {
        Class.forName(driver);
        Connection connection = DriverManager.getConnection(url, user, pass);
        Statement statement = connection.createStatement();
        String sql = "select a.id_pesanan,d.nama_meja,b.waktu,c.nama_makanan,c.harga_makanan,a.jumlah_makanan,a.status from isi_pesanan a, pesanan b, makanan c, meja d where b.id_pesanan='"
                + id_pesanan
                + "' and a.id_pesanan=b.id_pesanan and a.id_makanan=c.id_makanan and b.meja=d.id_meja";
        ResultSet rs = statement.executeQuery(sql);
        int i = 0;
        int harga_tot = 0;
        while (rs.next()) {
            int id = rs.getInt(1);
            String nama_meja = rs.getString(2);
            String firstName = rs.getString(3);
            String surname = rs.getString(4);
            if (i == 0) {

                preface.add(new Chunk("ID Pesanan: " + rs.getInt(1) + "\n", normalFont));
                preface.add(new Chunk("Meja: " + rs.getString(2) + "\n", normalFont));
                preface.add(new Chunk("Waktu Pesanan: " + rs.getString(3), normalFont));
                addEmptyLine(preface, 1);
                preface.add(new Paragraph(
                        "---------------------------------------------------------------------------------------------------------------------------------\n",
                        smallBold));
                addEmptyLine(preface, 1);
                preface.add(new Paragraph("Rincian Pesananan:", smallBold));
                addEmptyLine(preface, 1);
            }
            preface.add(new Paragraph(
                    rs.getString(4) + " @ " + rs.getString(6) + " = Rp. " + rs.getString(5) + "\n",
                    normalFont));
            harga_tot += Integer.parseInt(rs.getString(5)) * Integer.parseInt(rs.getString(6));
            i++;
        }
        addEmptyLine(preface, 1);
        preface.add(new Paragraph(
                "---------------------------------------------------------------------------------------------------------------------------------\n",
                smallBold));
        addEmptyLine(preface, 1);
        preface.add(new Paragraph("Harga Total: Rp. " + harga_tot, smallBold));
        addEmptyLine(preface, 1);
        preface.add(new Paragraph("Bayar: Rp. " + bayar, normalFont));
        addEmptyLine(preface, 1);
        preface.add(new Paragraph("Kembali: Rp. " + kembali, smallBold));
        addEmptyLine(preface, 3);
        preface.add(new Paragraph("============================== TERIMA KASIH ==============================",
                smallBold));

        rs.close();
        statement.close();
        connection.close();
    } catch (Exception DBException) {
    }

    document.add(preface);
    document.newPage();
}