Example usage for com.itextpdf.text Paragraph setLeading

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

Introduction

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

Prototype

public void setLeading(final float fixedLeading, final float multipliedLeading) 

Source Link

Document

Sets the leading fixed and variable.

Usage

From source file:fxml.test.PDFService.java

public PdfPTable createFooter1() {

    //String[] names = new String[]{"Md. Eamin Rahman", "Md. Mujibur Rahman", "Md Masum", "Md. Saiful Islam", "Husne Ara Chowdhury", "Sabir Ismail"};
    PdfPTable table = new PdfPTable(5);
    table.setHorizontalAlignment(Element.ALIGN_LEFT);

    try {/*from   w w w  . j av a2s.co m*/
        table.setTotalWidth(new float[] { 161f, 161f, 133f, 167f, 161f });
        table.setLockedWidth(true);

    } catch (DocumentException ex) {
        Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex);
    }
    //table.setWidthPercentage(100);
    PdfPCell chairmanSIgnature = new PdfPCell(new Paragraph("Signature of the Chairman:", font9));
    chairmanSIgnature.setBorder(Rectangle.NO_BORDER);
    chairmanSIgnature.setPaddingLeft(0f);
    chairmanSIgnature.setPaddingTop(5);
    table.addCell(chairmanSIgnature);

    PdfPCell underLine = new PdfPCell(new Paragraph("_______________________"));
    underLine.setBorder(Rectangle.NO_BORDER);
    table.addCell(underLine);

    PdfPCell blankColumn = new PdfPCell(new Paragraph(" "));
    blankColumn.setBorder(Rectangle.NO_BORDER);
    table.addCell(blankColumn);

    Paragraph p = new Paragraph("Signature of The Controller of Examinations:", font9);
    p.setLeading(0, 1.3f);
    PdfPCell controllerSignature = new PdfPCell();
    controllerSignature.addElement(p);
    controllerSignature.setBorder(Rectangle.NO_BORDER);
    table.addCell(controllerSignature);
    table.addCell(underLine);

    PdfPCell cell1 = new PdfPCell(new Paragraph(inputs.get(5).trim(), font9));
    cell1.setPaddingTop(0f);
    cell1.setBorder(Rectangle.NO_BORDER);

    PdfPCell cell2 = new PdfPCell(new Paragraph(inputs.get(6).trim(), font9));
    cell2.setPaddingTop(0f);
    cell2.setBorder(Rectangle.NO_BORDER);

    PdfPCell nameColumn = new PdfPCell(new Paragraph("Name :", font9));
    nameColumn.setBorder(Rectangle.NO_BORDER);
    nameColumn.setPaddingLeft(0f);
    nameColumn.setPaddingTop(0f);

    PdfPCell nameColumn2 = new PdfPCell(new Paragraph("Name :", font9));
    nameColumn2.setBorder(Rectangle.NO_BORDER);
    nameColumn2.setPaddingTop(0f);

    table.addCell(nameColumn);
    table.addCell(cell1);
    table.addCell(blankColumn);
    table.addCell(nameColumn2);
    table.addCell(cell2);

    table.setSpacingAfter(23.5f);
    return table;
}

From source file:IAS.Class.BackIssueLabels.java

