Example usage for com.lowagie.text Font NORMAL

List of usage examples for com.lowagie.text Font NORMAL

Introduction

In this page you can find the example usage for com.lowagie.text Font NORMAL.

Prototype

int NORMAL

To view the source code for com.lowagie.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException {
    final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);

    for (final ExportField exportColumn : exportSheet.getExportFields()) {
        datatable.getDefaultCell().setBorderWidth(2);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont));

        datatable.getDefaultCell().setBorderWidth(1);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        final DtField dtField = exportColumn.getDtField();
        final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject());
        final int horizontalAlignement;
        if (value instanceof Number || value instanceof Date) {
            horizontalAlignement = Element.ALIGN_RIGHT;
        } else if (value instanceof Boolean) {
            horizontalAlignement = Element.ALIGN_CENTER;
        } else {//from   www.j  ava  2  s . com
            horizontalAlignement = Element.ALIGN_LEFT;
        }
        datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

        String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache,
                exportSheet.getDtObject(), exportColumn);
        if (text == null) {
            text = "";
        }
        datatable.addCell(new Phrase(8, text, valueFont));
    }
}

From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Effectue le rendu de la liste./*from  w w w. j  a  v  a 2s .com*/
 *
 * @param parameters Paramtres
 * @param datatable Table
 */
private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException {
    // data rows
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    whiteFont.setColor(Color.WHITE);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    // datatable.getDefaultCell().setGrayFill(0);

    // Parcours des DTO de la DTC
    for (final DtObject dto : parameters.getDtList()) {
        for (final ExportField exportColumn : parameters.getExportFields()) {
            final DtField dtField = exportColumn.getDtField();
            final Object value = dtField.getDataAccessor().getValue(dto);
            final int horizontalAlignement;
            if (value instanceof Number || value instanceof Date) {
                horizontalAlignement = Element.ALIGN_RIGHT;
            } else if (value instanceof Boolean) {
                horizontalAlignement = Element.ALIGN_CENTER;
            } else {
                horizontalAlignement = Element.ALIGN_LEFT;
            }
            datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

            String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache, dto,
                    exportColumn);
            if (text == null) {
                text = "";
            }
            datatable.addCell(new Phrase(8, text, font));
        }
    }
}

From source file:io.vertigo.dynamo.plugins.export.rtf.RTFExporter.java

License:Apache License

/** {@inheritDoc} */
@Override//from   w w  w  .j a  v a 2 s .  c  o  m
protected void createWriter(final Document document, final OutputStream out) {
    // final RtfWriter2 writer =
    RtfWriter2.getInstance(document, out);
    // writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

    // advanced page numbers : x/y
    final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
    //-----
    final Paragraph footerParagraph = new Paragraph();
    footerParagraph.add(new RtfPageNumber(font));
    footerParagraph.add(new Phrase(" / ", font));
    footerParagraph.add(new RtfTotalPageNumber(font));
    footerParagraph.setAlignment(Element.ALIGN_CENTER);
    //-----
    final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
    footer.setBorder(Rectangle.TOP);
    document.setFooter(footer);
}

From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException {
    final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);

    for (final ExportField exportColumn : exportSheet.getExportFields()) {
        datatable.getDefaultCell().setBorderWidth(2);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont));

        datatable.getDefaultCell().setBorderWidth(1);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        final DtField dtField = exportColumn.getDtField();
        final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject());
        final int horizontalAlignement;
        if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) {
            horizontalAlignement = Element.ALIGN_RIGHT;
        } else if (value instanceof Boolean) {
            horizontalAlignement = Element.ALIGN_CENTER;
        } else {//w w w.  j a  v a2 s . com
            horizontalAlignement = Element.ALIGN_LEFT;
        }
        datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

        String text = ExportUtil.getText(storeManager, referenceCache, denormCache, exportSheet.getDtObject(),
                exportColumn);
        if (text == null) {
            text = "";
        }
        datatable.addCell(new Phrase(8, text, valueFont));
    }
}

From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Effectue le rendu de la liste./*from   w  w  w.j a  va 2 s .c o m*/
 *
 * @param parameters Paramtres
 * @param datatable Table
 */
