Example usage for com.itextpdf.text BaseColor LIGHT_GRAY

List of usage examples for com.itextpdf.text BaseColor LIGHT_GRAY

Introduction

In this page you can find the example usage for com.itextpdf.text BaseColor LIGHT_GRAY.

Prototype

BaseColor LIGHT_GRAY

To view the source code for com.itextpdf.text BaseColor LIGHT_GRAY.

Click Source Link

Usage

From source file:ManagementPackage.Setting.java

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
    // TODO add your handling code here:
    totalAdjustment = 0;/*from   w  ww.  j av  a 2 s.c om*/
    totalTotalPaid = 0;
    total = 0;

    Document doc = new Document();
    try {
        long time = new Date().getTime();
        PdfWriter.getInstance(doc, new FileOutputStream("Reports\\Daily" + time + " " + formatedDate + ".pdf"));
        doc.open();

        PdfPTable table = new PdfPTable(5);
        PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE)));
        cell1.setColspan(10);
        cell1.setPadding(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setBackgroundColor(BaseColor.BLACK);
        table.addCell(cell1);

        PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n"));
        cell21.setColspan(10);
        cell21.setBorder(2);
        cell21.setBorderColorLeft(BaseColor.WHITE);
        table.addCell(cell21);

        PdfPCell cell2 = new PdfPCell(new Paragraph("Daily Report\n"));
        cell2.setColspan(10);
        cell2.setPadding(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell2);

        PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime));
        cell4.setColspan(10);
        cell4.setPaddingBottom(10);
        cell4.setPaddingTop(10);
        cell4.setBorder(2);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell4.setBorderColorRight(BaseColor.WHITE);
        table.addCell(cell4);

        table.addCell("Transaction No");
        table.addCell("Billed By");
        table.addCell("Product Name");
        table.addCell("Qty");
        table.addCell("Amount (TK)");

        String PrevTransNo = " ";
        String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date = '"
                + formatedDate + "'";
        try {
            pst = con.prepareStatement(query);
            rs = pst.executeQuery();
            while (rs.next()) {
                String NewTransNo = rs.getString("trans_no");
                String product_name = rs.getString("product_name");
                String qty = rs.getString("qty");
                String amount = rs.getString("amount");
                String trans_by = rs.getString("trans_by");

                total = total + Float.parseFloat(amount);

                if (PrevTransNo.equals(NewTransNo))
                    table.addCell(" ");
                else {
                    table.addCell(NewTransNo);
                    String query1 = "select adjustment, total_paid from paid_amount where trans_no = '"
                            + NewTransNo + "'";
                    pst1 = con1.prepareStatement(query1);
                    rs1 = pst1.executeQuery();
                    String adjustment = rs1.getString("adjustment");
                    String total_paid = rs1.getString("total_paid");

                    totalAdjustment = totalAdjustment + Float.parseFloat(adjustment);
                    totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid);

                    rs1.close();
                    pst1.close();
                }

                PrevTransNo = rs.getString("trans_no");
                table.addCell(trans_by);
                table.addCell(product_name);
                table.addCell(qty);

                PdfPCell cellAmount = new PdfPCell(new Paragraph(amount));
                cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cellAmount);

            }
            rs.close();
            pst.close();

        } catch (SQLException ex) {
            Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
        }

        PdfPCell cellb = new PdfPCell(new Paragraph(" "));
        cellb.setColspan(10);
        cellb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cellb);

        //
        PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total"));
        celltxtTotal.setColspan(3);
        celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal);

        PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total));
        celltxtTotal1.setColspan(2);
        celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal1);

        PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment"));
        celltxtAdjust.setColspan(3);
        celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust);

        PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment));
        celltxtAdjust1.setColspan(2);
        celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust1);

        PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid"));
        celltxtTotalPaid.setColspan(3);
        celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid);

        PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid));
        celltxtTotalPaid1.setColspan(2);
        celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid1);

        doc.add(table);

        doc.close();

        //JOptionPane.showMessageDialog(null, "Report Created!");
        // open PDF file
        File file = new File("Reports\\Daily" + time + " " + formatedDate + ".pdf");
        if (file.toString().endsWith(".pdf"))
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);
        else {
            Desktop desktop = Desktop.getDesktop();
            desktop.open(file);
        }

    } catch (DocumentException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ManagementPackage.Setting.java

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed

    // TODO add your handling code here:
    totalAdjustment = 0;//w w w .j ava  2 s. com
    totalTotalPaid = 0;
    total = 0;

    Document doc = new Document();
    try {
        long time = new Date().getTime();
        PdfWriter.getInstance(doc,
                new FileOutputStream("Reports\\Monthly" + time + " " + formatedDate + ".pdf"));
        doc.open();

        PdfPTable table = new PdfPTable(5);
        PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE)));
        cell1.setColspan(10);
        cell1.setPadding(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setBackgroundColor(BaseColor.BLACK);
        table.addCell(cell1);

        PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n"));
        cell21.setColspan(10);
        cell21.setBorder(2);
        cell21.setBorderColorLeft(BaseColor.WHITE);
        table.addCell(cell21);

        PdfPCell cell2 = new PdfPCell(new Paragraph("Monthly Report\n"));
        cell2.setColspan(10);
        cell2.setPadding(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell2);

        PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime));
        cell4.setColspan(10);
        cell4.setPaddingBottom(10);
        cell4.setPaddingTop(10);
        cell4.setBorder(2);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell4.setBorderColorRight(BaseColor.WHITE);
        table.addCell(cell4);

        table.addCell("Transaction No");
        table.addCell("Billed By");
        table.addCell("Product Name");
        table.addCell("Qty");
        table.addCell("Amount (TK)");

        String PrevTransNo = " ";
        String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date like '%"
                + month + "%'";
        try {
            pst = con.prepareStatement(query);
            rs = pst.executeQuery();
            while (rs.next()) {
                String NewTransNo = rs.getString("trans_no");
                String product_name = rs.getString("product_name");
                String qty = rs.getString("qty");
                String amount = rs.getString("amount");
                String trans_by = rs.getString("trans_by");

                total = total + Float.parseFloat(amount);

                if (PrevTransNo.equals(NewTransNo))
                    table.addCell(" ");
                else {
                    table.addCell(NewTransNo);
                    String query1 = "select adjustment, total_paid from paid_amount where trans_no = '"
                            + NewTransNo + "'";
                    pst1 = con1.prepareStatement(query1);
                    rs1 = pst1.executeQuery();
                    String adjustment = rs1.getString("adjustment");
                    String total_paid = rs1.getString("total_paid");

                    totalAdjustment = totalAdjustment + Float.parseFloat(adjustment);
                    totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid);

                    rs1.close();
                    pst1.close();
                }

                PrevTransNo = rs.getString("trans_no");
                table.addCell(trans_by);
                table.addCell(product_name);
                table.addCell(qty);

                PdfPCell cellAmount = new PdfPCell(new Paragraph(amount));
                cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cellAmount);

            }
            rs.close();
            pst.close();

        } catch (SQLException ex) {
            Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
        }

        PdfPCell cellb = new PdfPCell(new Paragraph(" "));
        cellb.setColspan(10);
        cellb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cellb);

        //
        PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total"));
        celltxtTotal.setColspan(3);
        celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal);

        PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total));
        celltxtTotal1.setColspan(2);
        celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal1);

        PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment"));
        celltxtAdjust.setColspan(3);
        celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust);

        PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment));
        celltxtAdjust1.setColspan(2);
        celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust1);

        PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid"));
        celltxtTotalPaid.setColspan(3);
        celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid);

        PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid));
        celltxtTotalPaid1.setColspan(2);
        celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid1);

        doc.add(table);

        doc.close();

        //JOptionPane.showMessageDialog(null, "Report Created!");
        // open PDF file
        File file = new File("Reports\\Monthly" + time + " " + formatedDate + ".pdf");
        if (file.toString().endsWith(".pdf"))
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);
        else {
            Desktop desktop = Desktop.getDesktop();
            desktop.open(file);
        }

    } catch (DocumentException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ManagementPackage.Setting.java

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed

    // TODO add your handling code here:
    totalAdjustment = 0;//from w  w  w .j  a  v a  2 s  .  c o  m
    totalTotalPaid = 0;
    total = 0;

    Document doc = new Document();
    try {
        long time = new Date().getTime();
        PdfWriter.getInstance(doc,
                new FileOutputStream("Reports\\Yearly" + time + " " + formatedDate + ".pdf"));
        doc.open();

        PdfPTable table = new PdfPTable(5);
        PdfPCell cell1 = new PdfPCell(new Paragraph("Shop Management System \n\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.WHITE)));
        cell1.setColspan(10);
        cell1.setPadding(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setBackgroundColor(BaseColor.BLACK);
        table.addCell(cell1);

        PdfPCell cell21 = new PdfPCell(new Paragraph("\n\n"));
        cell21.setColspan(10);
        cell21.setBorder(2);
        cell21.setBorderColorLeft(BaseColor.WHITE);
        table.addCell(cell21);

        PdfPCell cell2 = new PdfPCell(new Paragraph("Yearly Report\n"));
        cell2.setColspan(10);
        cell2.setPadding(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell2);

        PdfPCell cell4 = new PdfPCell(new Paragraph("Date: " + formatedDateTime));
        cell4.setColspan(10);
        cell4.setPaddingBottom(10);
        cell4.setPaddingTop(10);
        cell4.setBorder(2);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell4.setBorderColorRight(BaseColor.WHITE);
        table.addCell(cell4);

        table.addCell("Transaction No");
        table.addCell("Billed By");
        table.addCell("Product Name");
        table.addCell("Qty");
        table.addCell("Amount (TK)");

        String PrevTransNo = " ";
        String query = "select trans_no, product_name, qty, amount, trans_by from trans_details where date like '%"
                + year + "%'";
        try {
            pst = con.prepareStatement(query);
            rs = pst.executeQuery();
            while (rs.next()) {
                String NewTransNo = rs.getString("trans_no");
                String product_name = rs.getString("product_name");
                String qty = rs.getString("qty");
                String amount = rs.getString("amount");
                String trans_by = rs.getString("trans_by");

                total = total + Float.parseFloat(amount);

                if (PrevTransNo.equals(NewTransNo))
                    table.addCell(" ");
                else {
                    table.addCell(NewTransNo);
                    String query1 = "select adjustment, total_paid from paid_amount where trans_no = '"
                            + NewTransNo + "'";
                    pst1 = con1.prepareStatement(query1);
                    rs1 = pst1.executeQuery();
                    String adjustment = rs1.getString("adjustment");
                    String total_paid = rs1.getString("total_paid");

                    totalAdjustment = totalAdjustment + Float.parseFloat(adjustment);
                    totalTotalPaid = totalTotalPaid + Float.parseFloat(total_paid);

                    rs1.close();
                    pst1.close();
                }

                PrevTransNo = rs.getString("trans_no");
                table.addCell(trans_by);
                table.addCell(product_name);
                table.addCell(qty);

                PdfPCell cellAmount = new PdfPCell(new Paragraph(amount));
                cellAmount.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cellAmount);

            }
            rs.close();
            pst.close();

        } catch (SQLException ex) {
            Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
        }

        PdfPCell cellb = new PdfPCell(new Paragraph(" "));
        cellb.setColspan(10);
        cellb.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cellb);

        //
        PdfPCell celltxtTotal = new PdfPCell(new Paragraph("Total"));
        celltxtTotal.setColspan(3);
        celltxtTotal.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal);

        PdfPCell celltxtTotal1 = new PdfPCell(new Paragraph("" + total));
        celltxtTotal1.setColspan(2);
        celltxtTotal1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotal1);

        PdfPCell celltxtAdjust = new PdfPCell(new Paragraph("Adjustment"));
        celltxtAdjust.setColspan(3);
        celltxtAdjust.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust);

        PdfPCell celltxtAdjust1 = new PdfPCell(new Paragraph("" + totalAdjustment));
        celltxtAdjust1.setColspan(2);
        celltxtAdjust1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtAdjust1);

        PdfPCell celltxtTotalPaid = new PdfPCell(new Paragraph("Total Paid"));
        celltxtTotalPaid.setColspan(3);
        celltxtTotalPaid.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid);

        PdfPCell celltxtTotalPaid1 = new PdfPCell(new Paragraph("" + totalTotalPaid));
        celltxtTotalPaid1.setColspan(2);
        celltxtTotalPaid1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(celltxtTotalPaid1);

        doc.add(table);

        doc.close();

        //JOptionPane.showMessageDialog(null, "Report Created!");
        // open PDF file
        File file = new File("Reports\\Yearly" + time + " " + formatedDate + ".pdf");
        if (file.toString().endsWith(".pdf"))
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);
        else {
            Desktop desktop = Desktop.getDesktop();
            desktop.open(file);
        }

    } catch (DocumentException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ServiceEnd.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Measurment_Result_Record.MeasurmentSetup.java

/**
 *  write the given table datas to the given document
 * @param doc  document to write the result tables on
 * @param table  the result table /*from   ww  w.  ja va2s.  co m*/
 * @param m_title   the measurment title
 */
public static void addResultTablesTotheDocument(Document doc, JTable table, String m_title)
        throws DocumentException {
    //add the measurment title and table
    Paragraph measurmenttitle = new Paragraph(m_title + "\n ");
    measurmenttitle.getFont().setStyle(com.itextpdf.text.Font.BOLD);
    doc.add(measurmenttitle);

    int colmWidth = table.getColumnCount();
    int rowCount = table.getModel().getRowCount();
    PdfPTable resultTable = new PdfPTable(colmWidth);
    resultTable.setHorizontalAlignment(Element.ALIGN_LEFT);

    //add the table headers
    for (int i = 0; i < colmWidth; i++) {
        String headertext = table.getModel().getColumnName(i);
        PdfPCell cell = new PdfPCell(new Paragraph(headertext));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        resultTable.addCell(cell);
    }

    //add the table body

    for (int r = 0; r < rowCount; r++) {
        for (int c = 0; c < colmWidth; c++) {
            String data = table.getValueAt(r, c).toString();
            resultTable.addCell(data);
        }
    }

    resultTable.setSpacingAfter(10);
    //add the table to the document
    doc.add(resultTable);

}

From source file:net.yuvideo.voipRacuni.classes.PrintPageListing.java

public void createListing() {

    document.open();//  w w  w  . j  av a2  s.co  m
    PdfPTable table = new PdfPTable(5);
    table.setWidthPercentage(100);

    //HEADERS
    PdfPCell cell = new PdfPCell(new Phrase("IZVETAJ-LISTING", fontBold));
    cell.setColspan(5);
    cell.setBorder(0);
    table.addCell(cell);

    //HEADER KORISNIK
    String korisnik;
    if (user.isFirma()) {
        korisnik = user.getNazivFirme();
    } else {
        korisnik = user.getIme();
    }
    cell = new PdfPCell(
            new Phrase(String.format("%s - %s - %s", korisnik, user.getBrojTelefona(), this.period), font));

    cell.setColspan(5);
    cell.setBorder(0);
    table.addCell(cell);

    //HEADER TABLE
    PdfPCell cellH1 = new PdfPCell(new Phrase("br.", fontBold));
    cellH1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(cellH1).setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell cellH2 = new PdfPCell(new Phrase("Pozivani broj", fontBold));
    cellH2.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(cellH2).setHorizontalAlignment(1);

    PdfPCell cellH3 = new PdfPCell(new Phrase("Destinacija", fontBold));
    cellH3.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(cellH3).setHorizontalAlignment(1);

    PdfPCell cellH4 = new PdfPCell(new Phrase("Vreme", fontBold));
    cellH4.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(cellH4).setHorizontalAlignment(1);

    PdfPCell cellH5 = new PdfPCell(new Phrase("Trajanje poziva", fontBold));
    cellH5.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(cellH5).setHorizontalAlignment(1);

    PdfPCell cellIzvestaj;
    int ukupno = 0;

    for (izvestajPotrosnje izvestaj : listing) {
        //potrosnja ukupno

        //Redni broj
        cellIzvestaj = new PdfPCell(new Phrase(String.valueOf(izvestaj.br), font));
        cellIzvestaj.setHorizontalAlignment(1);
        cellIzvestaj.setVerticalAlignment(5);
        table.addCell(cellIzvestaj);

        //Pozivani broj
        cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getSource(), font));
        cellIzvestaj.setHorizontalAlignment(1);
        cellIzvestaj.setVerticalAlignment(5);
        table.addCell(cellIzvestaj);

        //Destinacija
        cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getDestination(), font));
        cellIzvestaj.setHorizontalAlignment(1);
        cellIzvestaj.setVerticalAlignment(5);
        table.addCell(cellIzvestaj);

        //Vreme
        cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getDatumPoziva(), font));
        cellIzvestaj.setHorizontalAlignment(1);
        cellIzvestaj.setVerticalAlignment(5);
        table.addCell(cellIzvestaj);

        //trajanje poziva
        cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getTrajanje(), font));
        cellIzvestaj.setHorizontalAlignment(1);
        cellIzvestaj.setVerticalAlignment(5);
        table.addCell(cellIzvestaj);

        ukupno = izvestaj.getUkupno_poziv();
    }

    PdfPCell footer = new PdfPCell(new Phrase(
            String.format("Ukupno: %s", LocalTime.MIN.plusSeconds(ukupno).toString()), fontLargeBold));
    footer.setColspan(5);
    footer.setHorizontalAlignment(2);
    footer.setBorder(0);
    table.addCell(footer);

    try {
        document.add(table);
    } catch (DocumentException ex) {
        Logger.getLogger(PrintPageListing.class.getName()).log(Level.SEVERE, null, ex);
    }

    document.close();

}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void createTable(Paragraph paragrah) throws MalformedURLException, IOException, DocumentException {
    PdfPTable table = new PdfPTable(6);
    table.setHeaderRows(0);/*w  w  w  .  j  a va2s.c  o m*/
    table.setWidthPercentage(95f);
    PdfPCell c1 = new PdfPCell(new Phrase(Messages.elementType));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.name));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.property));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.information));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.status));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.reviewed));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);

    List<Change> changes = report.getChanges();
    if (viewer != null) {
        for (int i = 0; i < changes.size(); i++) {
            addTableRow(table, (Change) viewer.getElementAt(i));
        }
    } else {
        for (Change change : changes) {
            addTableRow(table, change);
        }
    }

    table.setWidths(new int[] { 3, 3, 3, 5, 2, 2 });
    table.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.setComplete(true);

    paragrah.add(table);
}

