Example usage for com.itextpdf.text.pdf BaseFont createFont

List of usage examples for com.itextpdf.text.pdf BaseFont createFont

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BaseFont createFont.

Prototype

public static BaseFont createFont(String name, String encoding, boolean embedded)
        throws DocumentException, IOException 

Source Link

Document

Creates a new font.

Usage

From source file:Almacen.Reporte2.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//from   w w  w .j  a v  a  2  s  .co  m
    if (t_datos1.getRowCount() > 0) {
        javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser();
        jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.pdf)", new String[] { "pdf" }));
        String ruta = null;
        if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) {
            ruta = jF1.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                Session session = HibernateUtil.getSessionFactory().openSession();
                try {
                    DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
                    formatoPorcentaje.setMinimumFractionDigits(2);
                    session.beginTransaction().begin();
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);
                    //Orden ord=buscaApertura();
                    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);

                    reporte.Abrir2(PageSize.LETTER, "reporte almacen", ruta + ".pdf");
                    Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = Element.ALIGN_CENTER;
                    int izquierda = Element.ALIGN_LEFT;
                    int derecha = Element.ALIGN_RIGHT;
                    float[] nuevos = new float[] { 20, 150, 20, 100, 70, 20, 60 };

                    PdfPTable tabla = reporte.crearTabla(nuevos.length, nuevos, 100, Element.ALIGN_LEFT);

                    cabecera(reporte, bf, tabla, "Reporte de material a " + cb_tipo.getSelectedItem().toString()
                            + " orden: " + t_busca.getText(), 2);
                    for (int ren = 0; ren < t_datos1.getRowCount(); ren++) {
                        for (int col = 0; col < t_datos1.getColumnCount(); col++) {
                            try {
                                tabla.addCell(reporte.celda(t_datos1.getValueAt(ren, col).toString(), font,
                                        contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                            } catch (Exception e) {
                                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1,
                                        Rectangle.RECTANGLE));
                            }
                        }
                    }
                    tabla.setHeaderRows(1);
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    System.out.println(e);
                    e.printStackTrace();
                    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:Almacen.Reporte2.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);// w  w  w .  j  a  v a2s  . co m
    if (t_datos.getRowCount() > 0) {
        javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser();
        jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.pdf)", new String[] { "pdf" }));
        String ruta = null;
        if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) {
            ruta = jF1.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                Session session = HibernateUtil.getSessionFactory().openSession();
                try {
                    DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
                    formatoPorcentaje.setMinimumFractionDigits(2);
                    session.beginTransaction().begin();
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);
                    //Orden ord=buscaApertura();
                    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);

                    reporte.Abrir2(PageSize.LETTER, "reporte almacen", ruta + ".pdf");
                    Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = Element.ALIGN_CENTER;
                    int izquierda = Element.ALIGN_LEFT;
                    int derecha = Element.ALIGN_RIGHT;
                    float[] nuevos = new float[] { 36, 140, 86, 36, 40, 45, 37, 50, 42, 60 };

                    PdfPTable tabla = reporte.crearTabla(nuevos.length, nuevos, 100, Element.ALIGN_LEFT);

                    cabecera(reporte, bf, tabla, "Reporte de movimientos de pedidos en almacen", 1);
                    for (int ren = 0; ren < t_datos.getRowCount(); ren++) {
                        for (int col = 0; col < t_datos.getColumnCount(); col++) {
                            try {
                                if (col == 7)
                                    tabla.addCell(reporte.celda(
                                            formatoPorcentaje.format(t_datos.getValueAt(ren, col)), font,
                                            contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                else
                                    tabla.addCell(reporte.celda(t_datos.getValueAt(ren, col).toString(), font,
                                            contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                            } catch (Exception e) {
                                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1,
                                        Rectangle.RECTANGLE));
                            }
                        }
                    }
                    tabla.setHeaderRows(1);
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    System.out.println(e);
                    e.printStackTrace();
                    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:Almacen.Reporte2.java

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*www.  j  av a2s . c o m*/
    if (t_datos2.getRowCount() > 0) {
        javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser();
        jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.pdf)", new String[] { "pdf" }));
        String ruta = null;
        if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) {
            ruta = jF1.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                Session session = HibernateUtil.getSessionFactory().openSession();
                try {
                    session.beginTransaction().begin();
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);

                    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);

                    reporte.Abrir2(PageSize.LETTER, "reporte pedidos", ruta + ".pdf");
                    Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = Element.ALIGN_CENTER;
                    int izquierda = Element.ALIGN_LEFT;
                    int derecha = Element.ALIGN_RIGHT;
                    float[] nuevos = new float[] { 60, 340, 170, 60, 90, 90, 90 };

                    PdfPTable tabla = reporte.crearTabla(nuevos.length, nuevos, 100, Element.ALIGN_CENTER);
                    cabecera1(reporte, bf, tabla, "Reporte de Consultar Pedidos.", 1);
                    for (int ren = 0; ren < t_datos2.getRowCount(); ren++) {
                        for (int col = 0; col < t_datos2.getColumnCount(); col++) {
                            try {
                                tabla.addCell(reporte.celda(t_datos2.getValueAt(ren, col).toString(), font,
                                        contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                            } catch (Exception e) {
                                tabla.addCell(
                                        reporte.celda("", font, contenido, centro, 0, 1, Rectangle.RECTANGLE));
                            }
                        }
                    }
                    tabla.setHeaderRows(1);
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    System.out.println(e);
                    e.printStackTrace();
                    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:Almacen.Responsiva.java

private void b_imprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_imprimirActionPerformed
    // TODO add your handling code here:
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from   ww w . j av a  2s  . c o  m*/
        String empleado = "";
        String puesto = "";
        if (t_datos.getRowCount() > 0) {
            //consulta
            Query q = session.createSQLQuery(
                    "select empleado.nombre as empleado, puestos.nombre as puesto from empleado inner join puestos on puestos.id_puestos=empleado.id_puesto where empleado.id_empleado="
                            + t_id_empleado.getText() + ";");
            q.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
            List lista = q.list();

            for (int i = 0; i < lista.size(); i++) {
                java.util.HashMap map = (java.util.HashMap) lista.get(i);
                empleado = (String) map.get("empleado");
                puesto = (String) map.get("puesto");
            }

            Date fecha = new Date();
            DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
            String Mes[] = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto",
                    "Septiembre", "Octubre", "Noviembre", "Diciembre" };
            Calendar fecha1 = new GregorianCalendar();
            int anio = fecha1.get(Calendar.YEAR);
            int mes = fecha1.get(Calendar.MONTH);
            int dia = fecha1.get(Calendar.DAY_OF_MONTH);
            //DateFormat dateFormat1 = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS
            String valor = dateFormat.format(fecha);
            File folder = new File("reportes/Responsivas");
            folder.mkdirs();
            PdfReader reader = new PdfReader("imagenes/CartaResponsiva.pdf");
            PdfStamper stamp = new PdfStamper(reader,
                    new FileOutputStream("reportes/Responsivas/" + valor + "CartaResponsiva.pdf"));
            PdfContentByte cb = stamp.getUnderContent(1);
            PdfContentByte cb2 = stamp.getUnderContent(2);
            AcroFields fdfDoc = stamp.getAcroFields();
            // Creo una fuente
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);

            cb.beginText();
            //dia
            try {
                if (dia < 9)
                    fdfDoc.setField("Dia", "0" + String.valueOf(dia));
                else
                    fdfDoc.setField("Dia", String.valueOf(dia));
            } catch (Exception e) {
                fdfDoc.setField("Dia", "error");
            }
            //mes
            try {
                fdfDoc.setField("Mes", Mes[mes]);
            } catch (Exception e) {
                fdfDoc.setField("Mes", "");
            }
            //ao
            try {
                fdfDoc.setField("Anio", String.valueOf(anio));
            } catch (Exception e) {
                fdfDoc.setField("Anio", "");
            }
            //nombre
            try {
                fdfDoc.setField("Nombre", empleado);
            } catch (Exception e) {
                fdfDoc.setField("Nombre", "");
            }
            //puesto
            try {
                fdfDoc.setField("Puesto", puesto);
            } catch (Exception e) {
                fdfDoc.setField("Puesto", "");
            }

            //tabla de herramientas
            float tam[] = new float[] { 250, 50, 180 };
            Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD);
            PDF reporte = new PDF();
            PdfPTable tabla = reporte.crearTabla(3, tam, 100, Element.ALIGN_LEFT);
            tabla.setTotalWidth(tam);
            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("HERRAMIENTA", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("CANTIDAD", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("NOTAS", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));

            for (int i = 0; i < t_datos.getRowCount(); i++) {
                tabla.addCell(reporte.celda(t_datos.getValueAt(i, 1).toString(), font, contenido, izquierda, 0,
                        1, Rectangle.RECTANGLE));

                tabla.addCell(reporte.celda(String.valueOf((double) t_datos.getValueAt(i, 2)), font, contenido,
                        centro, 0, 1, Rectangle.RECTANGLE));
                if (t_datos.getValueAt(i, 3) != null)
                    tabla.addCell(reporte.celda(t_datos.getValueAt(i, 3).toString(), font, contenido, izquierda,
                            0, 1, Rectangle.RECTANGLE));
                else
                    tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            }

            tabla.completeRow();
            tabla.writeSelectedRows(0, -1, 70, 720, cb2);
            cb.endText();
            stamp.close();
            reporte.cerrar();
            reporte.visualizar("reportes/Responsivas/" + valor + "CartaResponsiva.pdf");
        } else {
            JOptionPane.showMessageDialog(this, "No Existe Ninguna Responsiva");
        }
    } 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:avalonscrollmaker20.AnothakScribe.java