private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException {
    // data rows
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    whiteFont.setColor(Color.WHITE);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    // Parcours des DTO de la DTC
    for (final DtObject dto : parameters.getDtList()) {
        for (final ExportField exportColumn : parameters.getExportFields()) {
            final DtField dtField = exportColumn.getDtField();
            final Object value = dtField.getDataAccessor().getValue(dto);
            final int horizontalAlignement;
            if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) {
                horizontalAlignement = Element.ALIGN_RIGHT;
            } else if (value instanceof Boolean) {
                horizontalAlignement = Element.ALIGN_CENTER;
            } else {
                horizontalAlignement = Element.ALIGN_LEFT;
            }
            datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

            String text = ExportUtil.getText(storeManager, referenceCache, denormCache, dto, exportColumn);
            if (text == null) {
                text = "";
            }
            datatable.addCell(new Phrase(8, text, font));
        }
    }
}

From source file:io.vertigo.quarto.plugins.export.rtf.RTFExporter.java

License:Apache License

/** {@inheritDoc} */
@Override//from  w  w  w  .  java 2 s  . c o  m
protected void createWriter(final Document document, final OutputStream out) {
    RtfWriter2.getInstance(document, out);

    // advanced page numbers : x/y
    final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
    //-----
    final Paragraph footerParagraph = new Paragraph();
    footerParagraph.add(new RtfPageNumber(font));
    footerParagraph.add(new Phrase(" / ", font));
    footerParagraph.add(new RtfTotalPageNumber(font));
    footerParagraph.setAlignment(Element.ALIGN_CENTER);
    //-----
    final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
    footer.setBorder(Rectangle.TOP);
    document.setFooter(footer);
}

From source file:is.idega.idegaweb.egov.cases.business.CaseWriter.java

License:Open Source License

protected MemoryFileBuffer writePDF(IWContext iwc) {
    Font titleFont = new Font(Font.HELVETICA, 14, Font.BOLD);
    Font labelFont = new Font(Font.HELVETICA, 11, Font.BOLD);
    Font textFont = new Font(Font.HELVETICA, 11, Font.NORMAL);

    try {//from  www .jav a2  s  .c o  m
        MemoryFileBuffer buffer = new MemoryFileBuffer();
        MemoryOutputStream mos = new MemoryOutputStream(buffer);

        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter.getInstance(document, mos);
        document.addAuthor("Idegaweb eGov");
        document.addSubject("Case");
        document.open();
        document.newPage();

        String title = iwrb.getLocalizedString("case_overview", "Case overview");
        Paragraph cTitle = new Paragraph(title, titleFont);
        cTitle.setSpacingAfter(24);
        document.setPageCount(1);
        document.add(cTitle);

        int[] widths = { 25, 75 };
        PdfPTable table = new PdfPTable(2);
        table.setWidths(widths);
        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setPaddingBottom(8);

        CaseCategory category = theCase.getCaseCategory();
        CaseCategory parentCategory = category.getParent();
        CaseType type = theCase.getCaseType();
        User user = theCase.getOwner();
        Address address = user != null ? getUserBusiness(iwc).getUsersMainAddress(user) : null;
        PostalCode postal = null;
        if (address != null) {
            postal = address.getPostalCode();
        }
        Phone phone = null;
        if (user != null) {
            try {
                phone = getUserBusiness(iwc).getUsersHomePhone(user);
            } catch (NoPhoneFoundException e) {
                //No phone found...
            }
        }
        Email email = null;
        if (user != null) {
            try {
                email = getUserBusiness(iwc).getUsersMainEmail(user);
            } catch (NoEmailFoundException e) {
                //No email found...
            }
        }

        IWTimestamp created = new IWTimestamp(theCase.getCreated());

        if (user != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("name", "Name"), labelFont));
            table.addCell(new Phrase(
                    new Name(user.getFirstName(), user.getMiddleName(), user.getLastName()).getName(locale),
                    textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("personal_id", "Personal ID"), labelFont));
            table.addCell(new Phrase(PersonalIDFormatter.format(user.getPersonalID(), locale), textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("address", "Address"), labelFont));
            table.addCell(new Phrase(address != null ? address.getStreetAddress() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("zip_code", "Postal code"), labelFont));
            table.addCell(new Phrase(postal != null ? postal.getPostalAddress() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("home_phone", "Home phone"), labelFont));
            table.addCell(new Phrase(phone != null ? phone.getNumber() : "-", textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("email", "Email"), labelFont));
            table.addCell(new Phrase(email != null ? email.getEmailAddress() : "-", textFont));

            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
            table.addCell(new Phrase(""));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("case_nr", "Case nr."), labelFont));
        table.addCell(new Phrase(theCase.getPrimaryKey().toString(), textFont));

        if (getCasesBusiness(iwc).useTypes()) {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_type", "Case type"), labelFont));
            table.addCell(new Phrase(type.getName(), textFont));
        }

        if (parentCategory != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont));
            table.addCell(new Phrase(parentCategory.getLocalizedCategoryName(locale), textFont));

            table.addCell(new Phrase(iwrb.getLocalizedString("sub_case_category", "Case category"), labelFont));
            table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont));
        } else {
            table.addCell(new Phrase(iwrb.getLocalizedString("case_category", "Case category"), labelFont));
            table.addCell(new Phrase(category.getLocalizedCategoryName(locale), textFont));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("created_date", "Created date"), labelFont));
        table.addCell(new Phrase(created.getLocaleDateAndTime(locale, IWTimestamp.SHORT, IWTimestamp.SHORT),
                textFont));

        if (theCase.getSubject() != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("subject", "Subject"), labelFont));
            table.addCell(new Phrase(theCase.getSubject(), textFont));
        }

        table.addCell(new Phrase(iwrb.getLocalizedString("message", "Message"), labelFont));
        table.addCell(new Phrase(theCase.getMessage(), textFont));

        if (theCase.getReference() != null) {
            table.addCell(new Phrase(iwrb.getLocalizedString("reference", "Reference"), labelFont));
            table.addCell(new Phrase(theCase.getReference(), textFont));
        }

        table.setWidthPercentage(100);
        document.add(table);

        document.close();
        try {
            mos.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        buffer.setMimeType("application/pdf");
        return buffer;

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

    return null;
}

