Example usage for com.itextpdf.text.pdf PdfPTable setWidths

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidths.

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:servlet.SalesReportPDF.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from ww  w. j  a  v a 2 s .co  m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        Document document = new Document();
        List<ArrayList> data = productSession.getEventList();
        List<ArrayList> sessions = getAllProductDetailsLocal.getAllSessions();

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        //get current date time with Date()
        Date date = new Date();
        //System.out.println(dateFormat.format(date));

        @SuppressWarnings("unused")
        PdfWriter pdfWriter = PdfWriter.getInstance(document,
                new FileOutputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf"));
        document.open();
        document.add(new Paragraph("Management Report",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLUE)));
        document.add(new Paragraph("PDF created on " + dateFormat.format(date).toString() + "\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        document.add(new Paragraph(
                "------------------------------------------------------------------------------------",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK)));

        for (int i = 0; i < data.size(); i++) {
            document.add(new Paragraph(data.get(i).get(1).toString() + " Event Details ",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            document.add(new Paragraph("Event Type : " + data.get(i).get(4).toString() + "\nStart Date : "
                    + data.get(i).get(2).toString() + "\nEnd Date : " + data.get(i).get(3).toString()
                    + "\nProperty Name : " + data.get(i).get(5).toString() + "\nNo of Category : "
                    + data.get(i).get(6).toString() + "\nPromotions : " + data.get(i).get(7).toString()
                    + "\n\n"));
            document.add(new Paragraph("Session",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            PdfPTable table = new PdfPTable(6);
            //table.addCell("item1");
            table.setSpacingBefore(5);
            table.setSpacingAfter(5);
            table.setWidths(new int[] { 1, 2, 3, 3, 3, 3 });
            table.setWidthPercentage(100);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("No:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Name:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Description:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Start:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("End:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("TicketPrices:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);

            for (int j = 0; j < sessions.size(); j++) {
                if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString())
                        && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString())) {
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(4).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(5).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(6).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(7).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(9).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                }

            }
            document.add(table);
            document.add(new Paragraph("\n"));
            document.add(new Paragraph("Alert",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            table = new PdfPTable(6);
            //table.addCell("item1");
            table.setSpacingBefore(5);
            table.setSpacingAfter(5);
            table.setWidths(new int[] { 1, 2, 2, 3, 3, 3 });
            table.setWidthPercentage(100);
            cell = new PdfPCell(new Phrase("No:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Alert Type:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Below Sales:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("In-Charged Email:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("Start:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("End:",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell(cell);

            for (int j = 0; j < sessions.size(); j++) {
                if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString())
                        && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString())
                        && sessions.get(j).size() == 15) {

                    cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(10).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(11).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(12).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(13).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                    cell = new PdfPCell(new Phrase(sessions.get(j).get(14).toString()));
                    cell.setBackgroundColor(BaseColor.WHITE);
                    table.addCell(cell);
                }

            }
            document.add(table);
            document.add(new Paragraph("\n\n"));

        }
        document.close();

        Thread.sleep(1000);

        PrintWriter out = response.getWriter();
        String fileName = "EventRecords.pdf";
        String filePath = "C:/Users/Yong Jing Ying/Desktop/";
        response.setContentType("APPLICATION/OCTET-STREAM");
        response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");

        FileInputStream fi = new FileInputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf");
        int i;
        while ((i = fi.read()) != -1) {
            out.write(i);
        }

        out.close();
        fi.close();
    } catch (Exception ex) {
        Logger.getLogger(SalesReportPDF.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Software_Jframes.chart.java

void print_pdf_report(JTable jTable5) {
    Access ac = new Access();
    try {/*from  ww  w.ja  v a 2  s .co m*/
        String filename = ac.chooseFile();

        com.itextpdf.text.Document document = new com.itextpdf.text.Document();
        PdfWriter.getInstance(document, new FileOutputStream(filename + ".pdf"));

        document.open();
        document.add(new Paragraph(""));

        Image image1 = Image.getInstance("src/images/ROPA_Logo_without_claim.jpg");
        document.add(new Paragraph(""));
        image1.scaleAbsolute(80, 50);
        image1.setAbsolutePosition(50, 800);

        document.add(image1);
        PdfPTable table = new PdfPTable(3); // 3 columns.

        DefaultTableModel dtm = (DefaultTableModel) jTable5.getModel();
        Vector v = new Vector();
        int count_row = dtm.getRowCount();
        int count_col = dtm.getColumnCount();

        for (int i = 0; i < count_row; i++) {
            for (int j = 0; j < count_col; j++) {

                table.addCell(new PdfPCell(new Paragraph(dtm.getValueAt(i, j) + "")));

            }
        }
        table.setWidthPercentage(100);
        float[] columnWidths = { 2f, 1f, 1f };

        table.setWidths(columnWidths);

        document.add(table);
        document.close();
        JOptionPane.showMessageDialog(null, "Successfully Created.");

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

From source file:src.servlets.ManageAdmin.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request//from   w w w. ja  v a 2  s  .c o m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    Map m = request.getParameterMap();
    if (m.containsKey("GetPDF")) {
        try {
            String Report = getServletContext().getRealPath("") + "admin\\PDF_Report.pdf";

            FileOutputStream file = new FileOutputStream(Report);
            Document document = new Document();
            document.addAuthor("K00140908");
            PdfWriter.getInstance(document, file);
            ///////////////////////ADDING THE FILES TO PDF////////////////////
            //Inserting Image in PDF
            String uploadPath = getServletContext().getRealPath("") + "images\\logo.gif";

            Image img = Image.getInstance(uploadPath);

            img.scaleAbsolute(120f, 60f);// width,height of image in float

            //            Inserting Title in PDF  ORIGINAL
            //            Font fontTitle=new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.WHITE);
            //            Chunk title=new Chunk("PDF GENERATION in Java with iText", fontTitle);
            //            title.setBackground(new BaseColor(255,102,0), 1f, 1f, 1f, 3f);
            //            title.setLineHeight(30f);
            //            title.setUnderline(BaseColor.BLACK,5f,0.5f,2f,0.5f,PdfContentByte.LINE_CAP_ROUND);
            Font fontTitle = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD, BaseColor.BLACK);
            Chunk title = new Chunk("Lit Realty System Report", fontTitle);
            title.setLineHeight(30f);

            //Inserting Table in PDF
            PdfPTable table = new PdfPTable(3);
            table.setWidthPercentage(100); // Sets the width percentage that the table will occupy in the page
            table.setSpacingAfter(10f);
            table.setSpacingBefore(15f);
            table.setWidths(new float[] { 2f, 2f, 2f }); // Sets relative width of table

            Font fontHeader = new Font(Font.FontFamily.HELVETICA, 15, Font.BOLD, BaseColor.BLUE);
            PdfPCell headercell = new PdfPCell(new Phrase("Property Photo", fontHeader)); // Creates new cell in table
            headercell.setBackgroundColor(new BaseColor(230, 230, 243));
            headercell.setPaddingBottom(5f);
            table.addCell(headercell);

            headercell = new PdfPCell(new Phrase("Property ID", fontHeader));
            headercell.setBackgroundColor(new BaseColor(233, 233, 233));
            headercell.setPaddingBottom(5f);
            table.addCell(headercell);

            headercell = new PdfPCell(new Phrase("Price", fontHeader));
            headercell.setBackgroundColor(new BaseColor(233, 233, 233));
            headercell.setPaddingBottom(5f);
            table.addCell(headercell);

            PdfPCell cell1 = new PdfPCell(img, false);

            table.addCell(cell1);
            table.addCell("134000");
            table.addCell("213445");
            table.addCell("134000");

            //Inserting List
            com.itextpdf.text.List list = new com.itextpdf.text.List(true, 30);
            list.add(new ListItem("Example1"));
            list.add(new ListItem("Example2"));
            list.add(new ListItem("Example3"));

            //Adding elements into PDF Document
            document.open();

            document.add(img);
            document.add(title);

            document.add(Chunk.NEWLINE);
            document.add(table);

            document.newPage();
            document.add(new Chunk("List of Examples").setUnderline(+1f, -5f));
            document.add(list);

            document.newPage();
            document.add(new Chunk("List of Examples").setUnderline(+1f, -5f));
            document.add(list);

            document.newPage();
            document.add(new Chunk("List of Properts By Agent X").setUnderline(+1f, -5f));
            //////////////////////GET Propertys From Entity///////////////
            List<Properties> allPropertiesList = PropertiesDB.getAllProperties();

            PdfPTable propertyTable = new PdfPTable(3);
            PdfPCell propertyHeadingcell1 = new PdfPCell(new Phrase("Photo"));
            PdfPCell propertyHeadingcell2 = new PdfPCell(new Phrase("Property ID"));
            PdfPCell propertyHeadingcell3 = new PdfPCell(new Phrase("Price"));

            propertyHeadingcell1.setBorder(Rectangle.NO_BORDER);
            propertyHeadingcell2.setBorder(Rectangle.NO_BORDER);
            propertyHeadingcell3.setBorder(Rectangle.NO_BORDER);

            propertyTable.addCell(propertyHeadingcell1);
            propertyTable.addCell(propertyHeadingcell2);
            propertyTable.addCell(propertyHeadingcell3);

            document.add(Chunk.NEWLINE);

            String uploadPathforPropertyPhoto = getServletContext().getRealPath("")
                    + "images\\properties\\thumbnails\\";

            Image propertyThumbnail;

            img.scaleAbsolute(120f, 60f);// width,height of image in float

            for (Properties anProperty : allPropertiesList) {
                propertyThumbnail = Image.getInstance(uploadPathforPropertyPhoto + anProperty.getPhoto());
                PdfPCell propertycell1 = new PdfPCell(propertyThumbnail, false);
                propertycell1.setPaddingBottom(20);
                PdfPCell propertycell2 = new PdfPCell(new Phrase(anProperty.getListingNum().toString()));
                PdfPCell propertycell3 = new PdfPCell(new Phrase(anProperty.getPrice().toString()));

                propertycell1.setBorder(Rectangle.NO_BORDER);
                propertycell2.setBorder(Rectangle.NO_BORDER);
                propertycell3.setBorder(Rectangle.NO_BORDER);

                propertyTable.addCell(propertycell1);
                propertyTable.addCell(propertycell2);
                propertyTable.addCell(propertycell3);

            }
            document.add(Chunk.NEWLINE);
            document.add(propertyTable);
            //////////////////////GET Propertys From Entity///////////////

            document.close();
            file.close();

            System.out.println("Pdf created successfully ! :)");

            String filePath = Report;
            File downloadFile = new File(filePath);
            FileInputStream inStream = new FileInputStream(downloadFile);

            // if you want to use a relative path to context root:
            String relativePath = getServletContext().getRealPath("");
            System.out.println("relativePath = " + relativePath);

            // obtains ServletContext
            ServletContext context = getServletContext();

            // gets MIME type of the file
            String mimeType = context.getMimeType(filePath);
            if (mimeType == null) {
                // set to binary type if MIME mapping not found
                mimeType = "application/octet-stream";
            }
            System.out.println("MIME type: " + mimeType);

            // modifies response
            response.setContentType(mimeType);
            response.setContentLength((int) downloadFile.length());

            // forces download
            String headerKey = "Content-Disposition";
            String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName());
            response.setHeader(headerKey, headerValue);

            // obtains response's output stream
            OutputStream outStream = response.getOutputStream();

            byte[] buffer = new byte[4096];
            int bytesRead = -1;

            while ((bytesRead = inStream.read(buffer)) != -1) {
                outStream.write(buffer, 0, bytesRead);
            }

            inStream.close();
            outStream.close();
            /////////////////

            processRequest(request, response);
        } catch (DocumentException ex) {
            Logger.getLogger(ManageAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:superlaskuttaja.logiikka.PdfExtractor.java

private void muodostaDokumentti(Document document, String laskunNumero, PdfWriter writer)
        throws DocumentException, SQLException, ParseException {
    document.open();/*w ww.j  a va2s.c o m*/
    //----------------------------------------------------------------------
    PdfPTable table1 = new PdfPTable(7);
    Font f1 = new Font(Font.FontFamily.HELVETICA, 10);
    Font f2 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD);
    Font f3 = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD);
    Font f4 = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD);
    ResultSet rs = lataaja.getDbc()
            .executeQuery("select distinct Laskuttaja.yrityksenNimi, Laskuttaja.katuosoite,\n"
                    + "Laskuttaja.postinumero, Laskuttaja.kaupunki, Lasku.paivays, Laskuttaja.alvTunniste,\n"
                    + "Pankkiviivakoodi.erapaiva, Lasku.viivastyskorko, Pankkiviivakoodi.viiteTarkisteella,\n"
                    + "T.nimi, Lasku.maksuehto, T.katuosoite, Laskuttaja.tilinumeronPankki,\n"
                    + "T.postinumero, T.kaupunki, Laskuttaja.tilinumero, T.email, Laskuttaja.tilinumeronSwiftBic,\n"
                    + "V.nimi, V.katuosoite, V.postinumero, V.kaupunki, V.email, Lasku.lisatiedot,\n"
                    + "T.asiakasnumero, V.asiakasnumero, Laskuttaja.nimi, Laskuttaja.puhelinnumero,\n"
                    + "Laskuttaja.sahkopostiOsoite, Pankkiviivakoodi.pankkiviivakoodi\n"
                    + "from Lasku, Pankkiviivakoodi, Laskuttaja, Suorite, Asiakas T, Asiakas V\n"
                    + "where Lasku.laskunNumero = " + laskunNumero + "\n"
                    + "and Lasku.laskuttaja = Laskuttaja.yrityksenNimi\n"
                    + "and Lasku.laskuttajanVersio = Laskuttaja.versio\n"
                    + "and Lasku.pankkiviivakoodi = Pankkiviivakoodi.pankkiviivakoodi\n"
                    + "and Lasku.laskunnumero = Suorite.lasku\n" + "and Suorite.tilaaja = T.asiakasnumero\n"
                    + "and Suorite.tilaajanVersio = T.versio\n"
                    + "and Suorite.vastaanottaja = V.asiakasnumero\n"
                    + "and Suorite.vastaanottajanVersio = V.versio\n" + "");
    rs.first();
    table1.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin()));
    table1.setLockedWidth(true);
    table1.setWidths(new int[] { 370, 100, 73, 100, 73, 100, 179 });
    PdfPCell cell;
    Paragraph p;

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph(rs.getString(1), f4);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("LASKU", f4);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    table1.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(7);
    p = new Paragraph(rs.getString(2), f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    table1.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph(rs.getString(3) + " " + rs.getString(4), f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("Pivys", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph(pvmFormaatti1.format(pvmFormaatti3.parse(rs.getTimestamp(5).toString())), f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    table1.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("Laskun numero", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph(laskunNumero, f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    table1.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph("Alv-tunniste: " + rs.getString(6), f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("Erpiv", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph(pvmFormaatti1.format(pvmFormaatti4.parse(rs.getDate(7).toString())), f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    table1.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("Viivstyskorko", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph(Integer.toString(rs.getInt(8)) + ".0%", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    table1.addCell(cell);

    table1.completeRow();

    //Jos vastaanottaja on sama kuin tilaaja ei laiteta erikseen vastaanottajan tietoja nkyville.
    if (rs.getInt(25) == rs.getInt(26)) {
        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(10), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Viitenumero", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(9), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(12), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Maksuehto", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(11), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(14) + " " + rs.getString(15), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Pankki", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(13), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(17), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Tilinumero", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(16), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Swift/BIC", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(18), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(" ", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph("Listiedot", f2);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(24), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(" ", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        document.add(table1);
    } else {
        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph("Palvelun tilaaja", f2);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Viitenumero", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(9), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(10), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Maksuehto", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(11), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(12), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Pankki", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(13), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(14) + " " + rs.getString(15), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Tilinumero", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(16), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(3);
        p = new Paragraph(rs.getString(17), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph("Swift/BIC", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(2);
        p = new Paragraph(rs.getString(18), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph("Palvelun vastaanottaja", f2);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(19), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(20), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(21) + " " + rs.getString(22), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(23), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph("Listiedot", f2);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(rs.getString(24), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(7);
        p = new Paragraph(" ", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table1.addCell(cell);

        table1.completeRow();

        document.add(table1);
    }

    // Otetaan alemmas tulevia tietoja talteen.
    String[] alasTulevatTiedot = new String[] { rs.getString(9), rs.getString(1), rs.getString(27),
            rs.getString(13), rs.getString(2), rs.getString(28), rs.getString(16),
            rs.getString(3) + " " + rs.getString(4), rs.getString(29), rs.getString(18), rs.getString(30), };

    //Muodostetaan suoritteiden taulukko.
    PdfPTable table2 = new PdfPTable(7);
    table2.setWidths(new int[] { 370, 100, 73, 100, 73, 100, 179 });
    table2.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin()));
    table2.setLockedWidth(true);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Kuvaus", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Mr", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Yks.", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(" hinta", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Alv %", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Alv ", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph("Yhteens", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorder(LEFT + BOTTOM + RIGHT + TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    table2.completeRow();

    rs = lataaja.getDbc().executeQuery(
            "select distinct kuvaus, maara, maaranYksikot, aHintaVeroton, alvProsentti, ((alvProsentti / 100.0) * aHintaVeroton * maara) as alvEuroa,\n"
                    + "((1.0 + alvProsentti / 100.0) * aHintaVeroton * maara) as yht, alkuaika\n"
                    + "from Suorite\n" + "where lasku = " + laskunNumero + "\n" + "");

    while (rs.next()) {
        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getString(1) + " "
                + pvmFormaatti1.format(pvmFormaatti3.parse(rs.getTimestamp(8).toString())), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_LEFT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getBigDecimal(2, 2).toString(), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getString(3), f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getBigDecimal(4, 2).toString() + "", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getString(5) + "%", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getBigDecimal(6, 2).toString() + "", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_CENTER);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setColspan(1);
        p = new Paragraph(rs.getBigDecimal(7, 2).toString() + "", f1);
        p.setLeading(0, 1);
        p.setAlignment(Element.ALIGN_RIGHT);
        cell.addElement(p);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBorder(LEFT + RIGHT);
        cell.setBorderColor(BaseColor.BLACK);
        cell.setBorderWidth(0.2f);
        table2.addCell(cell);

        table2.completeRow();
    }

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(7);
    p = new Paragraph(" ", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(TOP);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table2.addCell(cell);

    table2.completeRow();

    rs = lataaja.getDbc().executeQuery(
            "select distinct sum(aHintaVeroton * maara), sum((alvProsentti / 100.0) * aHintaVeroton * maara)\n"
                    + "from Suorite\n" + "where lasku = " + laskunNumero + "\n" + "");

    rs.first();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph("Veroton hinta yhteens", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(rs.getBigDecimal(1, 2).toString() + "", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    table2.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph("Arvonlisvero yhteens", f2);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(rs.getBigDecimal(2, 2).toString() + "", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    table2.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(7);
    p = new Paragraph(" ", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    table2.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(4);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    p = new Paragraph("Yhteens", f3);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    rs = lataaja.getDbc()
            .executeQuery("select laskunSumma\n" + "from Lasku, Pankkiviivakoodi\n" + "where laskunNumero = "
                    + laskunNumero + "\n" + "and Lasku.pankkiviivakoodi = Pankkiviivakoodi.pankkiviivakoodi\n"
                    + "");

    rs.first();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(rs.getBigDecimal(1, 2).toString() + "", f3);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table2.addCell(cell);

    table2.completeRow();

    document.add(table2);

    PdfPTable table3 = new PdfPTable(3);
    table3.setWidths(new int[] { 1, 1, 1 });
    table3.setTotalWidth(document.right(document.rightMargin()) - document.left(document.leftMargin()));
    table3.setLockedWidth(true);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph("Pyydmme kyttmn maksaessanne viitenumeroa: " + alasTulevatTiedot[0], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph(" ", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBorder(BOTTOM);
    cell.setBorderColor(BaseColor.BLACK);
    cell.setBorderWidth(0.2f);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[1], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[2], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[3], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[4], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[5], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[6], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[7], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[8], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(1);
    p = new Paragraph(alasTulevatTiedot[9], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph(" ", f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_RIGHT);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    cell = new PdfPCell();
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(3);
    p = new Paragraph("Virtuaaliviivakoodi: " + alasTulevatTiedot[10], f1);
    p.setLeading(0, 1);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.addElement(p);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table3.addCell(cell);

    table3.completeRow();

    table3.writeSelectedRows(0, -1, document.left(document.leftMargin()),
            table3.getTotalHeight() + document.bottom(document.bottomMargin()), writer.getDirectContent());
    //----------------------------------------------------------------------
    document.close();

}

From source file:support.plus.reportit.export.export_pdf_class.java

License:Open Source License

public PdfPTable createFirstTable(String filenumber, String filetag, String startdate, String enddate,
        String TextUserNameString, String TextUserNameBossString, String mondayText1, String mondayText2,
        String mondayText3, String mondayText4, String mondayText5, String mondayText6, String tuesdayText1,
        String tuesdayText2, String tuesdayText3, String tuesdayText4, String tuesdayText5, String tuesdayText6,
        String wednesdayText1, String wednesdayText2, String wednesdayText3, String wednesdayText4,
        String wednesdayText5, String wednesdayText6, String thursdayText1, String thursdayText2,
        String thursdayText3, String thursdayText4, String thursdayText5, String thursdayText6,
        String fridayText1, String fridayText2, String fridayText3, String fridayText4, String fridayText5,
        String fridayText6, String mondayTextTime1, String mondayTextTime2, String mondayTextTime3,
        String mondayTextTime4, String mondayTextTime5, String mondayTextTime6, String tuesdayTextTime1,
        String tuesdayTextTime2, String tuesdayTextTime3, String tuesdayTextTime4, String tuesdayTextTime5,
        String tuesdayTextTime6, String wednesdayTextTime1, String wednesdayTextTime2,
        String wednesdayTextTime3, String wednesdayTextTime4, String wednesdayTextTime5,
        String wednesdayTextTime6, String thursdayTextTime1, String thursdayTextTime2, String thursdayTextTime3,
        String thursdayTextTime4, String thursdayTextTime5, String thursdayTextTime6, String fridayTextTime1,
        String fridayTextTime2, String fridayTextTime3, String fridayTextTime4, String fridayTextTime5,
        String fridayTextTime6) {

    String mon = String.valueOf(context.getResources().getText(R.string.monday_short));
    String tues = String.valueOf(context.getResources().getText(R.string.tuesday_short));
    String wed = String.valueOf(context.getResources().getText(R.string.wednesday_short));
    String thurs = String.valueOf(context.getResources().getText(R.string.thursday_short));
    String fri = String.valueOf(context.getResources().getText(R.string.friday_short));
    String hours = String.valueOf(context.getResources().getText(R.string.hours));
    String day = String.valueOf(context.getResources().getText(R.string.day));
    String reportNr = String.valueOf(context.getResources().getText(R.string.report_nr));
    String weekFrom = String.valueOf(context.getResources().getText(R.string.weekFrom));
    String weekTo = String.valueOf(context.getResources().getText(R.string.weekTo));
    String firmName = String.valueOf(context.getResources().getText(R.string.firmName));
    String instructorName = String.valueOf(context.getResources().getText(R.string.instructorName));

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(450 / 5.23f);
    try {// w  w w  .j  ava 2 s. c om
        table.setWidths(new int[] { 1, 9, 1 });
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    PdfPCell cell;

    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);

    cell = new PdfPCell(
            new Phrase(reportNr + " " + filenumber + "                                                "
                    + weekFrom + "   " + startdate + "   " + weekTo + "   " + enddate, fontbold));
    cell.setColspan(3);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(firmName + "   " + TextUserNameString + "                          "
            + instructorName + " " + TextUserNameBossString));
    cell.setColspan(3);
    table.addCell(cell);

    table.addCell(day);
    cell = new PdfPCell(new Phrase(filetag));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(hours);

    table.addCell(mon);
    cell = new PdfPCell(new Phrase(mondayText1));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime1);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(mondayText2));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime2);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(mondayText3));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime3);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(mondayText4));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime4);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(mondayText5));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime5);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(mondayText6));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(mondayTextTime6);

    table.addCell(tues);
    cell = new PdfPCell(new Phrase(tuesdayText1));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime1);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(tuesdayText2));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime2);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(tuesdayText3));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime3);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(tuesdayText4));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime4);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(tuesdayText5));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime5);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(tuesdayText6));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(tuesdayTextTime6);

    table.addCell(wed);
    cell = new PdfPCell(new Phrase(wednesdayText1));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime1);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(wednesdayText2));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime2);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(wednesdayText3));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime3);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(wednesdayText4));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime4);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(wednesdayText5));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime5);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(wednesdayText6));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(wednesdayTextTime6);

    table.addCell(thurs);
    cell = new PdfPCell(new Phrase(thursdayText1));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime1);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(thursdayText2));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime2);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(thursdayText3));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime3);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(thursdayText4));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime4);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(thursdayText5));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime5);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(thursdayText6));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(thursdayTextTime6);

    table.addCell(fri);
    cell = new PdfPCell(new Phrase(fridayText1));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime1);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(fridayText2));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime2);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(fridayText3));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime3);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(fridayText4));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime4);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(fridayText5));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime5);

    table.addCell(" ");
    cell = new PdfPCell(new Phrase(fridayText6));
    cell.setColspan(1);
    table.addCell(cell);
    table.addCell(fridayTextTime6);

    createSecondTable();
    return table;
}