License:Open Source License

private void makeFonts() {
    try {/*from  ww  w  . j a va  2 s. com*/
        String fontURL = this.getClass().getResource("resources/Avalon - Lierseth.ttf").toString();
        BaseFont bf = BaseFont.createFont(fontURL, "", BaseFont.EMBEDDED);
        f_phraseSymbol = new Font(bf, 70);
        f_phraseSymbolBreath = new Font(bf, 55);

        fontURL = this.getClass().getResource("resources/HARNGTON.TTF").toString();
        bf = BaseFont.createFont(fontURL, "", BaseFont.EMBEDDED);
        f_phraseCommon = new Font(bf, 25);
        f_phraseCommonBreath = new Font(bf, 15);

        fontURL = this.getClass().getResource("resources/ENDOR___.ttf").toString();
        bf = BaseFont.createFont(fontURL, "", BaseFont.EMBEDDED);
        f_school = new Font(bf, 30);
        f_schoolPure = new Font(bf, 25);

        fontURL = this.getClass().getResource("resources/neverworld.ttf").toString();
        bf = BaseFont.createFont(fontURL, "", BaseFont.EMBEDDED);
        f_title = new Font(bf, 40);
        //f_titlePhrase = new Font( bf, 10 );
        f_code = new Font(bf, 50);
        f_code.setColor(new BaseColor(128, 128, 128, 16));

        fontURL = this.getClass().getResource("resources/evanescent.ttf").toString();
        bf = BaseFont.createFont(fontURL, "", BaseFont.EMBEDDED);
        f_keu = new Font(bf, 40);
    } catch (Exception ex) {
        System.err.println(ex + "\nProgram closing.");
        System.exit(2);
    }
}

