Example usage for com.itextpdf.text BaseColor LIGHT_GRAY

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

Introduction

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

Prototype

BaseColor LIGHT_GRAY

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

Click Source Link

Usage

From source file:scrum.server.common.APdfCreator.java

License:Open Source License

protected void release(APdfContainerElement pdf, Release release) {
    pdf.nl();/*  w w  w.  j  a  v  a 2s  .  c  o  m*/

    ATable table = pdf.table(3, 20, 3);

    ARow rowHeader = table.row().setDefaultBackgroundColor(BaseColor.LIGHT_GRAY);
    rowHeader.cell().setFontStyle(referenceFont).text(release.getReference());
    rowHeader.cell().setFontStyle(new FontStyle(defaultFont).setBold(true)).text(release.getLabel());
    rowHeader.cell().setFontStyle(defaultFont).text(release.getReleaseDate());

    richtextRow(table, "Development notes", release.getNote());
    richtextRow(table, "Release notes", release.getReleaseNotes());

    table.createCellBorders(BaseColor.GRAY, 0.2f);
}

From source file:scrum.server.common.APdfCreator.java

License:Open Source License

protected void issue(APdfContainerElement pdf, Issue issue) {
    pdf.nl();/*from w w w  . j a  v  a  2 s .c  om*/

    ATable table = pdf.table(3, 20, 6);

    ARow rowHeader = table.row().setDefaultBackgroundColor(BaseColor.LIGHT_GRAY);
    rowHeader.cell().setFontStyle(referenceFont).text(issue.getReference());
    rowHeader.cell().setFontStyle(new FontStyle(defaultFont).setBold(true)).text(issue.getLabel());
    String sideinfo;
    if (issue.isBug()) {
        if (issue.isFixed()) {
            sideinfo = issue.getSeverityLabel() + ", fixed by " + issue.getOwner().getName() + " on "
                    + issue.getFixDate();
        } else if (issue.isOwnerSet()) {
            sideinfo = issue.getSeverityLabel() + ", claimed by " + issue.getOwner().getName();
        } else {
            sideinfo = issue.getSeverityLabel();
        }
    } else {
        sideinfo = issue.getAcceptDate().toString();
    }
    rowHeader.cell().setFontStyle(defaultFont).text(sideinfo);

    richtextRow(table, "Description", issue.getDescription());
    richtextRow(table, "Statement", issue.getStatement());

    table.createCellBorders(BaseColor.GRAY, 0.2f);
}

From source file:scrum.server.impediments.ImpedimentListPdfCreator.java

License:Open Source License

private void impediment(APdfContainerElement pdf, Impediment imp) {
    pdf.nl();/*from  w ww . j a  v a  2 s.co  m*/

    ATable table = pdf.table(2, 20, 3);

    ARow rowHeader = table.row().setDefaultBackgroundColor(BaseColor.LIGHT_GRAY);
    rowHeader.cell().setFontStyle(referenceFont).text(imp.getReference());
    rowHeader.cell().setFontStyle(new FontStyle(defaultFont).setBold(true)).text(imp.getLabel());
    rowHeader.cell().setFontStyle(smallerFont).text(imp.getDate());

    richtextRow(table, "Description", imp.getDescription());

    if (imp.isSolutionSet())
        richtextRow(table, "Solution", imp.getSolution());

    Set<Task> tasks = imp.getTasks();
    if (!tasks.isEmpty()) {
        ACell cell = richtextRow(table, "Blocked tasks", null);
        for (Task task : tasks) {
            cell.paragraph().text(task.getReference(), referenceFont).text(" ").text(task.getLabel()).text(" (")
                    .text(task.getRequirement().getReference(), referenceFont).text(")");
        }
    }

    table.createCellBorders(BaseColor.GRAY, 0.2f);
}

From source file:scrum.server.sprint.SprintReportPdfCreator.java

License:Open Source License

