Example usage for com.itextpdf.text Element ALIGN_BASELINE

List of usage examples for com.itextpdf.text Element ALIGN_BASELINE

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_BASELINE.

Prototype

int ALIGN_BASELINE

To view the source code for com.itextpdf.text Element ALIGN_BASELINE.

Click Source Link

Document

A possible value for vertical alignment.

Usage

From source file:javaresturentdesktopclient.BillingPage.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    // TODO add your handling code here:

    try {/*  w w w  .ja va  2  s  .c  o  m*/
        Document doc = new Document(PageSize.A4.rotate());
        String Datee = Date;
        PdfWriter.getInstance(doc,
                new FileOutputStream("d:/BillingTable_" + transactionId + "_" + Datee + ".pdf"));

        PdfPTable pdfTable = new PdfPTable(jTableMealOrder.getColumnCount());
        //adding table headers
        for (int i = 0; i < jTableMealOrder.getColumnCount(); i++) {
            pdfTable.addCell(jTableMealOrder.getColumnName(i));
        }
        //extracting data from the JTable and inserting it to PdfPTable
        for (int rows = 0; rows < jTableMealOrder.getRowCount(); rows++) {
            for (int cols = 0; cols < jTableMealOrder.getColumnCount(); cols++) {
                pdfTable.addCell(jTableMealOrder.getModel().getValueAt(rows, cols).toString());

            }
        }

        doc.open();

        Paragraph preface = new Paragraph("Biliing Id :  " + transactionId
                + "                                                                                                                                  DATE : "
                + Date + "  TIME :" + Time + "\n\n\n\n");
        preface.setAlignment(Element.ALIGN_LEFT);
        doc.add(preface);
        pdfTable.setHorizontalAlignment(Element.ALIGN_CENTER);
        doc.add(pdfTable);

        Paragraph preface1 = new Paragraph("\n\n\n\n\tTotal:" + Total + "\n\n");
        preface1.setAlignment(Element.ALIGN_BASELINE);
        doc.add(preface1);
        doc.add(new Paragraph());

        doc.add(new Paragraph("\n\n\n\nTHANK YOU"));

        doc.close();
        System.out.println("done");
        JOptionPane.showMessageDialog(null, "Printed", "Information", JOptionPane.INFORMATION_MESSAGE);
    } catch (DocumentException ex) {
        Logger.getLogger(BillingPage.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(BillingPage.class.getName()).log(Level.SEVERE, null, ex);
    }

}