From source file:it.businesslogic.ireport.gui.sheet.SheetProperty.java

License:Open Source License

public void updateLabel() {

    if (this.getType() != CATEGORY_LABEL) {
        try {//w w w .  j  ava 2  s. c o m
            if (getLabelComponent() != null) {

                //String bold = (value == null || this.isReadOnly() || !isShowResetButton()) ? "" : "<html><b>";

                boolean needBold = !(value == null || this.isReadOnly() || !isShowResetButton());

                java.awt.Font f = getLabelComponent().getFont();

                if (f.isBold() && !needBold) {
                    ((JLabel) getLabelComponent()).setFont(f.deriveFont(Font.NORMAL));
                } else if (!f.isBold() && needBold) {
                    ((JLabel) getLabelComponent()).setFont(f.deriveFont(Font.BOLD));
                }

                // The table is used to avoid word wrap
                //((JLabel)getLabelComponent()).setText("<html><table><tr><td nowrap>" + bold + this.getName() + "</td></tr></table></html>");
                ((JLabel) getLabelComponent()).setText(this.getName());

                if (this.isReadOnly()) {
                    getLabelComponent().setEnabled(false);
                } else {
                    getLabelComponent().setEnabled(true);
                }

                if (labelError != null) {
                    ((JLabel) getLabelComponent()).setIcon(errorIcon);
                    getLabelComponent().setForeground(errorColor);
                    getLabelComponent().setToolTipText(labelError);
                } else {
                    ((JLabel) getLabelComponent()).setIcon(null);
                    getLabelComponent().setForeground(getLabelColor());
                    getLabelComponent().setToolTipText(getName());
                }

                getLabelComponent().updateUI();
            }
        } catch (Exception ex) {

        }
    }
}

From source file:it.prato.comune.tolomeo.web.TolomeoPrintPDFServlet.java