@Deprecated
private void requirement(APdfContainerElement pdf, StoryInfo req) {
    pdf.nl();//  w  w  w.  ja  va  2s  .c  o m

    ATable table = pdf.table(3, 20, 2, 2);

    ARow rowHeader = table.row().setDefaultBackgroundColor(BaseColor.LIGHT_GRAY);
    rowHeader.cell().setFontStyle(referenceFont).text(req.getReference());
    rowHeader.cell().setFontStyle(new FontStyle(defaultFont).setBold(true)).text(req.getLabel());
    rowHeader.cell().paragraph().text(req.getEstimatedWorkAsString(), referenceFont);
    rowHeader.cell().paragraph().text(req.getBurnedWorkAsString(), referenceFont);

    List<TaskInfo> tasks = req.getTasks();
    for (TaskInfo tsk : tasks) {
        ACell tasksCell = table.row().cell().setColspan(table.getColumnCount());
        AParagraph p = tasksCell.paragraph();
        p.text(tsk.getReference(), referenceFont);
        p.text(" " + tsk.getLabel() + " ", defaultFont);
        p.text(tsk.getBurnedWork() + " hrs.", referenceFont);
    }

    table.createCellBorders(BaseColor.GRAY, 0.2f);
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.PdfExportServiceImpl.java

License:Open Source License

private PdfPTable createSjukfallTable(List<SjukfallEnhet> sjukfallList, Urval urval, boolean showPatientId,
        boolean showSrsRisk) throws DocumentException {

    // Setup column widths (relative to each other)
    PdfPTable table = createTableColumns(urval, showPatientId, showSrsRisk);

    table.setWidthPercentage(100.0f);/*from w  w  w .j  a  v a  2 s  . com*/

    table.getDefaultCell().setBackgroundColor(TABLE_HEADER_BASE_COLOR);
    table.getDefaultCell().setBorderColor(TABLE_HEADER_BASE_COLOR);
    table.getDefaultCell().setNoWrap(true);
    table.getDefaultCell().setPadding(3f);
    table.getDefaultCell().setPaddingLeft(2f);

    addCell(table, TABLEHEADER_NR, PdfExportConstants.TABLE_HEADER_FONT);

    if (showPatientId) {
        addCell(table, TABLEHEADER_PERSONNUMMER, PdfExportConstants.TABLE_HEADER_FONT);
    }

    addCell(table, TABLEHEADER_ALDER, PdfExportConstants.TABLE_HEADER_FONT);

    if (showPatientId) {
        addCell(table, TABLEHEADER_NAMN, PdfExportConstants.TABLE_HEADER_FONT);
    }

    addCell(table, TABLEHEADER_KON, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_NUVARANDE_DIAGNOS, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_STARTDATUM, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_SLUTDATUM, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_SJUKSKRIVNINGSLANGD, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_ANTAL, PdfExportConstants.TABLE_HEADER_FONT);
    addCell(table, TABLEHEADER_SJUKSKRIVNINGSGRAD, PdfExportConstants.TABLE_HEADER_FONT);
    if (Urval.ALL.equals(urval)) {
        addCell(table, TABLEHEADER_NUVARANDE_LAKARE, PdfExportConstants.TABLE_HEADER_FONT);
    }

    if (showSrsRisk) {
        addCell(table, TABLEHEADER_SRS_RISK, PdfExportConstants.TABLE_HEADER_FONT);
    }

    // Set cell styles for the non-header cells following hereafter
    table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
    table.getDefaultCell().setBorderColor(BaseColor.LIGHT_GRAY);
    table.getDefaultCell().setNoWrap(false);
    table.getDefaultCell().setPadding(2f);

    table.setHeaderRows(1);
    int rowNumber = 1;
    for (SjukfallEnhet is : sjukfallList) {
        if (rowNumber % 2 == 0) {
            table.getDefaultCell().setBackgroundColor(TABLE_EVEN_ROW_COLOR);
        } else {
            table.getDefaultCell().setBackgroundColor(TABLE_ODD_ROW_COLOR);
        }

        addCell(table, String.valueOf(rowNumber));

        if (showPatientId) {
            addCell(table, getPersonnummerColumn(is));
        }

        addCell(table, is.getPatient().getAlder());

        if (showPatientId) {
            addCell(table, is.getPatient().getNamn());
        }
        addCell(table, is.getPatient().getKon().getDescription());
        addCell(table, getCompoundDiagnoseText(is, showPatientId));
        addCell(table, is.getStart() != null ? YearMonthDateFormatter.print(is.getStart()) : "?");
        addCell(table, is.getSlut() != null ? YearMonthDateFormatter.print(is.getSlut()) : "?");
        addCell(table, getlangdText(is));
        addCell(table, is.getIntyg());
        addCell(table, getGrader(is));
        if (Urval.ALL.equals(urval)) {
            addCell(table, is.getLakare().getNamn());
        }
        if (showSrsRisk) {
            addCell(table, getRiskKategoriDesc(is.getRiskSignal()));
        }
        rowNumber++;
    }

    return table;

}

From source file:Servicios.formatos.java

@SuppressWarnings("empty-statement")
private void b_inv_tractoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_inv_tractoActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//from w w w. ja  v  a  2 s.c o  m
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        Orden ord = (Orden) session.get(Orden.class, Integer.parseInt(orden));
        session.beginTransaction().begin();
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);

        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "Inventario de Tractocamin",
                "reportes/" + ord.getIdOrden() + "/" + valor + "-invTRacto.pdf");

        reporte.agregaObjeto(reporte.crearImagen("imagenes/empresa300115.jpg", 00, -32, 17));

        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(30, 710, 550, 60, 5);

        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, con.getEmpresa(), 305, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "HOLAJATERIA Y PINTURA EN GENERAL", 305,
                743, 0);
        reporte.texto("FECHA: " + ord.getFecha().toString(), bf, BaseColor.BLACK, 7, 495, 743);
        reporte.contenido.rectangle(527, 742, 50, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMPRA Y VENTA DE REFACCIONES", 305,
                733, 0);
        reporte.texto("SEGURO: ", bf, BaseColor.BLACK, 8, 487, 733);
        reporte.contenido.rectangle(527, 732, 50, 0);
        reporte.texto("OT: " + ord.getIdOrden(), bf, BaseColor.BLACK, 8, 511, 723);
        reporte.contenido.rectangle(527, 722, 50, 0);
        String cliente = ord.getClientes().getNombre();
        if (cliente.length() > 58)
            cliente = cliente.substring(0, 58);
        reporte.texto("ASEGURADO: " + cliente, bf, BaseColor.BLACK, 7, 135, 723);
        reporte.contenido.rectangle(190, 722, 288, 0);
        if (ord.getNoSerie() != null)
            reporte.texto("SERIE: " + ord.getNoSerie(), bf, BaseColor.BLACK, 7, 38, 713);
        else
            reporte.texto("SERIE: ", bf, BaseColor.BLACK, 7, 38, 713);

        reporte.contenido.rectangle(65, 712, 72, 0);
        reporte.texto("MARCA: " + ord.getMarca().getMarcaNombre(), bf, BaseColor.BLACK, 7, 145, 713);
        reporte.contenido.rectangle(177, 712, 145, 0);
        reporte.texto("TIPO: " + ord.getTipo().getTipoNombre(), bf, BaseColor.BLACK, 7, 330, 713);
        reporte.contenido.rectangle(352, 712, 125, 0);
        if (ord.getModelo() != null)
            reporte.texto("MODELO: " + ord.getModelo(), bf, BaseColor.BLACK, 7, 488, 713);
        else
            reporte.texto("MODELO: ", bf, BaseColor.BLACK, 7, 488, 713);

        /*reporte.contenido.rectangle(527, 712, 50, 0);
                
        reporte.contenido.roundRectangle(30, 70, 550, 150, 5);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMBUSTIBLE", 530, 145, 270);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "LLANTAS", 200, 200, 0);
                
        reporte.contenido.rectangle(70, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "NOMBRE Y FIRMA DEL CLIENTE", 185, 20, 0);
        reporte.contenido.rectangle(320, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "OPERADOR DE GRUA", 430, 20, 0);*/

        reporte.finTexto();

        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        float tam[] = new float[] { 350, 50, 50, 200, 350, 50, 50, 200 };
        Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD);
        PdfPTable tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT);
        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        tabla.addCell(reporte.celda("INVENTARIO DE UNIDADES", font, BaseColor.LIGHT_GRAY, centro, 8, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));

        //agregamos los renglones
        String descripcion[][] = { { "I SECCIN FRENTE", "EXTINGUIDOR" }, { "DEFENSA O ALMA", "LUZ INTERIOR" },
                { "CUBIERTAS DEFENSA", "PALANCA VELOCIDADES" }, { "COFRE", "SELECTOR VELOCIDADES" },
                { "BISAGRA COFRE", "VESTIDURA" }, { "SALPICADERAS", "III DORMITORIO EXT." },
                { "BISELES", "TOLDO" }, { "FAROS", "DEFLECTOR TOLDO" }, { "DIRECCIONALES", "CONCHA LATERALES" },
                { "MOLDURAS", "LIENZO COSTADO" }, { "PARRILLA", "PUERTA COST. SUP." },
                { "EMBLEMAS", "PUERTA COST. INF." }, { "EXT. SALPICADERA", "MANIJA CHAPA" },
                { "II CABINA EXT.", "PASAMANOS" }, { "ZEPPELIN", "DEFLECTOR LATERAL" },
                { "CORNETA AIRE ELECT.", "LIENZO TRASERO" }, { "PARABRISAS Y HULE", "INTERIOR" },
                { "BRAZOS Y PLUMAS IMP.", "CORTINA" }, { "DEFLECTOR TOLDO", "COLCHN" },
                { "ESPEJO LATERAL", "CALEFACCIN" }, { "PUERTAS", "LUZ INTERIOR" },
                { "CRISTAL PUERTA", "VESTIDURA" }, { "MANIJA", "GATO Y HERRAMIENTA" },
                { "PASAMANOS", "LLAVE DE RUEDAS" }, { "DEFLECTOR LATERAL", "SEALES EMERGENCIA" },
                { "CRISTAL MEDALLN", "IV ACCCESORIOS Y MOTOR" }, { "INTERIOR", "CAJA BATERIA Y TAPA" },
                { "TOLDO", "ACUMULADOR" }, { "CONSOLA TOLDO", "TANQUES COMBUSTIBLE" },
                { "CONSOLA TABLERO", "ESTRIBOS TANQUES" }, { "APARATOS TABLERO", "FALDONES TANQUES" },
                { "RELOJ", "TANQUES AIRE" }, { "CONTROLES TABLERO", "PUNTA ESCAPE" },
                { "GUANTERA", "MALLA SILENCIADOR" }, { "CENICERO", "SILENCIADOR" },
                { "ENCENDEDOR", "QUINTA RUEDA" }, { "C.B.", "EJE DEL." }, { "RADIO ESTREO", "MUELLES DEL." },
                { "BOCINAS", "BRAZOS DE DIRECCIN" }, { "VOLANTE", "CAJA DE DIRECCIN" },
                { "PALANCA DIRECCIONALES", "CONDENSADOR" }, { "ASIENTOS", "ENFRIADOR DE AIRE" },
                { "CINTURONES SEGURIDAD", "POST ENFRIADOR" }, { "MANIJAS", "RADIADOR" },
                { "TOLVA RADIADOR", "ALTERNADOR" }, { "MANGUERAS", "BANDAS DE MOTOR" },
                { "VENTILADOR/FAN CLUTCH", "BAYONETA ACEITE DE MOTOR" }, { "DAMPER", "TURBO" },
                { "TAPA DISTRIBUCIN", "DEPSITO AGUA" }, { "POLEA DE MARCAS", "FRENO MOTOR" },
                { "BOMBA INYECCIN", "GPS" }, { "TARJETA IAVE", "CARDAN" }, { "COMPUTADORA", "YUGO" },
                { "COMPRESOR A/C", "CRUCETA" }, { "COMPRESOR AIRE", "INTERDIFERENCIALES" },
                { "BOMBA DIRECCIN HID.", "DIFERENCIAL(1)(2)" },
                { "DEPSITO DIRECCIN HID.", "FLECHA DIFERENCIALES" },
                { "BAYONETA ACEITE HID.", "SUSPENSIN TRASERA" }, { "PURIFICADOR", "C?MARAS DE AIRE" },
                { "MONO BLOCK", "TOMA DE FUERZA VOLTEO" }, { "CARTER", "TANQUE ACEITE HID. VOLTEO" },
                { "CONCHA MOTOR", "SOPORTE SILENCIADOR" }, { "MARCHA", "ENGOMADOS" },
                { "CLUTCH", "PLACA DELANTERA" }, { "CAMPANA TRANSMISIN", "PLACA TRASERA" },
                { "TRANSMISIN", "KILOMETRAJE" }, { "BOMBA DE AGUA", "LODERAS INTERNAS" },
                { "BOMBA DE ACEITE", "LODERAS TRASERAS" },

        };
        for (int i = 0; i < 68; i++) {
            tabla.addCell(
                    reporte.celda(descripcion[i][0], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(
                    reporte.celda(descripcion[i][1], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
        }
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("herramientas:", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));

        reporte.agregaObjeto(tabla);
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        //reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, con.getEmpresa(), 305, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.rectangle(527, 712, 50, 0);

        reporte.contenido.roundRectangle(30, 440, 550, 150, 5);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMBUSTIBLE", 530, 520, 270);//445
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "LLANTAS", 200, 575, 0);//400

        reporte.contenido.rectangle(70, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "NOMBRE Y FIRMA DEL CLIENTE", 185, 20,
                0);
        reporte.contenido.rectangle(320, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "OPERADOR DE GRUA", 430, 20, 0);
        reporte.finTexto();
        //*****agregamos los tanques de combustible
        reporte.agregaObjeto(reporte.crearImagen("imagenes/nivel.jpg", 350, -145, 25));
        reporte.agregaObjeto(reporte.crearImagen("imagenes/llantas.jpg", -125, -145, 65));

        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-invTRacto.pdf");

    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto");
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Servicios.formatos.java

private void b_inv_cajaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_inv_cajaActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*from w  ww . j a  v a 2s.c o  m*/

    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        Orden ord = (Orden) session.get(Orden.class, Integer.parseInt(orden));
        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "Inventario de Caja",
                "reportes/" + ord.getIdOrden() + "/" + valor + "-invCaja.pdf");

        reporte.agregaObjeto(reporte.crearImagen("imagenes/empresa300115.jpg", 00, -32, 17));

        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(30, 710, 550, 60, 5);

        session.beginTransaction().begin();
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);

        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, con.getEmpresa(), 305, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "HOLAJATERIA Y PINTURA EN GENERAL", 305,
                743, 0);
        reporte.texto("FECHA: " + ord.getFecha().toString(), bf, BaseColor.BLACK, 7, 495, 743);
        reporte.contenido.rectangle(527, 742, 50, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMPRA Y VENTA DE REFACCIONES", 305,
                733, 0);
        reporte.texto("SEGURO: ", bf, BaseColor.BLACK, 8, 487, 733);
        reporte.contenido.rectangle(527, 732, 50, 0);
        reporte.texto("OT: " + ord.getIdOrden(), bf, BaseColor.BLACK, 8, 511, 723);
        reporte.contenido.rectangle(527, 722, 50, 0);
        String cliente = ord.getClientes().getNombre();
        if (cliente.length() > 58)
            cliente = cliente.substring(0, 58);
        reporte.texto("ASEGURADO: " + cliente, bf, BaseColor.BLACK, 7, 135, 723);
        reporte.contenido.rectangle(190, 722, 288, 0);
        if (ord.getNoSerie() != null)
            reporte.texto("SERIE: " + ord.getNoSerie(), bf, BaseColor.BLACK, 7, 38, 713);
        else
            reporte.texto("SERIE: ", bf, BaseColor.BLACK, 7, 38, 713);

        reporte.contenido.rectangle(65, 712, 72, 0);
        reporte.texto("MARCA: " + ord.getMarca().getMarcaNombre(), bf, BaseColor.BLACK, 7, 145, 713);
        reporte.contenido.rectangle(177, 712, 145, 0);
        reporte.texto("TIPO: " + ord.getTipo().getTipoNombre(), bf, BaseColor.BLACK, 7, 330, 713);
        reporte.contenido.rectangle(352, 712, 125, 0);
        if (ord.getModelo() != null)
            reporte.texto("MODELO: " + ord.getModelo(), bf, BaseColor.BLACK, 7, 488, 713);
        else
            reporte.texto("MODELO: ", bf, BaseColor.BLACK, 7, 488, 713);

        reporte.contenido.rectangle(527, 712, 50, 0);

        reporte.contenido.roundRectangle(30, 70, 550, 150, 5);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMBUSTIBLE", 530, 145, 270);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "LLANTAS", 200, 200, 0);

        reporte.contenido.rectangle(70, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "NOMBRE Y FIRMA DEL CLIENTE", 185, 20,
                0);
        reporte.contenido.rectangle(320, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "OPERADOR DE GRUA", 430, 20, 0);

        reporte.finTexto();

        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        float tam[] = new float[] { 350, 50, 50, 200, 350, 50, 50, 200 };
        Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD);
        PdfPTable tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT);
        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        tabla.addCell(reporte.celda("INVENTARIO DE UNIDADES", font, BaseColor.LIGHT_GRAY, centro, 8, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));

        //agregamos los renglones
        String descripcion[][] = { { "CAJAS Y REMOLQUES", "" }, { "EQ.REFRIGERACIN", "" },
                { "CAJA BATER?AS", "" }, { "ACUMULADOR", "" }, { "MANITAS", "" }, { "VENTILAS", "" },
                { "PLAFONES", "" }, { "PUERTAS", "" }, { "REDILLAS", "" }, { "CABALLETES", "" }, { "LONA", "" },
                { "DOMOS", "" }, { "FALDONES", "" }, { "PISTN (VOLTEO)", "" }, { "PATINES Y SOPORTES", "" },
                { "PORTA LLANTAS", "" }, { "TANQUE DE GAS O DIESEL", "" }, { "EJES", "" }, { "MUELLES", "" },
                { "C?MARAS DE AIRE", "" }, { "V?LVULAS DE AIRE", "" }, { "V?LVULAS DE AIRE", "" },
                { "GANCHO P/DOLLY", "" }, { "GPS", "" }, { "LLAVES SWITCH", "" }, { " ", "" }, { " ", "" },
                { " ", "" }, { " ", "" }, { " ", "" }, { " ", "" }, { " ", "" }, { " ", "" }, { " ", "" },
                { " ", "" }, { " ", "" }, { " ", "" } };
        for (int i = 0; i < 37; i++) {
            tabla.addCell(
                    reporte.celda(descripcion[i][0], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(
                    reporte.celda(descripcion[i][1], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
        }
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("herramientas:", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));

        reporte.agregaObjeto(tabla);

        //*****agregamos los tanques de combustible
        reporte.agregaObjeto(reporte.crearImagen("imagenes/GAS.jpg", 350, -145, 50));
        reporte.agregaObjeto(reporte.crearImagen("imagenes/llantas-caja.jpg", -100, -145, 60));

        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-invCaja.pdf");

    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto");
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Servicios.SmLogistics.java

private void b_inventario_formatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_inventario_formatoActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*from  www .jav  a 2 s.  c  o m*/
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        Orden ord = (Orden) session.get(Orden.class, orden_act.getIdOrden());
        session.beginTransaction().begin();
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);

        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir2(PageSize.LETTER, "Inventario de Tractocamin",
                "reportes/" + ord.getIdOrden() + "/" + valor + "-invTRacto.pdf");

        reporte.agregaObjeto(reporte.crearImagen("imagenes/empresa300115.jpg", 00, -32, 17));

        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(30, 710, 550, 60, 5);

        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, con.getEmpresa(), 305, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "HOLAJATERIA Y PINTURA EN GENERAL", 305,
                743, 0);
        reporte.texto("FECHA: " + ord.getFecha().toString(), bf, BaseColor.BLACK, 7, 495, 743);
        reporte.contenido.rectangle(527, 742, 50, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMPRA Y VENTA DE REFACCIONES", 305,
                733, 0);
        reporte.texto("SEGURO: ", bf, BaseColor.BLACK, 8, 487, 733);
        reporte.contenido.rectangle(527, 732, 50, 0);
        reporte.texto("OT: " + ord.getIdOrden(), bf, BaseColor.BLACK, 8, 511, 723);
        reporte.contenido.rectangle(527, 722, 50, 0);
        String cliente = ord.getClientes().getNombre();
        if (cliente.length() > 58)
            cliente = cliente.substring(0, 58);
        reporte.texto("ASEGURADO: " + cliente, bf, BaseColor.BLACK, 7, 135, 723);
        reporte.contenido.rectangle(190, 722, 288, 0);
        if (ord.getNoSerie() != null)
            reporte.texto("SERIE: " + ord.getNoSerie(), bf, BaseColor.BLACK, 7, 38, 713);
        else
            reporte.texto("SERIE: ", bf, BaseColor.BLACK, 7, 38, 713);

        reporte.contenido.rectangle(65, 712, 72, 0);
        reporte.texto("MARCA: " + ord.getMarca().getMarcaNombre(), bf, BaseColor.BLACK, 7, 145, 713);
        reporte.contenido.rectangle(177, 712, 145, 0);
        reporte.texto("TIPO: " + ord.getTipo().getTipoNombre(), bf, BaseColor.BLACK, 7, 330, 713);
        reporte.contenido.rectangle(352, 712, 125, 0);
        if (ord.getModelo() != null)
            reporte.texto("MODELO: " + ord.getModelo(), bf, BaseColor.BLACK, 7, 488, 713);
        else
            reporte.texto("MODELO: ", bf, BaseColor.BLACK, 7, 488, 713);

        reporte.finTexto();

        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        float tam[] = new float[] { 350, 50, 50, 200, 350, 50, 50, 200 };
        Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD);
        PdfPTable tabla = reporte.crearTabla(8, tam, 100, Element.ALIGN_LEFT);
        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        tabla.addCell(reporte.celda("INVENTARIO DE UNIDADES", font, BaseColor.LIGHT_GRAY, centro, 8, 1,
                Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("DESCRIPCIN", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("SI", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("NO", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("OBSERVACIONES", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));

        //agregamos los renglones
        String descripcion[][] = { { "I SECCIN FRENTE", "EXTINGUIDOR" }, { "DEFENSA O ALMA", "LUZ INTERIOR" },
                { "CUBIERTAS DEFENSA", "PALANCA VELOCIDADES" }, { "COFRE", "SELECTOR VELOCIDADES" },
                { "BISAGRA COFRE", "VESTIDURA" }, { "SALPICADERAS", "III DORMITORIO EXT." },
                { "BISELES", "TOLDO" }, { "FAROS", "DEFLECTOR TOLDO" }, { "DIRECCIONALES", "CONCHA LATERALES" },
                { "MOLDURAS", "LIENZO COSTADO" }, { "PARRILLA", "PUERTA COST. SUP." },
                { "EMBLEMAS", "PUERTA COST. INF." }, { "EXT. SALPICADERA", "MANIJA CHAPA" },
                { "II CABINA EXT.", "PASAMANOS" }, { "ZEPPELIN", "DEFLECTOR LATERAL" },
                { "CORNETA AIRE ELECT.", "LIENZO TRASERO" }, { "PARABRISAS Y HULE", "INTERIOR" },
                { "BRAZOS Y PLUMAS IMP.", "CORTINA" }, { "DEFLECTOR TOLDO", "COLCHN" },
                { "ESPEJO LATERAL", "CALEFACCIN" }, { "PUERTAS", "LUZ INTERIOR" },
                { "CRISTAL PUERTA", "VESTIDURA" }, { "MANIJA", "GATO Y HERRAMIENTA" },
                { "PASAMANOS", "LLAVE DE RUEDAS" }, { "DEFLECTOR LATERAL", "SEALES EMERGENCIA" },
                { "CRISTAL MEDALLN", "IV ACCCESORIOS Y MOTOR" }, { "INTERIOR", "CAJA BATERIA Y TAPA" },
                { "TOLDO", "ACUMULADOR" }, { "CONSOLA TOLDO", "TANQUES COMBUSTIBLE" },
                { "CONSOLA TABLERO", "ESTRIBOS TANQUES" }, { "APARATOS TABLERO", "FALDONES TANQUES" },
                { "RELOJ", "TANQUES AIRE" }, { "CONTROLES TABLERO", "PUNTA ESCAPE" },
                { "GUANTERA", "MALLA SILENCIADOR" }, { "CENICERO", "SILENCIADOR" },
                { "ENCENDEDOR", "QUINTA RUEDA" }, { "C.B.", "EJE DEL." }, { "RADIO ESTREO", "MUELLES DEL." },
                { "BOCINAS", "BRAZOS DE DIRECCIN" }, { "VOLANTE", "CAJA DE DIRECCIN" },
                { "PALANCA DIRECCIONALES", "CONDENSADOR" }, { "ASIENTOS", "ENFRIADOR DE AIRE" },
                { "CINTURONES SEGURIDAD", "POST ENFRIADOR" }, { "MANIJAS", "RADIADOR" },
                { "TOLVA RADIADOR", "ALTERNADOR" }, { "MANGUERAS", "BANDAS DE MOTOR" },
                { "VENTILADOR/FAN CLUTCH", "BAYONETA ACEITE DE MOTOR" }, { "DAMPER", "TURBO" },
                { "TAPA DISTRIBUCIN", "DEPSITO AGUA" }, { "POLEA DE MARCAS", "FRENO MOTOR" },
                { "BOMBA INYECCIN", "GPS" }, { "TARJETA IAVE", "CARDAN" }, { "COMPUTADORA", "YUGO" },
                { "COMPRESOR A/C", "CRUCETA" }, { "COMPRESOR AIRE", "INTERDIFERENCIALES" },
                { "BOMBA DIRECCIN HID.", "DIFERENCIAL(1)(2)" },
                { "DEPSITO DIRECCIN HID.", "FLECHA DIFERENCIALES" },
                { "BAYONETA ACEITE HID.", "SUSPENSIN TRASERA" }, { "PURIFICADOR", "C?MARAS DE AIRE" },
                { "MONO BLOCK", "TOMA DE FUERZA VOLTEO" }, { "CARTER", "TANQUE ACEITE HID. VOLTEO" },
                { "CONCHA MOTOR", "SOPORTE SILENCIADOR" }, { "MARCHA", "ENGOMADOS" },
                { "CLUTCH", "PLACA DELANTERA" }, { "CAMPANA TRANSMISIN", "PLACA TRASERA" },
                { "TRANSMISIN", "KILOMETRAJE" }, { "BOMBA DE AGUA", "LODERAS INTERNAS" },
                { "BOMBA DE ACEITE", "LODERAS TRASERAS" },

        };
        for (int i = 0; i < 68; i++) {
            tabla.addCell(
                    reporte.celda(descripcion[i][0], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(
                    reporte.celda(descripcion[i][1], font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
        }
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.BOTTOM));
        tabla.addCell(reporte.celda("herramientas:", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda(" ", font, contenido, derecha, 0, 1, Rectangle.NO_BORDER));
        tabla.addCell(reporte.celda(" ", font, contenido, centro, 7, 1, Rectangle.RECTANGLE));

        reporte.agregaObjeto(tabla);
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        //reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, con.getEmpresa(), 305, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.rectangle(527, 712, 50, 0);

        reporte.contenido.roundRectangle(30, 440, 550, 150, 5);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "COMBUSTIBLE", 530, 520, 270);//445
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "LLANTAS", 200, 575, 0);//400

        reporte.contenido.rectangle(70, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "NOMBRE Y FIRMA DEL CLIENTE", 185, 20,
                0);
        reporte.contenido.rectangle(320, 30, 215, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER, "OPERADOR DE GRUA", 430, 20, 0);
        reporte.finTexto();
        //*****agregamos los tanques de combustible
        reporte.agregaObjeto(reporte.crearImagen("imagenes/nivel.jpg", 350, -145, 25));
        reporte.agregaObjeto(reporte.crearImagen("imagenes/llantas.jpg", -125, -145, 65));

        reporte.cerrar();
        reporte.visualizar2("reportes/" + ord.getIdOrden() + "/" + valor + "-invTRacto.pdf");

    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto");
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:servlet.GenerarPDF.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w  w  w . j  a va2 s.c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    Document document = new Document();

    try {
        ConexionDB sqlite = new ConexionDB();
        java.sql.Connection cn = sqlite.Conectar();
        Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM mascotas;");

        response.setContentType("APPLICATION/download");
        response.setHeader("Content-Disposition", "filename=Mascotas.pdf");
        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();

        Image image = Image.getInstance(
                "C:/Users/Cristian/Documents/NetBeansProjects/adopc-mascotas/web/imagenes/logo9.png");
        image.scaleAbsolute(100, 100);
        document.add(image);

        Paragraph preface = new Paragraph("LOVE MY PET");
        preface.setAlignment(Element.ALIGN_CENTER);
        document.add(preface);

        PdfPTable table = new PdfPTable(5); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table

        //Set Column widths
        float[] columnWidths = { 1f, 1f, 1f, 1f, 1f };
        table.setWidths(columnWidths);

        PdfPCell cellusuario = new PdfPCell(new Paragraph("usario"));
        cellusuario.setBorderColor(BaseColor.BLUE);
        cellusuario.setPaddingLeft(10);
        cellusuario.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellusuario.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell celltipo = new PdfPCell(new Paragraph("tipo"));
        celltipo.setBorderColor(BaseColor.BLUE);
        celltipo.setPaddingLeft(10);
        celltipo.setHorizontalAlignment(Element.ALIGN_CENTER);
        celltipo.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellnombre = new PdfPCell(new Paragraph("nombre"));
        cellnombre.setBorderColor(BaseColor.BLUE);
        cellnombre.setPaddingLeft(10);
        cellnombre.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellnombre.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cellraza = new PdfPCell(new Paragraph("raza"));
        cellraza.setBorderColor(BaseColor.BLUE);
        cellraza.setPaddingLeft(10);
        cellraza.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellraza.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell celledad = new PdfPCell(new Paragraph("edad"));
        celledad.setBorderColor(BaseColor.BLUE);
        celledad.setPaddingLeft(10);
        celledad.setHorizontalAlignment(Element.ALIGN_CENTER);
        celledad.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cellusuario);
        table.addCell(celltipo);
        table.addCell(cellnombre);
        table.addCell(cellraza);
        table.addCell(celledad);

        while (rs.next()) {

            PdfPCell cell1 = new PdfPCell(new Paragraph(rs.getString(1)));
            cell1.setPaddingLeft(1);
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell1);

            PdfPCell cell2 = new PdfPCell(new Paragraph(rs.getString(2)));
            cell2.setPaddingLeft(2);
            cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell2);

            PdfPCell cell3 = new PdfPCell(new Paragraph(rs.getString(3)));
            cell3.setPaddingLeft(3);
            cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell3.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell3);

            PdfPCell cell4 = new PdfPCell(new Paragraph(rs.getString(4)));
            cell4.setPaddingLeft(4);
            cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell4.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell4);

            PdfPCell cell5 = new PdfPCell(new Paragraph(rs.getString(5)));
            cell5.setPaddingLeft(5);
            cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell5.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell5);

        }

        document.add(table);
        //Add more content here
        cn.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    document.close();
}

From source file:superlaskuttaja.logiikka.PdfExtractor.java

private void muodostaDokumentti(Document document, String laskunNumero, PdfWriter writer)
        throws DocumentException, SQLException, ParseException {
    document.open();//from   w w  w .  ja va  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();

}