From source file:support.plus.reportit.export.export_pdf_class.java

License:Open Source License

public PdfPTable createSecondTable() {
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(450 / 5.23f);
    try {//from w ww. j av  a 2 s .  c  o m
        table.setWidths(new int[] { 1, 9, 1 });
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    PdfPCell cell;

    String signatures = String.valueOf(context.getResources().getText(R.string.signatures));
    String trainee = String.valueOf(context.getResources().getText(R.string.trainee_only));
    String instructor = String.valueOf(context.getResources().getText(R.string.instructor_only));
    String deputy = String.valueOf(context.getResources().getText(R.string.desputy));
    String notes = String.valueOf(context.getResources().getText(R.string.notes));

    cell = new PdfPCell(new Phrase("\n\n  " + signatures + "\n"
            + "                                __________          __________          __________          __________"
            + "\n                                    " + trainee + "                   " + instructor
            + "               " + deputy + "                   " + notes));
    cell.setColspan(3);
    table.addCell(cell);

    return table;
}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createLAOTable(Section subCatPart, String clientId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Loan Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);// w  w w.j a  va2  s.  c  o m

    c1 = new PdfPCell(new Phrase("Loan Code"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Approved Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("OutStd Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Start Date"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    ArrayList<OpenMFLoanAccount> loanAccounts = OMFUtils.getLoanAccountsByClientList(clientId);
    //ArrayList<OpenMFSavingsAccount> savingsAccounts = OMFUtils.getSavingsAccountsByClientList(clientId);
    for (OpenMFLoanAccount openMFLoanAccount : loanAccounts) {
        table.addCell(openMFLoanAccount.getLoanaccountnumber());
        table.addCell(openMFLoanAccount.getLoancode());
        table.addCell(openMFLoanAccount.getApprovedamount());
        table.addCell(openMFLoanAccount.getBalanceoutstandingamount());
        table.addCell(openMFLoanAccount.getLoanstartdate());
    }

    subCatPart.add(table);

}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createSAOTable(Section subCatPart, String clientId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    PdfPCell c1 = new PdfPCell(new Phrase("Savings Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);//from  w w  w . j a va2 s .  com

    c1 = new PdfPCell(new Phrase("Savings Code"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Available Balance"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Total# Deposits"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Matures On"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    ArrayList<OpenMFSavingsAccount> savingsAccounts = OMFUtils.getSavingsAccountsByClientList(clientId);
    for (OpenMFSavingsAccount openMFSavingsAccount : savingsAccounts) {
        table.addCell(openMFSavingsAccount.getSavingsaccountnumber());
        table.addCell(openMFSavingsAccount.getSavingscode());
        table.addCell(openMFSavingsAccount.getAvailablebalance());
        table.addCell(openMFSavingsAccount.getTotalnumdeposits());
        table.addCell(openMFSavingsAccount.getMatureson());
    }

    subCatPart.add(table);

}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createTasksTable(Section subCatPart, String omfuId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    PdfPCell c1 = new PdfPCell(new Phrase("Task#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/*from   w w  w .  ja  v a2s .c o m*/

    c1 = new PdfPCell(new Phrase("Date Assigned"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Type"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    OpenMFUser omfuser = null;
    if (omfuId != null) {
        omfuser = AppContext.getAppContext().getUserManager().getUser(ServletUtils.validateEventId(omfuId));
    }

    ArrayList<OpenMFTask> tasks = OMFUtils.getTasksByUsername(omfuser.getUsername(), false);
    for (OpenMFTask task : tasks) {
        table.addCell(task.getTaskId());
        table.addCell(task.getDateassigned());
        table.addCell(task.getAmount());
        table.addCell(task.getAccountnumber());
        table.addCell(task.getCollectiontype());
    }

    subCatPart.add(table);

}

From source file:utilities.itext.Turnover.java

private static Paragraph createTablesWithoutDetails(HashMap<String, BigDecimal> expenseData)
        throws DocumentException {
    Paragraph paragraph = new Paragraph();

    PdfPTable expense = new PdfPTable(2);
    float[] colWidths = { 1f, 3f };
    expense.setWidths(colWidths);

    for (String cat : expenseData.keySet()) {
        Paragraph contentCell1 = new Paragraph(cat);
        PdfPCell cell1 = new PdfPCell(contentCell1);

        Paragraph contentCell2 = new Paragraph(formatter.format(expenseData.get(cat)));
        PdfPCell cell2 = new PdfPCell(contentCell2);
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);

        cell1.setPaddingBottom(4f);/*from   w w w  .  j a va 2  s .co m*/
        cell2.setPaddingBottom(4f);

        expense.addCell(cell1);
        expense.addCell(cell2);
    }

    paragraph.add(expense);
    return paragraph;
}