Example usage for com.itextpdf.text Document left

List of usage examples for com.itextpdf.text Document left

Introduction

In this page you can find the example usage for com.itextpdf.text Document left.

Prototype


public float left(float margin) 

Source Link

Document

Returns the lower left x-coordinate considering a given margin.

Usage

From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java

License:Apache License

private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();/*  w ww .ja  v  a 2s. c  om*/
    BscReportSupportUtils.loadExpression(); // 2015-04-18 add
    String visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = UUID.randomUUID().toString() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    //Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    Document document = new Document(PageSize.A4, 10, 10, 10, 10);
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();

    int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0)
            .getDateRangeScores().size();
    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    PdfPTable dateRangeTable = new PdfPTable(dateRangeRows);
    PdfPTable chartsTable = new PdfPTable(2);
    PdfPTable signTable = new PdfPTable(1);
    table.setWidthPercentage(100f);
    dateRangeTable.setWidthPercentage(100f);
    chartsTable.setWidthPercentage(100f);
    signTable.setWidthPercentage(100f);

    this.createHead(table, vision);
    this.createBody(table, vision);
    this.createDateRange(dateRangeTable, vision, context, dateRangeRows);
    this.putCharts(chartsTable, context);
    this.putSignature(signTable, context);

    document.add(chartsTable);
    document.add(table);
    document.add(dateRangeTable);
    document.add(signTable);
    document.close();
    writer.close();

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file,
            "kpi-report.pdf");
    file = null;
    return oid;
}

From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java

License:Apache License

private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();/*from   w  ww .j  a va2  s  .c o m*/
    String visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = UUID.randomUUID().toString() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();

    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    table.setWidthPercentage(100f);
    PdfPTable signTable = new PdfPTable(1);
    signTable.setWidthPercentage(100f);

    this.createHead(table, vision, context);
    this.createBody(table, vision);

    this.putSignature(signTable, context);

    document.add(table);
    document.add(signTable);
    document.close();
    writer.close();

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file,
            "department-report.pdf");
    file = null;
    return oid;
}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java

License:Apache License

private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();//from  w ww  .  ja  v  a 2  s. c  o m
    String visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = UUID.randomUUID().toString() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();

    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    table.setWidthPercentage(100f);
    PdfPTable signTable = new PdfPTable(1);
    signTable.setWidthPercentage(100f);

    this.createHead(table, vision, context);
    this.createBody(table, vision);
    this.createFoot(table, context);
    this.putSignature(signTable, context);

    document.add(table);
    document.add(signTable);
    document.close();
    writer.close();

    os.flush();
    os.close();
    os = null;

    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file,
            "personal-report.pdf");
    file = null;
    return oid;
}

From source file:superlaskuttaja.logiikka.PdfExtractor.java

private void muodostaDokumentti(Document document, String laskunNumero, PdfWriter writer)
        throws DocumentException, SQLException, ParseException {
    document.open();/*from ww  w  . j a  v a 2 s  . co  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();

}