From source file:org.cejug.yougi.web.report.EventAttendeeReport.java

License:Open Source License

public void printReport(List<Attendee> attendees) throws DocumentException {
    float[] columnSizes = { 20, 220, 220, 60 };
    PdfPTable table = new PdfPTable(columnSizes.length);
    table.setLockedWidth(true);/*from   w  w  w .j av a  2 s . c o  m*/
    table.setTotalWidth(columnSizes);

    PdfPCell headerCell = new PdfPCell(new Phrase("Yougi"));
    headerCell.setColspan(4);
    headerCell.setBackgroundColor(BaseColor.ORANGE);
    headerCell.setPadding(3);
    table.addCell(headerCell);

    table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);

    PdfPCell checkCell = new PdfPCell(new Phrase(" "));
    checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(checkCell);

    PdfPCell productCell = new PdfPCell(new Phrase("Nome"));
    productCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    productCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    table.addCell(productCell);

    PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email"));
    currentPurchaseCell.setPadding(3);
    currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(currentPurchaseCell);

    PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente"));
    previousPurchaseCell.setPadding(3);
    previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(previousPurchaseCell);

    table.getDefaultCell().setBackgroundColor(null);
    table.setHeaderRows(2);

    Font font = new Font(Font.FontFamily.HELVETICA, 9);
    int seq = 1;
    for (Attendee attendee : attendees) {
        table.addCell(new Phrase(String.valueOf(seq++), font));

        table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font));

        table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font));

        table.addCell(" ");
    }

    document.add(table);
}