License:Open Source License

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    LogInterface logger = getLogger(request);

    String titolo = request.getParameter("titolo");
    String descrizione = request.getParameter("descrizione");
    String scala = request.getParameter("scala");
    String mapx = request.getParameter("mapx");
    String mapy = request.getParameter("mapy");
    //creo URL alla mappa
    URL urlMappa = new URL(URLDecoder.decode(request.getParameter("urlMappa"), "UTF-8"));
    URI uriMappa = null;//  w ww. j  a  v  a  2s .  com
    try {
        uriMappa = new URI(urlMappa.getProtocol(), null, urlMappa.getHost(), urlMappa.getPort(),
                urlMappa.getPath(), urlMappa.getQuery() + "&mode=map&scale=" + scala + "&mapxy=" + mapx + "+"
                        + mapy + "&map_size=500 500",
                null);
        logger.info("URI di stampa mappa: " + uriMappa);
    } catch (URISyntaxException e) {
        logger.error("URI errore di sintassi", e);
    }

    Font BOLD15 = new Font(Font.HELVETICA, 15, Font.BOLD);
    Font FONT12 = new Font(Font.HELVETICA, 12, Font.NORMAL);
    Font FONT10 = new Font(Font.HELVETICA, 10, Font.NORMAL);

    Document doc = new Document();
    ;
    PdfWriter pdf = null;
    Paragraph par = new Paragraph();

    try {

        //creo il PDF
        response.setContentType("application/pdf");
        pdf = PdfWriter.getInstance(doc, response.getOutputStream());

        //attributi file
        doc.addTitle("Mappa di Prato");
        doc.addAuthor("Comune di Prato");
        doc.open();

        //intestazione
        par.setAlignment(Paragraph.ALIGN_CENTER);
        print("Comune di Prato", BOLD15, par, doc);
        print(titolo, FONT10, par, doc);
        print("", FONT10, par, doc);

        //mappa
        Image mappa = Image.getInstance(uriMappa.toURL());
        mappa.setAlignment(Image.MIDDLE);
        mappa.setBorder(Rectangle.BOX);
        mappa.setBorderWidth(1f);
        doc.add(mappa);

    } catch (Exception e) {
        logger.error("Errore durante la creazione del PDF", e);
        printErr(doc);
    } finally {
        doc.close();
        pdf.close();
        response.getOutputStream().close();
    }
}

From source file:jm.fac.pdf.pdfArqueoCaja.java