public Paragraph prepareBILLabelPDFContent(subInfo sLabelInfo, String bilLabel) {
    Paragraph info = null;

    info = new Paragraph();
    info.setLeading(lfixedLeading, lmultipliedLeadingPlus);
    info.setAlignment(textAlignment);/*from  ww w . jav  a  2 s. c  om*/

    Font font;
    font = new Font(sfontType, sfontSizeHeader - 1, sfontStyle, BaseColor.BLACK);
    if (!bilLabel.isEmpty() && !sLabelInfo.getsubscriberNumber().isEmpty()) {
        String header = sLabelInfo.getsubscriberNumber() + " " + bilLabel;
        info.add(new Chunk(header, font));
        info.add(Chunk.NEWLINE);
    }

    font = new Font(sfontType, sfontSize, sfontStyle, BaseColor.BLACK);
    String firstLine = sLabelInfo.getsubscriberName();
    // + " " + sLabelInfo.getjournalCode();

    //if(!noHeader){

    //if(sLabelInfo.getcopies() > 1){
    //    firstLine = firstLine + " " + sLabelInfo.getcopies();
    //}

    //firstLine = firstLine + " " + sLabelInfo.getsubtypecode();

    //if(sLabelInfo.equals("Paid")) {
    //    firstLine = firstLine + " " + sLabelInfo.getstartDate()+
    //        " " + "to" +
    //        " " + sLabelInfo.getendDate();
    //}
    if (!firstLine.isEmpty()) {
        info.add(new Chunk(firstLine, font));
        info.add(Chunk.NEWLINE);
    }
    //}

    //info.add(new Chunk(sLabelInfo.getsubscriberName(), font));
    //info.add(Chunk.NEWLINE);
    if (!sLabelInfo.getdepartment().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getdepartment(), font));
        info.add(Chunk.NEWLINE);
    }
    if (!sLabelInfo.getinstitution().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getinstitution(), font));
        info.add(Chunk.NEWLINE);
    }

    if (!sLabelInfo.getaddress().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getaddress(), font));
        info.add(Chunk.NEWLINE);
    }
    font = new Font(sfontType, sfontSize, Font.BOLD);
    /*
    String lastLine = sLabelInfo.getcity() +
        " " + sLabelInfo.getpincode() +
        " " + sLabelInfo.getstate() +
        " ";
    if(!sLabelInfo.getcountry().equals("India")){
    lastLine = lastLine + sLabelInfo.getcountry();
    }
    */

    String lastLine = "";
    if (!sLabelInfo.getcity().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getcity();
    }
    if (sLabelInfo.getcity().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getpincode();
    } else {
        lastLine = lastLine + " " + sLabelInfo.getpincode();
    }
    if (sLabelInfo.getpincode().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getstate();
    } else {
        lastLine = lastLine + " " + sLabelInfo.getstate();
    }

    String country = "";
    if (!sLabelInfo.getcountry().equals("India")) {
        country = sLabelInfo.getcountry();
    }

    if (sLabelInfo.getstate().isEmpty()) {
        lastLine = lastLine + country;
    } else {
        lastLine = lastLine + " " + country;
    }

    if (!lastLine.isEmpty()) {
        lastLine = lastLine.trim();
        // Remove the leading spaces
        //lastLine.replaceAll("^\\s+", "");
        info.add(new Chunk(lastLine, font));
    }

    return info;

}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addFooter(LebData lebData, PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    int footerMargin = 0;
    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerMargin = bottomMargin + 85;
    } else {/*from w ww  . java 2s.c  om*/
        footerMargin = bottomMargin + 170;
    }
    alertLonelyFooter(writer, footerMargin);
    while (writer.getVerticalPosition(false) > (footerMargin + 20)) {
        document.add(Chunk.NEWLINE);
    }
    float footerBegin = writer.getVerticalPosition(false);
    Paragraph footerTopParagraph = new Paragraph();
    footerTopParagraph.setLeading(1, 0.4f);
    footerTopParagraph.add(Chunk.NEWLINE);
    footerTopParagraph.add(Chunk.NEWLINE);

    Paragraph footerBottompParagraph = new Paragraph();
    footerBottompParagraph.setLeading(1, 0.4f);

    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerTopParagraph
                .add(PdfFormatHelper.buildFooterHalbjahrDatumLine(lebData.getDatumString(), footerFont));
        footerTopParagraph.add(PdfFormatHelper.buildFooterHalbjahrDatumKlassenleiterLine(footerFont));
    } else {
        footerTopParagraph.add(
                PdfFormatHelper.buildFooterVersetzungsvermerkLine(lebData.getVersetzungsvermerk(), footerFont));
        footerTopParagraph.add(Chunk.NEWLINE);
        footerTopParagraph.add(PdfFormatHelper.buildFooterDatumLine(lebData.getDatumString(), footerFont));
        document.add(footerTopParagraph);
        while (writer.getVerticalPosition(false) > (footerBegin - 82)) {
            document.add(Chunk.NEWLINE);
        }
        footerBottompParagraph.add(PdfFormatHelper.buildFooterDienstsiegelLine(footerFont));
        footerBottompParagraph.add(Chunk.NEWLINE);
        footerBottompParagraph.add(PdfFormatHelper.buildFooterUnterschriftenLine(footerFont));
    }
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(PdfFormatHelper.buildFooterKenntnisLine(footerFont));
    document.add(footerBottompParagraph);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addContent(PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    Anchor anchor = new Anchor("Lernentwicklungsbericht", lernentwicklungsberichtUeberschriftFont);
    Chapter chapterLEB = new Chapter(new Paragraph(anchor), 1);
    chapterLEB.setNumberDepth(0);/*from   w w  w  .j  a  v  a  2  s  . co m*/
    Paragraph paragraphHeader = new Paragraph();
    paragraphHeader.setLeading(FIXED_LEADING_TEXT, 1);
    sectionCount += 1;
    Section headerSection = chapterLEB.addSection(paragraphHeader);
    headerSection.setNumberDepth(0);

    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderNameLine(lebData.getSchuelername(), headerFont));
    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderKlassendatenLine(lebData, headerFont));
    headerSection.add(Chunk.NEWLINE);
    headerSection.add(Chunk.NEWLINE);
    document.add(chapterLEB);
    insertDummyLineIfNecessary(writer);

    addKlassenbrief(chapterLEB, writer);
    addIndividuelleEinschaetzung(chapterLEB, writer);
    addFacheinschaetzungen(chapterLEB, writer);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addFacheinschaetzungen(Chapter chapterLEB, PdfWriter writer)
        throws DocumentException, PdfFormatierungsException {
    for (LebFacheinschaetzungData facheinschaetzungsdaten : lebData.getFacheinschaetzungsdaten()) {
        sectionCount += 1;//w ww. ja  v  a 2s . c  o  m
        breakHurenkind(writer);
        breakSchusterjunge(writer);
        Paragraph paragraphFacheinschaetzung = new Paragraph();
        Section facheinschaetzungsTextSection = chapterLEB.addSection(paragraphFacheinschaetzung);
        facheinschaetzungsTextSection.setNumberDepth(0);
        Collection<String> fachbezeichnungen = facheinschaetzungsdaten.getFachbezeichnungen();
        fachbezeichnungen.add(facheinschaetzungsdaten.getFachname());

        String facheinschaetzung = facheinschaetzungsdaten.getFacheinschaetzung();

        Integer firstIndex = null;
        String boldedWord = "";
        for (String fachbezeichnung : fachbezeichnungen) {
            int index = facheinschaetzung.toLowerCase().indexOf(fachbezeichnung.toLowerCase());
            if (index != -1 && (firstIndex == null || firstIndex > index)) {
                firstIndex = index;
                boldedWord = fachbezeichnung;
            }
        }
        Paragraph facheinschaetzungParapgraph = new Paragraph();
        facheinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        facheinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        if (firstIndex == null) {
            facheinschaetzungParapgraph.add(new Phrase(
                    facheinschaetzungsdaten.getFacheinschaetzung().replace('\t', '\0'), standardTextFont));
        } else {
            String beforeBoldWord = facheinschaetzung.substring(0, firstIndex);
            facheinschaetzungParapgraph.add(new Phrase(beforeBoldWord.replace('\t', '\0'), standardTextFont));

            String boldWord = facheinschaetzung.substring(firstIndex, firstIndex + boldedWord.length());
            facheinschaetzungParapgraph.add(new Phrase(boldWord, standardTextBoldFont));

            String afterBoldWord = facheinschaetzung.substring(firstIndex + boldedWord.length());
            facheinschaetzungParapgraph.add(new Phrase(afterBoldWord.replace('\t', '\0'), standardTextFont));
        }
        facheinschaetzungParapgraph.setFont(standardTextFont);
        facheinschaetzungsTextSection.add(facheinschaetzungParapgraph);
        Paragraph unterschriftParagraph = new Paragraph();
        document.add(facheinschaetzungsTextSection);
        Section facheinschaetzungsUnterschriftSection = chapterLEB.addSection(unterschriftParagraph);
        facheinschaetzungsUnterschriftSection.setNumberDepth(0);
        unterschriftParagraph.add(
                new Phrase(facheinschaetzungsdaten.getUnterschrift().replace('\t', '\0'), standardTextFont));
        unterschriftParagraph.setAlignment(Element.ALIGN_RIGHT);
        unterschriftParagraph.add(Chunk.NEWLINE);
        unterschriftParagraph.add(Chunk.NEWLINE);
        document.add(facheinschaetzungsUnterschriftSection);
        alertHurenkind(writer);
        insertDummyLineIfNecessary(writer);
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addIndividuelleEinschaetzung(Chapter chapterLEB, PdfWriter writer)
        throws DocumentException, PdfFormatierungsException {
    if (!lebData.getIndividuelleEinschaetzung().isEmpty()) {
        sectionCount += 1;/*from ww  w.  j a  va  2s .com*/
        breakHurenkind(writer);
        breakSchusterjunge(writer);
        Paragraph paragraphIndividuelleEinschaetzung = new Paragraph();
        Section individuelleEinschaetzungsTextSection = chapterLEB
                .addSection(paragraphIndividuelleEinschaetzung);
        individuelleEinschaetzungsTextSection.setNumberDepth(0);
        Paragraph schuelereinschaetzungParapgraph = new Paragraph(
                lebData.getIndividuelleEinschaetzung().replace('\t', '\0'), standardTextFont);
        schuelereinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        schuelereinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        individuelleEinschaetzungsTextSection.add(schuelereinschaetzungParapgraph);
        document.add(individuelleEinschaetzungsTextSection);
        document.add(getKlassenlehrerunterschrift(chapterLEB));
        alertHurenkind(writer);
        insertDummyLineIfNecessary(writer);
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addKlassenbrief(Chapter chapterLEB, PdfWriter writer)
        throws DocumentException, PdfFormatierungsException {
    if (!lebData.getKlassenbrief().isEmpty()) {
        sectionCount += 1;// w w  w  .  ja  v  a2 s  . com
        breakSchusterjunge(writer);
        Paragraph paragraphKlassenbrief = new Paragraph();
        Section klassenbriefSection = chapterLEB.addSection(paragraphKlassenbrief);
        klassenbriefSection.setNumberDepth(0);
        Paragraph klasseneinschaetzungParapgraph = new Paragraph(lebData.getKlassenbrief().replace('\t', '\0'),
                standardTextFont);
        klasseneinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        klasseneinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
        if (lebData.getIndividuelleEinschaetzung().isEmpty()) {
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
            document.add(getKlassenlehrerunterschrift(chapterLEB));
        } else {
            klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
        }
        alertLonelyHeader(writer);
        insertDummyLineIfNecessary(writer);
    }
}

From source file:py.com.palermo.imprimeetiquetas.web.ProductoController.java

public String createPdf() throws IOException, DocumentException {

    if (hayParaImprimir()) {

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();
        response.setContentType("application/x-pdf");
        response.setHeader("Content-Disposition", "attachment; filename=\"etiquetas.pdf\"");

        // step 1
        Document document = new Document(new Rectangle(86, 35));
        // step 2

        document.setMargins(0f, 0f, 0f, 0f);

        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
        // step 3
        document.open();//w ww.jav  a2s  .c  o m

        // step 4
        PdfContentByte cb = writer.getDirectContent();

        for (ProductoCantidad p : productos) {
            if (p.getCantidad() > 0) {

                BarcodeEAN codeEAN = new BarcodeEAN();
                codeEAN.setCode(p.getCodigo());
                codeEAN.setCodeType(Barcode.EAN13);
                codeEAN.setBarHeight(10f);
                codeEAN.setX(0.7f);
                codeEAN.setSize(4f);

                NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("es", "py"));
                Font fontbold = FontFactory.getFont("Times-Roman", 5, Font.NORMAL);
                Chunk productTitle = new Chunk(p.getNombre() + "," + " " + nf.format(p.getPrecio()), fontbold);

                // EAN 13
                Paragraph pTitile = new Paragraph(productTitle);
                pTitile.setAlignment(Element.ALIGN_CENTER);
                pTitile.setLeading(0, 1);

                PdfPTable table = new PdfPTable(1);
                table.setPaddingTop(0f);

                table.setWidthPercentage(96);
                PdfPCell cell = new PdfPCell();
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setBorder(Rectangle.NO_BORDER);
                cell.addElement(codeEAN.createImageWithBarcode(cb, null, BaseColor.BLACK));

                table.addCell(cell);

                PdfPCell cell2 = new PdfPCell();
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setBorder(Rectangle.NO_BORDER);
                cell2.addElement(pTitile);

                table.addCell(cell2);

                for (int i = 0; i < p.getCantidad(); i++) {
                    document.add(table);
                    document.newPage();
                }
            }
        }

        // step 5
        document.close();

        response.getOutputStream().flush();
        response.getOutputStream().close();
        FacesContext.getCurrentInstance().responseComplete();
    } else {
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, "No hay nada que imprimir", ""));
    }
    return null;
}

From source file:server.kartu.tik.iText.java

public String createPDF(String tanggal, ArrayList kegiatan, String divisi) {
    ArrayList<Kegiatan> list = new ArrayList<>(kegiatan);

    String output = System.getProperty("user.dir") + "\\src\\data\\pdf\\" + tanggal + " " + getNamalengkap()
            + "-" + getTglnoktp() + ".pdf";

    String namaDivisi = "";
    switch (divisi) {
    case "1":
        namaDivisi = "Ekonomi";
        break;/*  ww w.  j  a v  a2  s. c o  m*/
    case "2":
        namaDivisi = "Politik";
        break;
    case "3":
        namaDivisi = "Sosial Budaya";
        break;
    case "4":
        namaDivisi = "Keamanan";
        break;
    }

    Document document = new Document(PageSize.A4);
    try {
        PdfWriter.getInstance(document, new FileOutputStream(output));

        document.open();

        //------------------------------------------------------------------------------------- TITLE
        PdfPTable title = new PdfPTable(1);
        title.setWidthPercentage(100);
        Font f = new Font(FontFamily.HELVETICA, 14, Font.NORMAL, GrayColor.GRAYWHITE);
        PdfPCell celltitle = new PdfPCell(new Phrase("KARTU TIK (" + namaDivisi + ")", f));
        celltitle.setMinimumHeight(20);
        celltitle.setBackgroundColor(GrayColor.GRAYBLACK);
        celltitle.setHorizontalAlignment(Element.ALIGN_CENTER);
        celltitle.setColspan(3);
        title.addCell(celltitle);
        document.add(title);
        //-------------------------------------------------------------------------------------- END

        //------------------------------------------------------------------------------------- NAMA + ALIAS
        float[] columnWidths = { 8, 2 };
        PdfPTable tabel1 = new PdfPTable(columnWidths);
        tabel1.setWidthPercentage(100);

        PdfPTable innerTable1 = new PdfPTable(1);
        innerTable1.setWidthPercentage(100);
        PdfPTable innerTable2 = new PdfPTable(1);
        innerTable2.setWidthPercentage(100);
        PdfPCell cell;
        innerTable1.addCell(
                "1.  a. Nama Lengkap : " + getNamalengkap() + " \n\n     b. Alias : " + getAlias() + " \n\n");
        innerTable1.addCell("2.  Kebangsaan \n     a. Tgl. No. KTP : " + getTglnoktp()
                + " \n\n     b. Tgl. No. Pasport : " + getTglnopasport() + "\n\n");
        innerTable1.addCell("3.  Agama : " + getAgama());
        cell = new PdfPCell(innerTable1);
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        if (getUrlfoto().equalsIgnoreCase("") || getUrlfoto().isEmpty() || getUrlfoto() == null) {

        } else {
            Image image = Image.getInstance(getUrlfoto());
            cell = new PdfPCell(image, false);
            if (image.getWidth() < 90) {
                cell.setPaddingLeft(8);
            } else {
                cell.setPaddingLeft(3);
            }
        }
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        cell = new PdfPCell();
        cell.setColspan(14);
        tabel1.addCell(cell);

        document.add(tabel1);
        //------------------------------------------------------------------------------------- NAMA + ALIAS END

        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT
        PdfPTable tabel4 = new PdfPTable(1);
        tabel4.setWidthPercentage(100);

        Paragraph pTglLahirnTempat = new Paragraph();
        pTglLahirnTempat.add("4.  a. Tgl. Lahir/ Umur : " + getTgllahir());
        pTglLahirnTempat.add("\n\n     b. Tempat Lahir     : " + getTempatlahir());
        pTglLahirnTempat.setLeading(0, 1);

        PdfPCell cTglLahirnTempat = new PdfPCell();
        cTglLahirnTempat.setMinimumHeight(45);
        cTglLahirnTempat.addElement(pTglLahirnTempat);
        tabel4.addCell(cTglLahirnTempat);

        document.add(tabel4);
        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT END

        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN
        PdfPTable tabel5 = new PdfPTable(1);
        tabel5.setWidthPercentage(100);

        Paragraph pAlamat = new Paragraph();
        pAlamat.add("5.  Alamat : ");
        pAlamat.add(alamat);
        pAlamat.setLeading(0, 1);

        PdfPCell cAlamat = new PdfPCell();
        cAlamat.setMinimumHeight(18);
        cAlamat.addElement(pAlamat);
        tabel5.addCell(cAlamat);
        document.add(tabel5);

        PdfPTable tabel51 = new PdfPTable(1);
        tabel51.setWidthPercentage(100);

        Paragraph pAlamatUbah = new Paragraph();
        pAlamatUbah.add("6.  Perubahan Alamat :");
        pAlamatUbah.add("\n\n    1. ");
        pAlamatUbah.add("\n\n    2. ");
        pAlamatUbah.add("\n\n    3. ");
        pAlamatUbah.add("\n\n");
        pAlamatUbah.setLeading(0, 1);

        PdfPCell cAlamatUbah = new PdfPCell();
        cAlamatUbah.addElement(pAlamatUbah);
        tabel51.addCell(cAlamatUbah);
        document.add(tabel51);
        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN END

        //------------------------------------------------------------------------------------- KEDUDUKAN KELUARGA
        PdfPTable tabel6 = new PdfPTable(1);
        tabel6.setWidthPercentage(100);

        Paragraph pKedudukanKeluarga = new Paragraph();
        pKedudukanKeluarga.add("7.  Kedudukan dalam Keluarga : ");
        pKedudukanKeluarga.setLeading(0, 1);

        PdfPCell cKedudukanKeluarga = new PdfPCell();
        cKedudukanKeluarga.setMinimumHeight(20);
        cKedudukanKeluarga.addElement(pKedudukanKeluarga);
        tabel6.addCell(cKedudukanKeluarga);
        document.add(tabel6);

        PdfPTable tabel61 = new PdfPTable(1);
        tabel61.setWidthPercentage(100);

        Paragraph pNamaBapakIbu = new Paragraph();
        pNamaBapakIbu.add("8.  a.  Nama Bapak : ");
        pNamaBapakIbu.add("\n\n          Nama Ibu      : ");
        pNamaBapakIbu.add("\n\n     b.  Alamat : ");
        pNamaBapakIbu.setLeading(0, 1);

        PdfPCell cNamaBapakIbu = new PdfPCell();
        cNamaBapakIbu.setMinimumHeight(70);
        cNamaBapakIbu.addElement(pNamaBapakIbu);
        tabel61.addCell(cNamaBapakIbu);

        document.add(tabel61);
        //------------------------------------------------------------------------------------- KEDUDUKAN END

        //------------------------------------------------------------------------------------- PEKERJAAN
        PdfPTable tabel7 = new PdfPTable(2);
        tabel7.setWidthPercentage(100);

        Paragraph pPekerjaan = new Paragraph();
        pPekerjaan.add("9.  a. Pekerjaan : " + getPekerjaan());
        pPekerjaan.setLeading(0, 1);

        PdfPCell cPekerjaan = new PdfPCell();
        cPekerjaan.setMinimumHeight(20);
        cPekerjaan.addElement(pPekerjaan);
        tabel7.addCell(cPekerjaan);

        Paragraph pJabatan = new Paragraph();
        pJabatan.add("  b. Jabatan : " + getJabatan());
        pJabatan.setLeading(0, 1);

        PdfPCell cJabatan = new PdfPCell();
        cJabatan.setMinimumHeight(20);
        cJabatan.addElement(pJabatan);
        tabel7.addCell(cJabatan);

        document.add(tabel7);
        //------------------------------------------------------------------------------------- PEKERJAAN END

        //------------------------------------------------------------------------------------- INSTANSI DLL
        PdfPTable tabel8 = new PdfPTable(1);
        tabel8.setWidthPercentage(100);

        Paragraph pInstansi = new Paragraph();
        pInstansi.add("     c. Instansi/Lembaga/Kantor : " + getInstansilembagakantor());
        pInstansi.setLeading(0, 1);

        PdfPCell cInstansi = new PdfPCell();
        cInstansi.setMinimumHeight(20);
        cInstansi.addElement(pInstansi);
        tabel8.addCell(cInstansi);

        document.add(tabel8);
        //------------------------------------------------------------------------------------- INSTANSI DLL END

        //------------------------------------------------------------------------------------- NAMA ISTRI
        float[] colomn = { 7, 1, 2 };
        PdfPTable tabel9 = new PdfPTable(colomn);
        tabel9.setWidthPercentage(100);

        Paragraph pNamaIstriBapakIbu = new Paragraph();
        pNamaIstriBapakIbu.add("10.");
        pNamaIstriBapakIbu.add("\n       a. Nama Istri : ");
        pNamaIstriBapakIbu.add("\n\n       b. Nama Bapak Istri : ");
        pNamaIstriBapakIbu.add("\n\n       c. Nama Ibu Istri : ");
        pNamaIstriBapakIbu.add("\n\n       d. Alamat : ");
        pNamaIstriBapakIbu.setLeading(0, 1);

        PdfPCell cNamaIstriBapakIbu = new PdfPCell();
        cNamaIstriBapakIbu.setMinimumHeight(110);
        cNamaIstriBapakIbu.addElement(pNamaIstriBapakIbu);
        tabel9.addCell(cNamaIstriBapakIbu);

        Paragraph pUmurIstriBapakIbu = new Paragraph();
        pUmurIstriBapakIbu.add("  Umur :");
        pUmurIstriBapakIbu.setLeading(0, 1);

        PdfPCell cUmurIstriBapakIbu = new PdfPCell();
        cUmurIstriBapakIbu.setMinimumHeight(110);
        cUmurIstriBapakIbu.addElement(pUmurIstriBapakIbu);
        tabel9.addCell(cUmurIstriBapakIbu);

        Paragraph pPekerjaanIstriBapakIbu = new Paragraph();
        pPekerjaanIstriBapakIbu.add("  Pekerjaan :");
        pPekerjaanIstriBapakIbu.setLeading(0, 1);

        PdfPCell cPekerjaanIstriBapakIbu = new PdfPCell();
        cPekerjaanIstriBapakIbu.setMinimumHeight(110);
        cPekerjaanIstriBapakIbu.addElement(pPekerjaanIstriBapakIbu);
        tabel9.addCell(cPekerjaanIstriBapakIbu);

        document.add(tabel9);
        //------------------------------------------------------------------------------------- NAMA ISTRI END

        //------------------------------------------------------------------------------------- SANAK SAUDARA
        PdfPTable tabel10 = new PdfPTable(colomn);
        tabel10.setWidthPercentage(100);

        Paragraph pSanakSaudara = new Paragraph();
        pSanakSaudara.add("11.  Nama Sanak/Saudara yang menjadi Tanggungan : \n       1.\n       2.");
        pSanakSaudara.setLeading(0, 1);

        PdfPCell cSanakSaudara = new PdfPCell();
        cSanakSaudara.addElement(pSanakSaudara);
        tabel10.addCell(cSanakSaudara);

        Paragraph pSanakSaudara1 = new Paragraph();
        pSanakSaudara1.add("");
        pSanakSaudara1.setLeading(0, 1);

        PdfPCell cSanakSaudara1 = new PdfPCell();
        cSanakSaudara1.addElement(pSanakSaudara1);
        tabel10.addCell(cSanakSaudara1);

        Paragraph pSanakSaudara2 = new Paragraph();
        pSanakSaudara2.add("");
        pSanakSaudara2.setLeading(0, 1);

        PdfPCell cSanakSaudara2 = new PdfPCell();
        cSanakSaudara2.addElement(pSanakSaudara2);
        tabel10.addCell(cSanakSaudara2);

        document.add(tabel10);
        //------------------------------------------------------------------------------------- SANAK SAUDARA END

        //------------------------------------------------------------------------------------- ANAK2
        PdfPTable tabel11 = new PdfPTable(colomn);
        tabel11.setWidthPercentage(100);

        Paragraph pAnak2 = new Paragraph();
        pAnak2.add("12.  Anak-anak : ");
        pAnak2.add("\n\n       1. ");
        pAnak2.add("\n\n       2. ");
        pAnak2.add("\n\n       3. ");
        pAnak2.add("\n\n       4. ");
        pAnak2.add("\n\n       5. ");
        pAnak2.add("\n\n       6. ");
        pAnak2.add("\n");
        pAnak2.setLeading(0, 1);

        PdfPCell cAnak2 = new PdfPCell();
        cAnak2.setMinimumHeight(165);
        cAnak2.addElement(pAnak2);
        tabel11.addCell(cAnak2);

        Paragraph pUmurAnak2 = new Paragraph();
        pUmurAnak2.add("  Umur : ");
        pUmurAnak2.setLeading(0, 1);

        PdfPCell cUmurAnak2 = new PdfPCell();
        cUmurAnak2.setMinimumHeight(165);
        cUmurAnak2.addElement(pUmurAnak2);
        tabel11.addCell(cUmurAnak2);

        Paragraph pPekarjaanAnak2 = new Paragraph();
        pPekarjaanAnak2.add("  Pekerjaan : ");
        pPekarjaanAnak2.setLeading(0, 1);

        PdfPCell cPekerjaanAnak2 = new PdfPCell();
        cPekerjaanAnak2.setMinimumHeight(165);
        cPekerjaanAnak2.addElement(pPekarjaanAnak2);
        tabel11.addCell(cPekerjaanAnak2);

        document.add(tabel11);
        //------------------------------------------------------------------------------------- ANAK2 END

        //------------------------------------------------------------------------------------- CIRI-CIRI
        PdfPTable tabel12 = new PdfPTable(1);
        tabel12.setWidthPercentage(100);

        Paragraph pCiri2 = new Paragraph();
        pCiri2.add("13.  Ciri-ciri badan : ");
        pCiri2.add("\n\n       1. Rambut : " + getRambut());
        for (int i = 0; i < (35 - getRambut().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("2. Muka : " + getMuka());
        for (int i = 0; i < (35 - getMuka().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("3. Kulit : " + getKulit());
        pCiri2.setLeading(0, 1);

        PdfPCell cCiri2 = new PdfPCell();
        cCiri2.setMinimumHeight(45);
        cCiri2.addElement(pCiri2);
        tabel12.addCell(cCiri2);

        document.add(tabel12);
        //------------------------------------------------------------------------------------- CIRI-CIRI END

        //------------------------------------------------------------------------------------- LANJUTAN CIRI2
        PdfPTable tabel13 = new PdfPTable(1);
        tabel13.setWidthPercentage(100);

        Paragraph pCiri2Lanjutan = new Paragraph();
        for (int i = 0; i < 20; i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("4.  Tinggi : " + getTinggi());
        for (int i = 0; i < (35 - getTinggi().length()); i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("5.  Tanda Istimewa : " + getTandaistimewa());
        pCiri2Lanjutan.setLeading(0, 1);

        PdfPCell cCiri2Lanjutan = new PdfPCell();
        cCiri2Lanjutan.setMinimumHeight(20);
        cCiri2Lanjutan.addElement(pCiri2Lanjutan);
        tabel13.addCell(cCiri2Lanjutan);

        document.add(tabel13);
        //------------------------------------------------------------------------------------- LANJUTAN CIRI2

        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI
        PdfPTable tabel14 = new PdfPTable(1);
        tabel14.setWidthPercentage(100);

        Paragraph pSidikJari = new Paragraph();
        pSidikJari.add("14.  Rumus Sidik Jari : " + getRumussidikjari());
        pSidikJari.setLeading(0, 1);

        PdfPCell cSidikJari = new PdfPCell();
        cSidikJari.setMinimumHeight(20);
        cSidikJari.addElement(pSidikJari);
        tabel14.addCell(cSidikJari);

        document.add(tabel14);
        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI END

        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH
        float[] colom = { 8, 2 };
        PdfPTable tabel15 = new PdfPTable(colom);
        tabel15.setWidthPercentage(100);

        Paragraph pRiwayatSekolah = new Paragraph();
        pRiwayatSekolah.add("15.  Riwayat Sekolah : ");
        pRiwayatSekolah.add("\n\n       1. ");
        pRiwayatSekolah.add("\n\n       2. ");
        pRiwayatSekolah.add("\n\n       3. ");
        pRiwayatSekolah.add("\n\n       4. ");
        pRiwayatSekolah.add("\n\n       5. ");
        pRiwayatSekolah.add("\n\n       6. ");
        pRiwayatSekolah.setLeading(0, 1);

        PdfPCell cRiwayatSekolah = new PdfPCell();
        cRiwayatSekolah.setMinimumHeight(165);
        cRiwayatSekolah.addElement(pRiwayatSekolah);
        tabel15.addCell(cRiwayatSekolah);

        Paragraph pTahunLulus = new Paragraph();
        pTahunLulus.add("Tahun Lulus");
        pTahunLulus.setLeading(0, 1);

        PdfPCell cTahunLulus = new PdfPCell();
        cTahunLulus.setMinimumHeight(165);
        cTahunLulus.addElement(pTahunLulus);
        tabel15.addCell(cTahunLulus);

        document.add(tabel15);
        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH END

        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI
        PdfPTable tabel16 = new PdfPTable(1);
        tabel16.setWidthPercentage(100);

        Paragraph pKesenenanganKegemaranHobi = new Paragraph();
        pKesenenanganKegemaranHobi.add("16.  Kesenangan/Kegemaran/Hobi : " + getHobi());
        pKesenenanganKegemaranHobi.setLeading(0, 1);

        PdfPCell cKesenenanganKegemaranHobi = new PdfPCell();
        cKesenenanganKegemaranHobi.setMinimumHeight(20);
        cKesenenanganKegemaranHobi.addElement(pKesenenanganKegemaranHobi);
        tabel16.addCell(cKesenenanganKegemaranHobi);

        document.add(tabel16);
        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI END

        //------------------------------------------------------------------------------------- CATATAN KRIMINAL
        PdfPTable tabel17 = new PdfPTable(1);
        tabel17.setWidthPercentage(100);

        Paragraph pCatatanKriminal = new Paragraph();
        pCatatanKriminal.add("17.  Catatan kriminal yang ada : ");
        pCatatanKriminal.add("\n\n       1. " + getCatatankriminal1());
        pCatatanKriminal.add("\n\n       2. " + getCatatankriminal2());
        pCatatanKriminal.add("\n\n       3. " + getCatatankriminal3());
        pCatatanKriminal.setLeading(0, 1);

        PdfPCell cCatatanKriminal = new PdfPCell();
        cCatatanKriminal.setMinimumHeight(95);
        cCatatanKriminal.addElement(pCatatanKriminal);
        tabel17.addCell(cCatatanKriminal);

        document.add(tabel17);
        //------------------------------------------------------------------------------------- CATATAN KRIMINAL END

        //------------------------------------------------------------------------------------- KETERANGAN DLL
        PdfPTable tabel18 = new PdfPTable(1);
        tabel18.setWidthPercentage(100);

        Paragraph pDataKeteranganLain2 = new Paragraph();
        pDataKeteranganLain2.add("18.  Data Keterangan dan lain2 : ");
        pDataKeteranganLain2.add("\n\n\n");
        pDataKeteranganLain2.setLeading(0, 1);

        PdfPCell cDataKeteranganLain2 = new PdfPCell();
        cDataKeteranganLain2.addElement(pDataKeteranganLain2);

        if (list.size() > 0) {
            float[] kolomkegiatan = { 8, 2 };
            PdfPTable nestedTable = new PdfPTable(kolomkegiatan);

            nestedTable.addCell(new Paragraph("Kegiatan"));
            nestedTable.addCell(new Paragraph("Tanggal"));

            for (int i = 0; i < list.size(); i++) {
                nestedTable.addCell(new Paragraph(list.get(i).getNamakegiatan()));
                nestedTable.addCell(new Paragraph(list.get(i).getTanggal()));
            }

            cDataKeteranganLain2.addElement(nestedTable);
            cDataKeteranganLain2.setPaddingBottom(20f);
            tabel18.addCell(cDataKeteranganLain2);
        }

        document.add(tabel18);
        //------------------------------------------------------------------------------------- KETERANGAN DLL END

        document.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return output;
}

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. ja v a  2 s.  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();

}