From source file:org.cherchgk.actions.tournament.result.show.GetPDFTournamentResultAction.java

License:Apache License

public InputStream getDocument() throws DocumentException, IOException {
    Font normalFont = getNormalFont();
    Font boldFont = getBoldFont();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, out);
    document.open();/* ww  w  .  j  av a  2s .  c  o  m*/

    Paragraph tournamentNameParagraph = new Paragraph(tournament.getTitle(), boldFont);
    tournamentNameParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentNameParagraph);

    Paragraph tournamentDateParagraph = new Paragraph(tournament.getDateAsString(), boldFont);
    tournamentDateParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentDateParagraph);

    if (teamCategory != null) {
        Paragraph teamCategoryParagraph = new Paragraph(teamCategory.getTitle(), boldFont);
        teamCategoryParagraph.setAlignment(Element.ALIGN_CENTER);
        document.add(teamCategoryParagraph);
    }

    int numColumns = 3 + tournamentResult.getRankingAlgorithms().size();
    PdfPTable resultTable = new PdfPTable(numColumns);
    int[] widths = new int[numColumns];
    widths[0] = 1;
    widths[1] = 3;
    for (int i = 2; i < numColumns; i++) {
        widths[i] = 1;
    }
    resultTable.setWidths(widths);
    resultTable.setSpacingBefore(10f);

    PdfPCell cell = new PdfPCell(new Phrase("", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setColspan(2);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    for (RankingAlgorithm rankingAlgorithm : tournamentResult.getRankingAlgorithms()) {
        cell = new PdfPCell(new Phrase(rankingAlgorithm.getPointName(), boldFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        resultTable.addCell(cell);
    }

    cell = new PdfPCell(new Phrase("?", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    boolean showTeamCategoryInTable = (teamCategory == null) && !tournament.getTeamCategories().isEmpty();

    for (TournamentResult.TeamResult teamResult : tournamentResult.getTeamResultList()) {
        if (showTeamCategoryInTable) {
            if (teamResult.getTeam().getTeamCategory() != null) {
                cell = new PdfPCell(new Phrase(teamResult.getTeam().getTeamCategory().getTitle(), normalFont));
            } else {
                cell = new PdfPCell(new Phrase("", normalFont));
            }
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getTeam().getName(), normalFont));
        if (!showTeamCategoryInTable) {
            cell.setColspan(2);
        }
        resultTable.addCell(cell);
        for (Map<Team, RankingPoint> m : tournamentResult.getRankingPointsList()) {
            cell = new PdfPCell(new Phrase(m.get(teamResult.getTeam()).toString(), normalFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getPlace(), normalFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        resultTable.addCell(cell);
    }

    document.add(resultTable);
    document.close();

    return new ByteArrayInputStream(out.toByteArray());
}

From source file:org.com.controller.ProductController.java

@RequestMapping(value = "/repProduct", method = RequestMethod.GET)
public void productReport(Model m, HttpServletResponse response, HttpServletRequest request,
        OutputStream outputStream) throws Exception {
    String name = "ProductReport-";
    Date d = new Date();
    name = name + d.toString() + ".pdf";
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "attachment; filename=" + name);
    Rectangle pagesize = new Rectangle(216f, 720f);
    Document document = new Document(PageSize.A4);
    PdfWriter.getInstance(document, outputStream);
    document.open();/*w  w w  .j a  v a2  s.co  m*/
    document.addTitle("PRODUCT DETAILSA REPORT");
    document.add(new Paragraph("PRODUCT DETAILSA REPORT ",
            FontFactory.getFont(FontFactory.HELVETICA, 28, BaseColor.CYAN)));
    document.add(new Paragraph("DATE: " + new Date()));
    document.add(new Paragraph("-------------------------------------------------------- "));
    document.add(new Paragraph(" "));
    ProductDaoImpl pdi = new ProductDaoImpl();
    PdfPTable table = new PdfPTable(4);
    table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell("ID");
    table.addCell("TITLE");
    table.addCell("PUBLISHER");
    table.addCell("PRICE");
    ArrayList<ProductTable> list = pdi.getAllProduct();
    for (ProductTable u : list) {
        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(u.getPid().toString());
        table.getDefaultCell().setBackgroundColor(BaseColor.GRAY);
        table.addCell(u.getPname());
        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(u.getPublisher());
        table.getDefaultCell().setBackgroundColor(BaseColor.GRAY);
        table.addCell(u.getSprice().toString());
    }
    document.add(table);
    document.close();

}

From source file:org.larz.dom4.editor.ReportGenerator.java

License:Open Source License

public static void generateReport(XtextEditor sourcePage, final Shell shell) {
    final IXtextDocument myDocument = ((XtextEditor) sourcePage).getDocument();
    myDocument.modify(new IUnitOfWork.Void<XtextResource>() {
        @Override/*w  w  w  .  j  a v  a2 s . com*/
        public void process(XtextResource resource) throws Exception {
            Map<String, Map<String, ModObject>> cellMap = new HashMap<String, Map<String, ModObject>>();

            Dom4Mod dom4Mod = (Dom4Mod) resource.getContents().get(0);
            EList<AbstractElement> elements = dom4Mod.getElements();
            for (AbstractElement element : elements) {
                if (element instanceof SelectArmorById || element instanceof SelectArmorByName) {
                    String name = getSelectArmorname((Armor) element);
                    if (name == null)
                        continue;
                    String id = getArmorid((Armor) element);

                    Map<String, ModObject> map = cellMap.get(ARMOR);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ARMOR, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Armor) element, modObject.propertyMap);
                } else if (element instanceof NewArmor) {
                    String name = getArmorname((Armor) element);
                    String id = getArmorid((Armor) element);

                    Map<String, ModObject> map = cellMap.get(ARMOR);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ARMOR, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Armor) element, modObject.propertyMap);
                } else if (element instanceof SelectWeaponById || element instanceof SelectWeaponByName) {
                    String name = getSelectWeaponname((Weapon) element);
                    String id = getWeaponid((Weapon) element);

                    Map<String, ModObject> map = cellMap.get(WEAPONS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(WEAPONS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Weapon) element, modObject.propertyMap);
                } else if (element instanceof NewWeapon) {
                    String name = getWeaponname((Weapon) element);
                    String id = getWeaponid((Weapon) element);

                    Map<String, ModObject> map = cellMap.get(WEAPONS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(WEAPONS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Weapon) element, modObject.propertyMap);
                } else if (element instanceof SelectMonsterById || element instanceof SelectMonsterByName) {
                    String name = getSelectMonstername((Monster) element);
                    String id = getMonsterid((Monster) element);

                    Map<String, ModObject> map = cellMap.get(MONSTERS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(MONSTERS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Monster) element, modObject.propertyMap);
                } else if (element instanceof NewMonster) {
                    String name = getMonstername((Monster) element);
                    String id = getMonsterid((Monster) element);

                    Map<String, ModObject> map = cellMap.get(MONSTERS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(MONSTERS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Monster) element, modObject.propertyMap);
                } else if (element instanceof SelectSpellById || element instanceof SelectSpellByName) {
                    String name = getSelectSpellname((Spell) element);
                    String id = getSpellid((Spell) element);

                    Map<String, ModObject> map = cellMap.get(SPELLS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SPELLS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Spell) element, modObject.propertyMap);
                } else if (element instanceof NewSpell) {
                    String name = getSpellname((Spell) element);
                    //String id = getSpellid((Spell)element);

                    Map<String, ModObject> map = cellMap.get(SPELLS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SPELLS, map);
                    }
                    ModObject modObject = map.get(name);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = "" + name;
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(name, modObject);
                    }
                    setPropertyValues((Spell) element, modObject.propertyMap);
                } else if (element instanceof SelectItemById || element instanceof SelectItemByName) {
                    String name = getSelectItemname((Item) element);
                    String id = getItemid((Item) element);

                    Map<String, ModObject> map = cellMap.get(ITEMS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ITEMS, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Item) element, modObject.propertyMap);
                } else if (element instanceof NewItem) {
                    String name = getItemname((Item) element);
                    //String id = getItemid((Item)element);

                    Map<String, ModObject> map = cellMap.get(ITEMS);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(ITEMS, map);
                    }
                    ModObject modObject = map.get(name);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name;
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(name, modObject);
                    }
                    setPropertyValues((Item) element, modObject.propertyMap);
                } else if (element instanceof SelectSiteById || element instanceof SelectSiteByName) {
                    String name = getSelectSitename((Site) element);
                    String id = getSiteid((Site) element);

                    Map<String, ModObject> map = cellMap.get(SITES);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SITES, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Site) element, modObject.propertyMap);
                } else if (element instanceof NewSite) {
                    String name = getSitename((Site) element);
                    String id = getSiteid((Site) element);

                    Map<String, ModObject> map = cellMap.get(SITES);
                    if (map == null) {
                        map = new HashMap<String, ModObject>();
                        cellMap.put(SITES, map);
                    }
                    ModObject modObject = map.get(id);
                    if (modObject == null) {
                        modObject = new ModObject();
                        modObject.title = name + " (" + id + ")";
                        modObject.propertyMap = new HashMap<String, PropertyValues>();
                        map.put(id, modObject);
                    }
                    setPropertyValues((Site) element, modObject.propertyMap);
                } else if (element instanceof SelectNation) {
                    //                  String name = getSelectNationname((Nation)element);
                    //                  String id = getNationid((Nation)element);
                    //
                    //                  Map<String, ModObject> map = cellMap.get(NATIONS);
                    //                  if (map == null) {
                    //                     map = new HashMap<String, ModObject>();
                    //                     cellMap.put(NATIONS, map);
                    //                  }
                    //                  ModObject modObject = map.get(id);
                    //                  if (modObject == null) {
                    //                     modObject = new ModObject();
                    //                     modObject.title = name + " (" + id + ")";
                    //                     modObject.propertyMap = new HashMap<String, PropertyValues>();
                    //                     map.put(id, modObject);
                    //                  }
                    //                  setPropertyValues((SelectNation)element, modObject.propertyMap, resource);
                }

            }

            try {
                // step 1
                Document document = new Document(PageSize.LETTER.rotate());
                // step 2
                File tempFile = File.createTempFile("dom4editor", ".pdf");
                tempFile.deleteOnExit();
                FileOutputStream tempFileOutputStream = new FileOutputStream(tempFile);

                PdfWriter.getInstance(document, tempFileOutputStream);
                // step 3
                document.open();

                List<Map.Entry<String, Map<String, ModObject>>> cellList = new ArrayList<Map.Entry<String, Map<String, ModObject>>>();
                for (Map.Entry<String, Map<String, ModObject>> innerEntry : cellMap.entrySet()) {
                    cellList.add(innerEntry);
                }
                Collections.sort(cellList, new Comparator<Map.Entry<String, Map<String, ModObject>>>() {
                    @Override
                    public int compare(Map.Entry<String, Map<String, ModObject>> o1,
                            Map.Entry<String, Map<String, ModObject>> o2) {
                        return o1.getKey().compareTo(o2.getKey());
                    }
                });

                for (Map.Entry<String, Map<String, ModObject>> entry : cellList) {
                    PdfPTable table = new PdfPTable(1);
                    table.setWidthPercentage(100f);

                    PdfPCell cell = new PdfPCell(new Phrase(entry.getKey(), TITLE));
                    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                    cell.setFixedHeight(26f);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
                    table.addCell(cell);
                    table.setHeaderRows(1);

                    List<Map.Entry<String, ModObject>> list = new ArrayList<Map.Entry<String, ModObject>>();
                    for (Map.Entry<String, ModObject> innerEntry : entry.getValue().entrySet()) {
                        list.add(innerEntry);
                    }

                    Collections.sort(list, new Comparator<Map.Entry<String, ModObject>>() {
                        @Override
                        public int compare(Map.Entry<String, ModObject> o1, Map.Entry<String, ModObject> o2) {
                            return o1.getValue().title.compareTo(o2.getValue().title);
                        }
                    });

                    PdfPTable propertyTable = null;
                    if (entry.getKey().equals(ARMOR)) {
                        propertyTable = getTable(new String[] { "name", "type", "prot", "def", "enc", "rcost" },
                                new String[] { "Name", "Type", "Prot", "Def", "Enc", "Rcost" },
                                new ValueTranslator[] { null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("4"))
                                            return "Shield";
                                        if (value.equals("5"))
                                            return "Body Armor";
                                        if (value.equals("6"))
                                            return "Helmet";
                                        return "Unknown";
                                    }
                                }, null, null, null, null }, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(WEAPONS)) {
                        propertyTable = getTable(
                                new String[] { "name", "dmg", "att", "nratt", "def", "len", "range", "ammo",
                                        "rcost" },
                                new String[] { "Name", "Dmg", "Att", "Nratt", "Def", "Len", "Range", "Ammo",
                                        "Rcost" },
                                null, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(MONSTERS)) {
                        propertyTable = getTable(
                                new String[] { "name", "hp", "prot", "MOVE", "size", "ressize", "str", "enc",
                                        "att", "def", "prec", "mr", "mor", "gcost", "rcost" },
                                new String[] { "Name", "HP", "Prot", "Move", "Size", "Rsize", "Str", "Enc",
                                        "Att", "Def", "Prec", "MR", "Mor", "Gcost", "Rcost" },
                                null, new ValueCombiner[] { null, null, null, new ValueCombiner() {
                                    @Override
                                    public String translate(String[] value) {
                                        if (value[0] == null && value[1] == null)
                                            return null;
                                        return value[0] + "/" + value[1];
                                    }

                                    @Override
                                    public String[] getNeededColumns() {
                                        return new String[] { "mapmove", "ap" };
                                    }
                                }, null, null, null, null, null, null, null, null, null, null, null }, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(ITEMS)) {
                        propertyTable = getTable(
                                new String[] { "name", "constlevel", "PATH", "type", "weapon", "armor" },
                                new String[] { "Name", "Constlevel", "Path Req", "Type", "Weapon", "Armor" },
                                new ValueTranslator[] { null, null, null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("1"))
                                            return "1-h Weapon";
                                        if (value.equals("2"))
                                            return "2-h Weapon";
                                        if (value.equals("3"))
                                            return "Missile Weapon";
                                        if (value.equals("4"))
                                            return "Shield";
                                        if (value.equals("5"))
                                            return "Body Armor";
                                        if (value.equals("6"))
                                            return "Helmet";
                                        if (value.equals("7"))
                                            return "Boots";
                                        if (value.equals("8"))
                                            return "Misc";
                                        return "Unknown";
                                    }
                                }, null, null }, new ValueCombiner[] { null, null, new ValueCombiner() {
                                    @Override
                                    public String translate(String[] value) {
                                        if (value[0] == null && value[1] == null && value[2] == null
                                                && value[3] == null)
                                            return null;
                                        StringBuffer buf = new StringBuffer();
                                        if (value[0] != null && !value[0].equals("null")) {
                                            buf.append(getPathName(Integer.parseInt(value[0])) + value[1]);
                                        }
                                        if (value[2] != null && !value[2].equals("null")
                                                && !value[2].equals("-1")) {
                                            buf.append(getPathName(Integer.parseInt(value[2])) + value[3]);
                                        }
                                        return buf.toString();
                                    }

                                    @Override
                                    public String[] getNeededColumns() {
                                        return new String[] { "mainpath", "mainlevel", "secondarypath",
                                                "secondarylevel" };
                                    }
                                }, null, null, null }, list);
                        propertyTable.setWidths(new float[] { 2.5f, 1, 1, 1, 2.5f, 2.5f });
                    }
                    if (entry.getKey().equals(SPELLS)) {
                        propertyTable = getTable(
                                new String[] { "name", "school", "researchlevel", "aoe", "damage", "effect",
                                        "fatiguecost", "nreff", "range", "precision", "spec", "nextspell" },
                                new String[] { "Name", "School", "Research", "AOE", "Damage", "Effect",
                                        "Fatigue", "Nreff", "Range", "Precision", "Spec", "Nextspell" },
                                null, null, list);
                        propertyTable.setWidths(new float[] { 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(NATIONS)) {
                        propertyTable = getTable(new String[] { "name", "startsite1", "startsite2",
                                "startsite3", "startsite4", "era", "startfort" }, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1 });
                    }
                    if (entry.getKey().equals(SITES)) {
                        propertyTable = getTable(
                                new String[] { "name", "path", "level", "rarity", "loc", "homemon", "homecom",
                                        "gold", "res" },
                                new String[] { "Name", "Path", "Level", "Rarity", "Loc", "Homemon", "Homecom",
                                        "Gold", "Res" },
                                new ValueTranslator[] { null, new ValueTranslator() {
                                    @Override
                                    public String translate(String value) {
                                        if (value == null)
                                            return null;
                                        if (value.equals("0"))
                                            return "Fire";
                                        if (value.equals("1"))
                                            return "Air";
                                        if (value.equals("2"))
                                            return "Water";
                                        if (value.equals("3"))
                                            return "Earth";
                                        if (value.equals("4"))
                                            return "Astral";
                                        if (value.equals("5"))
                                            return "Death";
                                        if (value.equals("6"))
                                            return "Nature";
                                        if (value.equals("7"))
                                            return "Blood";
                                        return "Unknown";
                                    }
                                }, null, null, null, null, null, null, null }, null, list);
                        propertyTable.setWidths(new float[] { 5, 1, 1, 1, 1, 1, 1, 1, 1 });
                    }
                    PdfPCell innerCell = new PdfPCell();
                    innerCell.addElement(propertyTable);
                    innerCell.setBorder(PdfPCell.NO_BORDER);
                    innerCell.setHorizontalAlignment(Element.ALIGN_LEFT);

                    table.addCell(innerCell);
                    document.add(table);
                    document.newPage();
                }
                document.close();

                tempFileOutputStream.flush();
                tempFileOutputStream.close();

                Program pdfViewer = Program.findProgram("pdf");
                if (pdfViewer != null) {
                    pdfViewer.execute(tempFile.getAbsolutePath());
                } else {
                    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
                    dialog.setFilterExtensions(new String[] { "*.pdf" });
                    if (dialog.open() != null) {
                        FileInputStream from = null;
                        FileOutputStream to = null;
                        try {
                            String filterPath = dialog.getFilterPath();
                            String name = dialog.getFileName();

                            from = new FileInputStream(new File(tempFile.getAbsolutePath()));
                            to = new FileOutputStream(new File(filterPath + File.separator + name));
                            byte[] buffer = new byte[4096];
                            int bytesRead;

                            while ((bytesRead = from.read(buffer)) != -1) {
                                to.write(buffer, 0, bytesRead); // write
                            }
                        } finally {
                            if (from != null) {
                                from.close();
                            }
                            if (to != null) {
                                to.close();
                            }
                        }
                    }
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}