From source file:book.pdfabc.chapter05.C0505_SupportedEncoding.java

public static void main(String[] args) throws DocumentException, IOException {
    C0505_SupportedEncoding app = new C0505_SupportedEncoding();
    app.listEncodings(BaseFont.createFont(BaseFont.COURIER, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED));
    app.listEncodings(BaseFont.createFont(TYPE1, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED));
    app.listEncodings(BaseFont.createFont(OT_T1, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED));
    app.listEncodings(BaseFont.createFont(OT_TT, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED));
}

From source file:bouttime.report.boutsheet.BoutSheetReport.java

License:Open Source License

/**
 * Generate a bout sheet report that has no data in it (only the image).
 * The length is the given number of pages.
 * //w  w  w .  ja v a2 s.c o m
 * @param numPages
 * @return True if the report was generated.
 */
public boolean generateBlank(Dao dao, Integer numPages) {
    // step 1: creation of a document-object
    // rotate to make page landscape
    Document document = new Document(PageSize.A4.rotate());

    try {

        // step 2: creation of the writer
        FileOutputStream fos = createOutputFile();
        if (fos == null) {
            return false;
        }
        PdfWriter writer = PdfWriter.getInstance(document, fos);
        writer.setPageEvent(this);

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
        float pageWidth = cb.getPdfDocument().getPageSize().getWidth();
        float midPage = pageWidth / 2;

        setHeaderString(dao);

        int count = 1;
        while (true) {
            drawBout(cb, bf, 35, midPage - 35, null);
            drawBout(cb, bf, midPage + 35, pageWidth - 35, null);

            if (++count > numPages) {
                break;
            }

            document.newPage();
        }

    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}

From source file:bouttime.report.boutsheet.BoutSheetReport.java

License:Open Source License

/**
 * Generate a bout sheet report for the given list of bouts.
 * It is assumed that the list is in the desired order (no sorting is done here).
 *
 * @param list/*  w  w w.  j ava 2 s. com*/
 * @return True if the report was generated.
 */
public boolean generateReport(Dao dao, List<Bout> list) {

    // step 1: creation of a document-object
    // rotate to make page landscape
    Document document = new Document(PageSize.A4.rotate());

    try {

        // step 2: creation of the writer
        FileOutputStream fos = createOutputFile();
        if (fos == null) {
            return false;
        }
        PdfWriter writer = PdfWriter.getInstance(document, fos);
        writer.setPageEvent(this);

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED);
        float pageWidth = cb.getPdfDocument().getPageSize().getWidth();
        float midPage = pageWidth / 2;

        setHeaderString(dao);

        int count = 0;
        for (Bout b : list) {
            boolean rightSide = false;
            if ((count++ % 2) == 0) {
                if (count > 2) {
                    // We could put this after Bout 2 is added, but
                    // that could leave a blank last page.
                    document.newPage();
                }

                // Bout 1 (Left side)
                drawBout(cb, bf, 35, midPage - 35, b);
            } else {
                // Bout 2 (Right side)
                drawBout(cb, bf, midPage + 35, pageWidth - 35, b);
                rightSide = true;
            }

            // Print the watermark, if necessary
            boolean doWatermark = false;
            String gClass = b.getGroup().getClassification();
            String wmValues = dao.getBoutsheetWatermarkValues();
            if ((wmValues != null) && !wmValues.isEmpty()) {
                String[] tokens = wmValues.split(",");
                for (String s : tokens) {
                    if (s.trim().equalsIgnoreCase(gClass)) {
                        doWatermark = true;
                        break;
                    }
                }
            }
            if (doWatermark) {
                int rotation = 45;
                PdfContentByte ucb = writer.getDirectContentUnder();
                BaseFont helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
                ucb.saveState();
                ucb.setColorFill(BaseColor.LIGHT_GRAY);
                ucb.beginText();
                ucb.setFontAndSize(helv, 86);
                float centerWidth = document.getPageSize().getWidth() / 4;
                if (rightSide) {
                    centerWidth = centerWidth * 3;
                }
                ucb.showTextAligned(Element.ALIGN_CENTER, gClass, centerWidth,
                        document.getPageSize().getHeight() / 2, rotation);
                ucb.endText();
                ucb.restoreState();
            }
        }

    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}

From source file:bouttime.report.boutsheet.BoutSheetReport.java

License:Open Source License

/**
 * Set the string for the page header.//  ww  w.  ja  v a 2 s  .co  m
 * @param dao Dao object to use to retrieve data.
 */
private void setHeaderString(Dao dao) {
    try {
        this.baseFont = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
        this.headerString = String.format("%s    %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(),
                dao.getYear());
    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        this.headerString = null;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        this.headerString = null;
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetReport.java

License:Open Source License

public static boolean generateReport(Dao dao, List<Group> list, String outputFile, boolean doBoutNumbers,
        boolean doTimestamp) {

    if (list.isEmpty()) {
        return false;
    }/*from   ww  w. j a v a2s.co  m*/

    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        FileOutputStream fos = createOutputFile(outputFile);
        if (fos == null) {
            return false;
        }
        PdfWriter writer = PdfWriter.getInstance(document, fos);

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        String timestamp = "";
        if (doTimestamp) {
            timestamp = DateFormat.getInstance().format(new Date());
        }

        int rv;
        int i = 0;
        int size = list.size();
        for (Group g : list) {
            rv = addBracket(cb, dao, g, doBoutNumbers);
            if (rv != PAGE_ERROR) {
                // Print the watermark, if necessary
                boolean doWatermark = false;
                String gClass = g.getClassification();
                String wmValues = dao.getBracketsheetWatermarkValues();
                if ((wmValues != null) && !wmValues.isEmpty()) {
                    String[] tokens = wmValues.split(",");
                    for (String s : tokens) {
                        if (s.trim().equalsIgnoreCase(gClass)) {
                            doWatermark = true;
                            break;
                        }
                    }
                }

                int rotation = (rv == PAGE_ROUNDROBIN) ? 45 : 135;

                if (doWatermark) {
                    PdfContentByte ucb = writer.getDirectContentUnder();
                    BaseFont helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
                    ucb.saveState();
                    ucb.setColorFill(BaseColor.LIGHT_GRAY);
                    ucb.beginText();
                    ucb.setFontAndSize(helv, 86);
                    ucb.showTextAligned(Element.ALIGN_CENTER, gClass, document.getPageSize().getWidth() / 2,
                            document.getPageSize().getHeight() / 2, rotation);
                    ucb.endText();
                    ucb.restoreState();
                }

                if (doTimestamp) {
                    rotation -= 45;
                    float width = cb.getPdfWriter().getPageSize().getWidth();
                    int x = (rv == PAGE_ROUNDROBIN) ? 15 : (int) (width - 15);
                    int y = 15;
                    BracketSheetUtil.drawTimestamp(cb, null, x, y, 10, timestamp, rotation);
                }

                // If not doing bout numbers, this is an 'award' type of
                // bracket.  So print an image/logo, if configured.
                if (!doBoutNumbers && (dao.getBracketsheetAwardImage() != null)
                        && !dao.getBracketsheetAwardImage().isEmpty()) {
                    Image image = Image.getInstance(Image.getInstance(dao.getBracketsheetAwardImage()));
                    image.setRotationDegrees((rv == PAGE_ROUNDROBIN) ? 0 : 90);
                    PositionOnPage positionOnPage = dao.getBracketsheetAwardImagePosition();
                    if (PositionOnPage.UPPER_RIGHT == positionOnPage) {
                        float x = (rv == PAGE_ROUNDROBIN)
                                ? document.getPageSize().getWidth() - 10 - image.getWidth()
                                : 10;
                        float y = document.getPageSize().getHeight() - 10 - image.getHeight();
                        image.setAbsolutePosition(x, y);
                        cb.addImage(image);
                    } else if (PositionOnPage.CENTER == positionOnPage) {
                        // put the image in the background, in the middle of the page
                        PdfContentByte ucb = writer.getDirectContentUnder();
                        float pageX = document.getPageSize().getWidth() / 2;
                        float pageY = document.getPageSize().getHeight() / 2;
                        float imageX = image.getWidth() / 2;
                        float imageY = image.getHeight() / 2;
                        image.setAbsolutePosition(pageX - imageX, pageY - imageY);
                        ucb.addImage(image);
                    }
                }

                if (++i < size) {
                    document.newPage();
                }
            }
        }

    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}