License:GNU General Public License

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request//  w ww  .  jav  a2s.  c o  m
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession sesion = request.getSession(true);
    String usuario = (String) sesion.getAttribute("usuario");
    String clave = (String) sesion.getAttribute("clave");

    response.setContentType("application/pdf");
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Expires", "Mon, 01 Jan 2001 00:00:01 GMT");
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Cache-Control", "must-revalidate");
    response.setHeader("Cache-Control", "no-cache");

    //PrintWriter out = response.getWriter();

    Configuracion conf = new Configuracion(this._ip, this._puerto, this._db, usuario, clave);
    String titulo = conf.getValor("razon_social");
    conf.cerrar();

    String path = String.valueOf(request.getRequestURL());
    path = path.substring(0, path.lastIndexOf("/"));
    /*Archivo archivo = new Archivo(this._ip, this._puerto, this._db, usuario, clave);
    String logo = path + "/img/" + archivo.getArchivo(this._dir, 1);
    archivo.cerrar();*/

    ArqueoCaja objArqueoCaja = new ArqueoCaja(this._ip, this._puerto, this._db, usuario, clave);

    Empleado objEmpleado = new Empleado(this._ip, this._puerto, this._db, usuario, clave);

    String id = request.getParameter("id");
    //int i=0;

    String num_documento = "0";
    String fecha = Fecha.getFecha("SQL");
    String hora = Fecha.getHora();
    String cajero = "";
    String saldo_caja = "0";
    String num_cheques = "0";
    String valor_cheques = "0";
    String num_comp_pagos = "0";
    String valor_comp_pagos = "0";
    String num_retenciones = "0";
    String valor_retenciones = "0";
    String valor_efectivo = "0";
    String total_caja = "0";
    String diferencia = "0";
    String tipo_diferencia = "0";
    //boolean anulado = false;

    if (id.compareTo("-1") != 0) {
        try {
            ResultSet rsArqueoCaja = objArqueoCaja.getArqueoCaja(id);
            if (rsArqueoCaja.next()) {
                num_documento = (rsArqueoCaja.getString("num_documento") != null)
                        ? rsArqueoCaja.getString("num_documento")
                        : "0";
                fecha = (rsArqueoCaja.getString("fecha") != null) ? rsArqueoCaja.getString("fecha") : "";
                hora = (rsArqueoCaja.getString("Hora") != null) ? rsArqueoCaja.getString("Hora") : "";
                cajero = (rsArqueoCaja.getString("cajero") != null) ? rsArqueoCaja.getString("cajero") : "";
                saldo_caja = (rsArqueoCaja.getString("saldo_caja") != null)
                        ? rsArqueoCaja.getString("saldo_caja")
                        : "";
                num_cheques = (rsArqueoCaja.getString("num_cheques") != null)
                        ? rsArqueoCaja.getString("num_cheques")
                        : "0.00";
                valor_cheques = (rsArqueoCaja.getString("valor_cheques") != null)
                        ? rsArqueoCaja.getString("valor_cheques")
                        : "0.00";
                num_comp_pagos = (rsArqueoCaja.getString("num_comp_pagos") != null)
                        ? rsArqueoCaja.getString("num_comp_pagos")
                        : "0.00";
                valor_comp_pagos = (rsArqueoCaja.getString("valor_comp_pagos") != null)
                        ? rsArqueoCaja.getString("valor_comp_pagos")
                        : "0.00";
                num_retenciones = (rsArqueoCaja.getString("num_retenciones") != null)
                        ? rsArqueoCaja.getString("num_retenciones")
                        : "0";
                valor_retenciones = (rsArqueoCaja.getString("valor_retenciones") != null)
                        ? rsArqueoCaja.getString("valor_retenciones")
                        : "0.00";

                valor_efectivo = (rsArqueoCaja.getString("valor_efectivo") != null)
                        ? rsArqueoCaja.getString("valor_efectivo")
                        : "0.00";
                total_caja = (rsArqueoCaja.getString("total") != null) ? rsArqueoCaja.getString("total")
                        : "0.00";
                diferencia = (rsArqueoCaja.getString("diferencia") != null)
                        ? rsArqueoCaja.getString("diferencia")
                        : "0.00";
                tipo_diferencia = (rsArqueoCaja.getString("tipo_diferencia") != null)
                        ? rsArqueoCaja.getString("tipo_diferencia")
                        : "";
                //anulado = (rsArqueoCaja.getString("anulado")!=null) ? rsArqueoCaja.getBoolean("anulado") : false;
                rsArqueoCaja.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    String sucursal = "";
    String empleado = "";
    try {
        ResultSet rs = objEmpleado.getCajero(cajero);
        if (rs.next()) {
            sucursal = rs.getString("sucursal") != null ? rs.getString("sucursal") : "";
            empleado = rs.getString("empleado") != null ? rs.getString("empleado") : "";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    /* inicio PDF */
    Document doc = new Document(PageSize.A4);// paso 1

    /* tambien establesco el alto del tope para la primera impresion de la factura */

    float ancho = PageSize.A4.getWidth();
    float alto = PageSize.A4.getHeight();

    try {
        PdfWriter writer = PdfWriter.getInstance(doc, response.getOutputStream()); // paso 2

        doc.open(); // paso 3

        // Para enviar a la impresora automticamente.

        writer.addJavaScript("this.print(false);", false);

        /* todo el cuerpo del doc es el paso 4 */

        PdfPTable tbl_titulo = new PdfPTable(1);
        tbl_titulo
                .addCell(Addons.setCeldaPDF(titulo, Font.HELVETICA, 14, Font.NORMAL, Element.ALIGN_CENTER, 0));
        tbl_titulo.addCell(Addons.setCeldaPDF("ARQUEO DE CAJA\n\n", Font.HELVETICA, 14, Font.BOLD,
                Element.ALIGN_CENTER, 0));
        tbl_titulo.addCell(Addons.setCeldaPDF("No.   " + num_documento + "\n", Font.HELVETICA, 12, Font.NORMAL,
                Element.ALIGN_RIGHT, 0));
        tbl_titulo.addCell(Addons.setCeldaPDF("Sucursal: " + sucursal, Font.HELVETICA, 10, Font.NORMAL,
                Element.ALIGN_LEFT, 0));
        tbl_titulo.addCell(Addons.setCeldaPDF("Usuario de caja: " + cajero, Font.HELVETICA, 10, Font.NORMAL,
                Element.ALIGN_LEFT, 0));
        tbl_titulo.addCell(Addons.setCeldaPDF("Responsable de caja: " + empleado, Font.HELVETICA, 10,
                Font.NORMAL, Element.ALIGN_LEFT, 0));
        doc.add(tbl_titulo);

        PdfPTable tbl_det = new PdfPTable(2);

        tbl_det.addCell(
                Addons.setCeldaPDF("Fecha: " + fecha, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));
        tbl_det.addCell(
                Addons.setCeldaPDF("Hora: " + hora, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));

        tbl_det.addCell(Addons.setFilaBlanco(3, 10));

        doc.add(tbl_det);

        /* efectivo */
        try {
            String denominacion = "";
            String cantidad = "";
            String total = "";
            ResultSet rsArqueoEfectivo = objArqueoCaja.getArqueoCajaEfectivo(id);
            if (objArqueoCaja.getFilas(rsArqueoEfectivo) > 0) {
                doc.add(Addons.setCabeceraTabla(new String[] { "DENOMINACION", "CANTIDAD", "TOTAL ($)" },
                        new float[] { 60f, 20f, 20f }));
                PdfPTable tbl_efectivo = new PdfPTable(new float[] { 60f, 20f, 20f });
                while (rsArqueoEfectivo.next()) {
                    denominacion = (rsArqueoEfectivo.getString("denominacion") != null)
                            ? rsArqueoEfectivo.getString("denominacion")
                            : "";
                    cantidad = (rsArqueoEfectivo.getString("cantidad") != null)
                            ? rsArqueoEfectivo.getString("cantidad")
                            : "";
                    total = (rsArqueoEfectivo.getString("total") != null) ? rsArqueoEfectivo.getString("total")
                            : "";
                    tbl_efectivo.addCell(Addons.setCeldaPDF(denominacion, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_efectivo.addCell(Addons.setCeldaPDF(cantidad, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_CENTER, 1));
                    tbl_efectivo.addCell(
                            Addons.setCeldaPDF(total, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                tbl_efectivo.addCell(Addons.setFilaBlanco(3, 10));
                doc.add(tbl_efectivo);
            }
            rsArqueoEfectivo.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        /* cheque */
        try {
            String efectivizado = "";
            String banco = "";
            String num_cheque = "";
            String valor = "";
            ResultSet rsArqueoCheque = objArqueoCaja.getArqueoCajaCheque(id);
            if (objArqueoCaja.getFilas(rsArqueoCheque) > 0) {
                doc.add(Addons.setCabeceraTabla(
                        new String[] { "BANCO", "Nro. CHEQUE", "VALOR ($)", "EFECTIVIZADO" },
                        new float[] { 60f, 30f, 20f, 15f }));
                PdfPTable tbl_cheque = new PdfPTable(new float[] { 60f, 30f, 20f, 15f });
                while (rsArqueoCheque.next()) {
                    efectivizado = (rsArqueoCheque.getString("efectivizado") != null)
                            ? rsArqueoCheque.getString("efectivizado")
                            : "";
                    banco = (rsArqueoCheque.getString("banco") != null) ? rsArqueoCheque.getString("banco")
                            : "";
                    num_cheque = (rsArqueoCheque.getString("num_cheque") != null)
                            ? rsArqueoCheque.getString("num_cheque")
                            : "";
                    valor = (rsArqueoCheque.getString("valor") != null) ? rsArqueoCheque.getString("valor")
                            : "";
                    tbl_cheque.addCell(
                            Addons.setCeldaPDF(banco, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_cheque.addCell(Addons.setCeldaPDF(num_cheque, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_cheque.addCell(
                            Addons.setCeldaPDF(valor, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                    tbl_cheque.addCell(Addons.setCeldaPDF(efectivizado, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_RIGHT, 1));
                }
                tbl_cheque.addCell(Addons.setFilaBlanco(4, 10));
                doc.add(tbl_cheque);
            }
            rsArqueoCheque.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        /* otros documentos */
        try {
            String num_comp_pago = "";
            String valor = "";
            ResultSet rsArqueoDocs = objArqueoCaja.getArqueoCajaOtros(id);
            if (objArqueoCaja.getFilas(rsArqueoDocs) > 0) {
                doc.add(Addons.setCabeceraTabla(new String[] { "Nro. COMP. PAGO", "VALOR ($)" },
                        new float[] { 70f, 30f }));
                PdfPTable tbl_otros = new PdfPTable(new float[] { 70f, 30f });
                while (rsArqueoDocs.next()) {
                    num_comp_pago = (rsArqueoDocs.getString("num_comp_pago") != null)
                            ? rsArqueoDocs.getString("num_comp_pago")
                            : "";
                    valor = (rsArqueoDocs.getString("valor") != null) ? rsArqueoDocs.getString("valor") : "0";
                    tbl_otros.addCell(Addons.setCeldaPDF(num_comp_pago, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_otros.addCell(
                            Addons.setCeldaPDF(valor, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                tbl_otros.addCell(Addons.setFilaBlanco(3, 10));
                doc.add(tbl_otros);
            }
            rsArqueoDocs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        /* retenciones */
        try {
            String num_retencion = "";
            String valor_retencion = "";
            ResultSet rsArqueoRets = objArqueoCaja.getArqueoCajaRetenciones(id);
            if (objArqueoCaja.getFilas(rsArqueoRets) > 0) {
                doc.add(Addons.setCabeceraTabla(new String[] { "Nro. RETENCION", "VALOR ($)" },
                        new float[] { 70f, 30f }));
                PdfPTable tbl_otros = new PdfPTable(new float[] { 70f, 30f });
                while (rsArqueoRets.next()) {
                    num_retencion = (rsArqueoRets.getString("num_retencion") != null)
                            ? rsArqueoRets.getString("num_retencion")
                            : "";
                    valor_retencion = (rsArqueoRets.getString("valor_retencion") != null)
                            ? rsArqueoRets.getString("valor_retencion")
                            : "0";
                    tbl_otros.addCell(Addons.setCeldaPDF(num_retencion, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_otros.addCell(Addons.setCeldaPDF(valor_retencion, Font.HELVETICA, 8, Font.NORMAL,
                            Element.ALIGN_RIGHT, 1));
                }
                tbl_otros.addCell(Addons.setFilaBlanco(3, 10));
                doc.add(tbl_otros);
            }
            rsArqueoRets.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        PdfPTable tbl_totales = new PdfPTable(new float[] { 60f, 40f });
        tbl_totales.addCell(Addons.setFilaBlanco(3, 5));

        tbl_totales.addCell(Addons.setCeldaPDF("Saldo en caja actual:", Font.HELVETICA, 8, Font.NORMAL,
                Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(saldo_caja, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(Addons.setCeldaPDF("Total monedas y billetes:", Font.HELVETICA, 8, Font.NORMAL,
                Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(valor_efectivo, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(Addons.setCeldaPDF("Total cheques (" + num_cheques + "):", Font.HELVETICA, 8,
                Font.NORMAL, Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(valor_cheques, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(Addons.setCeldaPDF("Total comprobantes de pago (" + num_comp_pagos + "):",
                Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(valor_comp_pagos, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(Addons.setCeldaPDF("Total retenciones (" + num_retenciones + "):", Font.HELVETICA,
                8, Font.NORMAL, Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(valor_retenciones, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(
                Addons.setCeldaPDF("Total en caja:", Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(total_caja, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        tbl_totales.addCell(Addons.setCeldaPDF(
                "Diferencia:        " + (tipo_diferencia.compareTo("f") == 0 ? "faltante"
                        : (tipo_diferencia.compareTo("s") == 0 ? "sobrante" : "")),
                Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
        tbl_totales.addCell(
                Addons.setCeldaPDF(diferencia, Font.HELVETICA, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

        doc.add(tbl_totales);

        doc.add(new Paragraph(" "));
        doc.add(new Paragraph(" "));
        doc.add(new Paragraph(" "));

        PdfPTable tbl_firmas = new PdfPTable(3);
        tbl_firmas.addCell(
                Addons.setCeldaPDF("RESPONSABLE", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0));
        tbl_firmas.addCell(
                Addons.setCeldaPDF("VERIFICADO", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0));
        tbl_firmas.addCell(
                Addons.setCeldaPDF("AUTORIZADO", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0));
        doc.add(tbl_firmas);

    } catch (IllegalStateException ie) {
        ie.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    } finally {
        objEmpleado.cerrar();
        objArqueoCaja.cerrar();
    }

    doc.close(); // paso 5
    /* fin PDF */
}