Example usage for com.itextpdf.text Font NORMAL

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

Introduction

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

Prototype

int NORMAL

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

Click Source Link

Document

this is a possible style.

Usage

From source file:pkgAgenda_Virtual.frmActividades.java

public void PDFdeestudio() throws SQLException {
    Document documento = new Document();
    FileOutputStream FacturaPdf;/*  www. j  a v  a  2  s .  co  m*/

    try {
        FacturaPdf = new FileOutputStream("archives/ActividadesdeEstudio.pdf");

        PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf);
        com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788);
        writer.setBoxSize("art", rct);
        HeaderFooter event = new HeaderFooter();
        writer.setPageEvent(event);

    } catch (DocumentException | FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

    try {
        Calendar fecha = Calendar.getInstance();
        documento.open();
        com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png");
        imagen.setAbsolutePosition(0f, 0f);
        documento.add(imagen);
        Paragraph AV = new Paragraph("Agenda Virtual",
                FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK));
        AV.setAlignment(Element.ALIGN_RIGHT);
        documento.add(AV);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph("Actividades de Estudio de " + frmLogin.usuario));
        documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/"
                + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + "  "
                + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE)));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));

        PdfPTable tblHoy = new PdfPTable(4);
        PdfPTable tblAntes = new PdfPTable(4);
        PdfPTable tblDespues = new PdfPTable(4);
        tblHoy.addCell("Asignatura");
        tblHoy.addCell("Tarea");
        tblHoy.addCell("Fecha");
        tblHoy.addCell("Hora");
        tblAntes.addCell("Asignatura");
        tblAntes.addCell("Tarea");
        tblAntes.addCell("Fecha");
        tblAntes.addCell("Hora");
        tblDespues.addCell("Asignatura");
        tblDespues.addCell("Tarea");
        tblDespues.addCell("Fecha");
        tblDespues.addCell("Hora");

        //sdfhfjhsdfsd
        int valor;

        rs = H.Buscar("SELECT nom_act, des_act, fecha_act, hora_act FROM Actividades WHERE cod_usu = "
                + H.Usuario + " AND id_tipoact = 1");
        while (rs.next()) {
            String fecharecibida = rs.getString(3).substring(0, 10);
            valor = H.FechaAnterior(fecharecibida);
            if (valor == 2) {
                tblHoy.addCell(H.desencriptar(rs.getString(1)));
                tblHoy.addCell(H.desencriptar(rs.getString(2)));
                tblHoy.addCell(fecharecibida);
                tblHoy.addCell(rs.getString(4).substring(0, 5));
            } else if (valor == 1) {
                tblAntes.addCell(H.desencriptar(rs.getString(1)));
                tblAntes.addCell(H.desencriptar(rs.getString(2)));
                tblAntes.addCell(fecharecibida);
                tblAntes.addCell(rs.getString(4).substring(0, 5));
            } else if (valor == 0) {
                tblDespues.addCell(H.desencriptar(rs.getString(1)));
                tblDespues.addCell(H.desencriptar(rs.getString(2)));
                tblDespues.addCell(fecharecibida);
                tblDespues.addCell(rs.getString(4).substring(0, 5));
            }
        }

        //askjdhskfjhdf
        documento.add(new Paragraph("Actividades Pasadas"));
        documento.add(new Paragraph(" "));
        documento.add(tblAntes);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph("Actividades de Hoy"));
        documento.add(new Paragraph(" "));
        documento.add(tblHoy);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph("Actividades Futuras"));
        documento.add(new Paragraph(" "));
        documento.add(tblDespues);
        documento.add(new Paragraph(" "));
        documento.add(P);
        documento.close();
    } catch (DocumentException | IOException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

}

From source file:pkgAgenda_Virtual.frmAgenda.java

public void PDF() throws SQLException {
    Document documento = new Document();
    FileOutputStream FacturaPdf;//from   ww w  .java  2  s  .  c  om

    try {
        FacturaPdf = new FileOutputStream("archives/Notas.pdf");

        PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf);
        com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788);
        writer.setBoxSize("art", rct);
        HeaderFooter event = new HeaderFooter();
        writer.setPageEvent(event);

    } catch (DocumentException | FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

    try {
        Calendar fecha = Calendar.getInstance();
        documento.open();
        com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png");
        imagen.setAbsolutePosition(0f, 0f);
        documento.add(imagen);
        Paragraph AV = new Paragraph("Agenda Virtual",
                FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK));
        AV.setAlignment(Element.ALIGN_RIGHT);
        documento.add(AV);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph("Notas de " + frmLogin.usuario));
        documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/"
                + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + "  "
                + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE)));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        PdfPTable tabla = new PdfPTable(2);
        tabla.addCell("Titulo");
        tabla.addCell("Descripcion");

        //sdfhfjhsdfsd

        rs = H.Buscar(
                "SELECT nom_nota, des_nota FROM Notas WHERE cod_usu = " + H.Usuario + " ORDER BY nom_nota ASC");
        while (rs.next()) {
            tabla.addCell(rs.getString(1));
            tabla.addCell(rs.getString(2));
        }

        //askjdhskfjhdf
        documento.add(tabla);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(P);
        documento.close();
    } catch (DocumentException | IOException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

}

From source file:pkgAgenda_Virtual.frmVerContactos.java

public void PDF() throws SQLException {
    Document documento = new Document();
    FileOutputStream FacturaPdf;/*from w  w w  . j av a 2 s  .co  m*/

    try {
        FacturaPdf = new FileOutputStream("archives/Contactos.pdf");

        PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf);
        com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788);
        writer.setBoxSize("art", rct);
        HeaderFooter event = new HeaderFooter();
        writer.setPageEvent(event);

    } catch (DocumentException | FileNotFoundException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

    try {
        Calendar fecha = Calendar.getInstance();
        documento.open();
        com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png");
        imagen.setAbsolutePosition(0f, 0f);
        documento.add(imagen);
        Paragraph AV = new Paragraph("Agenda Virtual",
                FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK));
        AV.setAlignment(Element.ALIGN_RIGHT);
        documento.add(AV);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph("Contactos de " + frmLogin.usuario));
        documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/"
                + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + "  "
                + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE)));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        PdfPTable tabla = new PdfPTable(4);
        tabla.addCell("Apellidos");
        tabla.addCell("Nombres");
        tabla.addCell("Telefono");
        tabla.addCell("Correo");

        //sdfhfjhsdfsd
        rs = H.Buscar("SELECT ape_contacto FROM Contactos WHERE cod_usu = " + H.Usuario + "");
        while (rs.next()) {
            cantidad_contactos += 1;
        }
        contactosdesordenados = new String[cantidad_contactos];
        rs = H.Buscar("SELECT ape_contacto FROM Contactos WHERE cod_usu = " + H.Usuario + "");
        while (rs.next()) {
            contactosdesordenados[num_contacto] = H.desencriptar(rs.getString(1));
            num_contacto += 1;
        }
        contactosordenados = new String[cantidad_contactos];
        Arrays.sort(contactosdesordenados);
        contactosordenados = contactosdesordenados;
        for (int i = 0; i < contactosordenados.length; i++) {
            if (!"".equals(contactosordenados[i].toString())) {
                rs = H.Buscar(
                        "SELECT ape_contacto, nom_contacto, tel1_contacto, correo_contacto FROM Contactos WHERE ape_contacto = '"
                                + H.encriptar(contactosordenados[i].toString()) + "'");
                while (rs.next()) {
                    tabla.addCell(H.desencriptar(rs.getString(1)));
                    tabla.addCell(H.desencriptar(rs.getString(2)));
                    tabla.addCell(rs.getString(3));
                    tabla.addCell(H.desencriptar(rs.getString(4)));
                }
            }
        }

        //askjdhskfjhdf
        documento.add(tabla);
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(new Paragraph(" "));
        documento.add(P);
        documento.close();
    } catch (DocumentException | IOException ex) {
        JOptionPane.showMessageDialog(null, ex.toString());
    }

}

From source file:presentation.frmReportForm.java

private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed
    Date dateNow = new Date();
    SimpleDateFormat df = new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss");

    System.out.println(dtcMonthChooser.getMonth());
    System.out.println(dtcYearChooser.getYear());

    if (radInMonth.isSelected()) {
        List<Transfer> transferList = new ArrayList<>();

        transferList = empObj.searchRecordByMonth(dtcMonthChooser.getMonth() + 1, dtcYearChooser.getYear());

        Document document = new Document();
        try {// w ww . j a  v a  2  s.c  o  m
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph(
                    "Transfer records at " + (dtcMonthChooser.getMonth() + 1) + "/" + dtcYearChooser.getYear(),
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);

            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    if (radInDateRange.isSelected()) {
        try {
            List<Transfer> transferList = new ArrayList<>();

            java.sql.Date fromDateSql = formatDateForSearching(dtcFromDate.getDate());
            java.sql.Date toDateSql = formatDateForSearching(dtcToDate.getDate());
            transferList = empObj.searchRecordByDate(fromDateSql, toDateSql);

            Document document = new Document();
            try {
                Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

                String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
                PdfWriter.getInstance(document, new FileOutputStream(fileName));

                document.open();

                Image imageLogo = Image
                        .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
                imageLogo.setAbsolutePosition(20, 750f);
                document.add(imageLogo);

                Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
                titlePara.setAlignment(Element.ALIGN_CENTER);
                titlePara.setSpacingAfter(5);
                document.add(titlePara);

                Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                        FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
                creditPara.setAlignment(Element.ALIGN_CENTER);
                creditPara.setSpacingAfter(10);
                document.add(creditPara);

                SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yyyy");
                String fromDate = df2.format(dtcFromDate.getDate());
                String toDate = df2.format(dtcToDate.getDate());

                Paragraph slashPara = new Paragraph("Transfer records from " + fromDate + " to " + toDate,
                        FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
                slashPara.setSpacingAfter(40);
                slashPara.setAlignment(Element.ALIGN_CENTER);
                document.add(slashPara);

                PdfPTable table = new PdfPTable(5);
                table.setWidthPercentage(100);

                Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
                Paragraph paragraphCellHeading = new Paragraph("Report", font);

                PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
                BaseColor myColor = WebColors.getRGBColor("#41a5c2");
                cellHeading.setColspan(5);
                cellHeading.setBackgroundColor(myColor);
                cellHeading.setFixedHeight(30.3f);
                cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellHeading);

                Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

                PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
                cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle1);
                PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
                cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle2);
                PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
                cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle3);
                PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
                cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitle4);
                PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
                cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cellTitleStatus);

                int cellColorCheck = 1;
                for (Transfer e : transferList) {
                    PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                    PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                    PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                    PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                    PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                    if (cellColorCheck % 2 == 1) {
                        cellBody1.setBackgroundColor(BaseColor.ORANGE);
                        cellBody2.setBackgroundColor(BaseColor.ORANGE);
                        cellBody3.setBackgroundColor(BaseColor.ORANGE);
                        cellBody4.setBackgroundColor(BaseColor.ORANGE);
                        cellBody5.setBackgroundColor(BaseColor.ORANGE);
                    }
                    table.addCell(cellBody1);
                    table.addCell(cellBody2);
                    table.addCell(cellBody3);
                    table.addCell(cellBody4);
                    table.addCell(cellBody5);
                    cellColorCheck++;
                }

                document.add(table);
                JOptionPane.showMessageDialog(this, "Report saved");

                if (Desktop.isDesktopSupported()) {
                    File reportFile = new File(fileName);
                    Desktop.getDesktop().open(reportFile);
                    ;
                }

                document.close();
            } catch (DocumentException | FileNotFoundException ex) {
                Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ParseException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    if (radInProject.isSelected()) {
        String fromProjectId = (String) cbxFromProject.getSelectedItem();
        String toProjectId = (String) cbxToProject.getSelectedItem();
        List<Transfer> transferList = new ArrayList<>();
        String andOr = "";
        if (cbxAndOr.getSelectedItem().equals("And")) {
            andOr = "and";
            transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr);
        } else {
            andOr = "or";
            transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr);
        }

        Document document = new Document();
        try {
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph(
                    "Transfer records from Project ID " + fromProjectId + " " + andOr + " " + toProjectId,
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);
            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (radAllRecord.isSelected()) {
        List<Transfer> transferList = new ArrayList<>();
        transferList = empObj.searchAllRecord();

        Document document = new Document();
        try {
            Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD);

            String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf";
            PdfWriter.getInstance(document, new FileOutputStream(fileName));

            document.open();

            Image imageLogo = Image
                    .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png"));
            imageLogo.setAbsolutePosition(20, 750f);
            document.add(imageLogo);

            Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle);
            titlePara.setAlignment(Element.ALIGN_CENTER);
            titlePara.setSpacingAfter(5);
            document.add(titlePara);

            Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh",
                    FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC));
            creditPara.setAlignment(Element.ALIGN_CENTER);
            creditPara.setSpacingAfter(10);
            document.add(creditPara);

            Paragraph slashPara = new Paragraph("All transfer records",
                    FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD));
            slashPara.setSpacingAfter(40);
            slashPara.setAlignment(Element.ALIGN_CENTER);
            document.add(slashPara);

            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);

            Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD);
            Paragraph paragraphCellHeading = new Paragraph("Report", font);

            PdfPCell cellHeading = new PdfPCell(paragraphCellHeading);
            BaseColor myColor = WebColors.getRGBColor("#41a5c2");
            cellHeading.setColspan(5);
            cellHeading.setBackgroundColor(myColor);
            cellHeading.setFixedHeight(30.3f);
            cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellHeading);

            Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK);

            PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody));
            cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle1);
            PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody));
            cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle2);
            PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody));
            cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle3);
            PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody));
            cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitle4);
            PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody));
            cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellTitleStatus);

            int cellColorCheck = 1;
            for (Transfer e : transferList) {
                PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId()));
                PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId()));
                PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId()));
                PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId()));
                PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus()));
                if (cellColorCheck % 2 == 1) {
                    cellBody1.setBackgroundColor(BaseColor.ORANGE);
                    cellBody2.setBackgroundColor(BaseColor.ORANGE);
                    cellBody3.setBackgroundColor(BaseColor.ORANGE);
                    cellBody4.setBackgroundColor(BaseColor.ORANGE);
                    cellBody5.setBackgroundColor(BaseColor.ORANGE);
                }
                table.addCell(cellBody1);
                table.addCell(cellBody2);
                table.addCell(cellBody3);
                table.addCell(cellBody4);
                table.addCell(cellBody5);
                cellColorCheck++;
            }

            document.add(table);
            JOptionPane.showMessageDialog(this, "Report saved");

            if (Desktop.isDesktopSupported()) {
                File reportFile = new File(fileName);
                Desktop.getDesktop().open(reportFile);
                ;
            }

            document.close();
        } catch (DocumentException | FileNotFoundException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:printom.PDFCreator.java

public static void createLabel(int aLabelType, int aJobNum, char aJobIdentifier, String aCustName,
        String aItemName, String aItemCode, String aDate, String aPOrderNum, int aInputPcs) {

    String myJobNum = String.valueOf(aJobNum);
    char myJobIdentifier = aJobIdentifier;
    String myCustName = aCustName;
    String myItemName = aItemName;
    String myItemCode = aItemCode;
    String myDate = aDate;//from  w ww  .j av a  2 s.c o  m
    String myPOrderNum = aPOrderNum;
    String myInputPcs = String.valueOf(aInputPcs);

    try {
        String src = "";
        if (aLabelType == 1) {
            src = CTNLABEL;
        }
        String dest = RESULTLABEL;

        Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.WHITE);
        Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);

        PdfReader reader = new PdfReader(src);
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
        PdfContentByte canvas = stamper.getOverContent(1);

        for (int k = 0; k < 3; k++) {

            //Positions
            int[] x = { 298, 350, 125, 80, 80, 80, 80, 120 };
            int[] y = { 562, 562, 518, 498, 479, 459, 440, 420 };

            if (k == 1) {
                for (int j = 0; j < 8; j++) {
                    y[j] = y[j] - 186;
                }
            }

            if (k == 2) {
                for (int j = 0; j < 8; j++) {
                    y[j] = y[j] - 372;
                }
            }

            for (int i = 0; i < 2; i++) {

                if (i == 1) {
                    for (int j = 0; j < 8; j++) {
                        x[j] = x[j] + 372;
                    }
                }

                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myJobNum, timesJob), x[0],
                        y[0], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                        new Phrase(String.valueOf(myJobIdentifier), timesDef), x[1], y[1], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myCustName, timesDef), x[2],
                        y[2], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemName, timesDef), x[3],
                        y[3], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemCode, timesDef), x[4],
                        y[4], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myDate, timesDef), x[5], y[5],
                        0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myPOrderNum, timesDef), x[6],
                        y[6], 0);
                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputPcs, timesDef), x[7],
                        y[7], 0);
            }
        }
        stamper.close();
        reader.close();

    } catch (IOException | DocumentException ex) {
        Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:printom.PDFCreator.java

public static void createReport(int aJobNum, char aJobIdentifier, String aCustName, String aItemName,
        String aItemCode, String aDate, String aPOrderNum, int aInputPcs, int aQtyWithOvers, int aNumContainers,
        String aInputContainer) {

    String myJobNum = String.valueOf(aJobNum);
    char myJobIdentifier = aJobIdentifier;
    String myCustName = aCustName;
    String myItemName = aItemName;
    String myItemCode = aItemCode;
    String myDate = aDate;/*from  ww  w .ja  v a 2 s .com*/
    String myPOrderNum = aPOrderNum;
    String myInputPcs = String.valueOf(aInputPcs);
    int myQtyWithOvers = aQtyWithOvers;
    int myNumContainers = aNumContainers;
    String myInputContainer = aInputContainer;

    double amount = myQtyWithOvers;
    DecimalFormat formatter = new DecimalFormat("#,###");

    String myStrQtyWithOvers = formatter.format(amount);

    try {
        String src = REPORT;
        String dest = RESULTREPORT;

        Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, BaseColor.WHITE);
        Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);

        PdfReader reader = new PdfReader(src);
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
        PdfContentByte canvas = stamper.getOverContent(1);

        int[] x = { 441, 510, 426, 87, 87, 87, 426, 307, 218, 325, 426 };
        int[] y = { 547, 547, 473, 450, 428, 473, 450, 325, 385, 385, 428 };

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myJobNum, timesJob), x[0], y[0], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase(String.valueOf(myJobIdentifier), timesDef), x[1], y[1], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myCustName, timesDef), x[2], y[2], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemName, timesDef), x[3], y[3], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemCode, timesDef), x[4], y[4], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myDate, timesDef), x[5], y[5], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myPOrderNum, timesDef), x[6], y[6],
                0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputPcs, timesDef), x[7], y[7], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myStrQtyWithOvers, timesDef), x[8],
                y[8], 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase("(" + String.valueOf(myNumContainers) + " cases with overs)", timesDef), x[9], y[9],
                0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputContainer, timesDef), x[10],
                y[10], 0);
        stamper.close();
        reader.close();

    } catch (IOException | DocumentException ex) {
        Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:printom.PDFCreator.java

public static void createBOL(ArrayList<Shipment> aShipmentList, int aTemplate) {

    ArrayList<Shipment> shipmentList = aShipmentList;
    Order chosenOrder = shipmentList.get(0).getChosenOrder();

    String bolCode = shipmentList.get(0).getBolCode();
    String bolFileName = bolCode + ".pdf";

    String myCustName = Customer.getCustomerName(chosenOrder.getCustID());
    String myShipDate = Prompter.dateString(shipmentList.get(0).getDateShipped());
    String myCarrier = shipmentList.get(0).getCarrier();
    String myInstructs = shipmentList.get(0).getInstructions();
    Address myAddress = Address.retAddress(shipmentList.get(0).getChosenOrder().getShipAddressID());

    try {//ww w  . j  av  a2s  .  c o m

        //BaseFont bf1 = BaseFont.createFont("c:/windows/fonts/consola.ttf",
        //BaseFont.WINANSI, BaseFont.EMBEDDED);
        Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, BaseColor.WHITE);
        Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);

        Font courierNorm = new Font(Font.FontFamily.COURIER, 11, Font.NORMAL, BaseColor.BLACK);
        Font courierSBig = new Font(Font.FontFamily.COURIER, 13, Font.NORMAL, BaseColor.BLACK);

        // step 1
        Document document = new Document(PageSize.LETTER, 18, 18, 126, 54);
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(bolFileName));
        // step 3
        document.open();
        // step 4
        // we set the compression to 0 so that we can read the PDF syntax
        writer.setCompressionLevel(0);
        // writes something to the direct content using a convenience method
        PdfContentByte canvas = writer.getDirectContentUnder();

        // Graphic Letterheard
        Image image = Image.getInstance("AresLH.jpg");
        image.scalePercent(50f);
        image.setAbsolutePosition(43, 680);

        if (aTemplate == 1)
            document.add(image);

        // 11" = 792
        // 8.5 = 612
        // TEXT SIZE = 11
        // LINE SPACING = 11
        // PARAGRAPH SPACE = 3 * 11
        int myPageWidth = 612;
        int myPageHeight = 792;
        int myTopMargin = 655;
        int myTopSubMargin = 622;
        int myPageLeftMargin = 54;

        // HEADER LINES
        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ARES BOL# " + bolCode, courierNorm),
                myPageLeftMargin, myTopMargin, 0);
        ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("DATE: " + myShipDate, courierNorm),
                myPageWidth - myPageLeftMargin, myTopMargin, 0);

        // CONSIGNEE ADDRESS
        int myAddressStartY = myTopSubMargin;
        int myCurrentY = myTopSubMargin;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CONSIGNEE", courierNorm),
                myPageLeftMargin, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ADDRESS:", courierNorm),
                myPageLeftMargin, myCurrentY, 0);

        myCurrentY = myAddressStartY;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase(myAddress.getAttention(), courierNorm), 125, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getAddress1(), courierNorm),
                125, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase(myAddress.getCity() + ", " + myAddress.getState() + " " + myAddress.getZipCode(),
                        courierNorm),
                125, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getLastLine(), courierNorm),
                125, myCurrentY, 0);

        // FROM ADDRESS
        myCurrentY = myAddressStartY;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FROM:", courierNorm),
                myPageLeftMargin + 288, myCurrentY, 0);

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase("Ares Printing & Packaging", courierNorm), 98 + 288, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase("63 Flushing Ave, Bldg 5", courierNorm), 98 + 288, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn Navy Yard", courierNorm),
                98 + 288, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn, NY 11205", courierNorm),
                98 + 288, myCurrentY, 0);

        // CARRIER, FOB AND SPECIAL INSTRUCTIONS
        myCurrentY -= 33;
        int myItemStartY = myCurrentY;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CARRIER: " + myCarrier, courierNorm),
                myPageLeftMargin, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FOB: Brooklyn", courierNorm),
                myPageLeftMargin, myCurrentY, 0);

        myCurrentY -= 11;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase("SPECIAL INSTRUCTIONS: " + myInstructs, courierNorm), myPageLeftMargin, myCurrentY,
                0);

        int myBOLTPallets = 0;
        int myBOLTCases = 0;
        int myBOLTPieces = 0;

        myCurrentY -= 22;

        ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                new Phrase("---------------------------------------------------------------------------",
                        courierNorm),
                myPageLeftMargin, myCurrentY, 0);

        // Start Item/ShipLine Information
        for (Shipment shipment : shipmentList) {

            ArrayList<Inventory> shipInventoryList = shipment.getInvenList();
            ArrayList<Inventory.InventoryLine> invenLineList = new ArrayList<>();

            Item item = new Item(shipInventoryList.get(0).getItemID());
            String apo = "";

            for (int i = 0; i < shipInventoryList.size(); i++) {

                if (i == 0) {
                    apo += shipInventoryList.get(i).getJobNum();
                } else {
                    apo += ", " + shipInventoryList.get(i).getJobNum();
                }

                invenLineList.addAll(shipInventoryList.get(i).getInvenLines());

            }
            //START ITEM
            myCurrentY -= 22;

            if (myCurrentY < 100) {
                document.newPage();
                if (aTemplate == 1) {
                    document.add(image);
                }
                myCurrentY = myTopSubMargin;
            }

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                    new Phrase("ITEM NAME: " + item.getItemName(), courierNorm), myPageLeftMargin, myCurrentY,
                    0);

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                    new Phrase("CUSTOMER PO#: " + chosenOrder.getPOrderNum(), courierNorm),
                    myPageLeftMargin + 288, myCurrentY, 0);

            myCurrentY -= 11;

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                    new Phrase("ITEM CODE: " + item.getItemCode(), courierNorm), myPageLeftMargin, myCurrentY,
                    0);

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: " + apo, courierNorm),
                    myPageLeftMargin + 288, myCurrentY, 0);

            myCurrentY -= 22;

            ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm),
                    myPageLeftMargin + 115, myCurrentY, 0);

            ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                    new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);

            ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm),
                    myPageLeftMargin + 340, myCurrentY, 0);

            // ITEM 1
            myCurrentY -= 12;

            int myItemTPallets = 0;
            int myItemTCases = 0;
            int myItemTPieces = 0;

            for (Inventory.InventoryLine invenLine : invenLineList) {

                ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                        new Phrase(String.valueOf(invenLine.getPallets()), courierNorm), myPageLeftMargin + 115,
                        myCurrentY, 0);

                ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm),
                        myPageLeftMargin + 150, myCurrentY, 0);

                ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                        new Phrase(String.valueOf(invenLine.getCases()), courierNorm), myPageLeftMargin + 215,
                        myCurrentY, 0);

                ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm),
                        myPageLeftMargin + 281, myCurrentY, 0);

                ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                        new Phrase(String.valueOf(invenLine.getPieces()), courierNorm), myPageLeftMargin + 340,
                        myCurrentY, 0);

                // LINE 2
                myCurrentY -= 11;

                myItemTPallets += invenLine.getPallets();
                myItemTCases += invenLine.getPallets() * invenLine.getCases();
                myItemTPieces += invenLine.getPallets() * invenLine.getCases() * invenLine.getPieces();

                myBOLTPallets += myItemTPallets;
                myBOLTCases += myItemTCases;
                myBOLTPieces += myItemTPieces;

            }

            myCurrentY -= 22;

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm),
                    myPageLeftMargin, myCurrentY, 0);

            ColumnText.showTextAligned(
                    canvas, Element.ALIGN_LEFT, new Phrase("   PALLETS: " + myItemTPallets + "   CASES: "
                            + myItemTCases + "   QUANTITY: " + myItemTPieces, courierNorm),
                    myPageLeftMargin + 95, myCurrentY, 0);

            myCurrentY -= 11;

            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
                    new Phrase("---------------------------------------------------------------------------",
                            courierNorm),
                    myPageLeftMargin, myCurrentY, 0);

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////           

        /*
                
        //START ITEM
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                
                
                     // ITEM 1
                    myCurrentY -= 12;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
           // LINE 2
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                
                
                    myCurrentY -= 33;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("   PALLETS: 12   CASES: 282   QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0);
                
                    myCurrentY -= 11;
                            
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0);
        //////////////         
        //END ITEM
        ////////////// 
                            
                            
                            
                            
                            
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 6;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
        //////////////         
        //END ITEM
        ////////////// 
                            
                    myCurrentY -= 12;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
           // LINE 2
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 1;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
                
                    myCurrentY -= 33;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("   PALLETS: 12   CASES: 282   QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0);
                
                    myCurrentY -= 11;
                            
        //////////////         
        //START ITEM
        ////////////// 
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    //START ITEM
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 6;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
                
                     // ITEM 1
                    myCurrentY -= 12;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
           // LINE 2
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 1;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
                
                    myCurrentY -= 33;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("   PALLETS: 12   CASES: 282   QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0);
        //////////////         
        //END ITEM
        ////////////// 
                    */

        //////////////         
        //START FOOTER
        //////////////     
        myCurrentY -= 33;

        if (myCurrentY < 85) {
            document.newPage();
            myCurrentY = myTopSubMargin;
        }

        ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                new Phrase("SHIPMENT RECEIVED IN GOOD CONDITION BY:", courierNorm), myPageLeftMargin + 128,
                myCurrentY, 0);

        myCurrentY -= 33;

        ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                new Phrase("______________________________________", courierNorm), myPageLeftMargin + 128,
                myCurrentY, 0);
        myCurrentY -= 16;

        ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
                new Phrase("(SIGNATURE) (DATE & TIME)", courierNorm), myPageLeftMargin + 128, myCurrentY, 0);

        myCurrentY += 49;

        ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT,
                new Phrase("TOTAL PALLETS: " + myBOLTPallets, courierSBig), myPageLeftMargin + 500, myCurrentY,
                0);

        myCurrentY -= 13;

        ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT,
                new Phrase("TOTAL CASES: " + myBOLTCases, courierSBig), myPageLeftMargin + 500, myCurrentY, 0);

        myCurrentY -= 13;

        ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT,
                new Phrase("TOTAL WEIGHT: ~" + ((myBOLTCases * 25) + (myBOLTPallets * 40)) + " lbs",
                        courierSBig),
                myPageLeftMargin + 500, myCurrentY, 0);
        //////////////         
        //END FOOTER
        ////////////// 
        /*
                    document.newPage();
                            
                    myCurrentY = myTopSubMargin;
                
        //////////////         
        //START ITEM
        ////////////// 
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    //START ITEM
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0);
                
                    myCurrentY -= 22;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 6;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
                
                     // ITEM 1
                    myCurrentY -= 12;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
           // LINE 2
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER,
            new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0);
                
                    myCurrentY -= 1;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0);
                
                    myCurrentY -= 33;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0);
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("   PALLETS: 12   CASES: 282   QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0);
                
                    myCurrentY -= 11;
                
                    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT,
            new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0);
        //////////////         
        //END ITEM
        ////////////// 
                    */

        // step 5
        document.close();

        if (Desktop.isDesktopSupported()) {
            try {
                File f = new File(bolFileName);
                Desktop.getDesktop().open(f);
            } catch (IOException ex) {
                // no application registered for PDFs
            }
        }

    } catch (IOException | DocumentException ex) {
        Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:PROCESOS.ImprimirPDF.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/pdf");
    String precio_unitario = request.getParameter("precio");

    String id_vale = request.getParameter("codigo");

    //  if(request.getParameter("codigo")!=null){
    OutputStream salida = response.getOutputStream();
    try {/*  www .j av  a2  s.  c om*/

        try {

            DTO.ClaseTransaccion clase = new ClaseTransaccion();
            clase = consulta.Transaccion();
            Document documento = new Document(PageSize.A4, 36, 36, 45, 20);
            PdfWriter pw = PdfWriter.getInstance(documento, salida);
            documento.open();
            Paragraph parrafo1 = new Paragraph();
            Font font_titulo = new Font(Font.FontFamily.HELVETICA, 16, Font.UNDERLINE, BaseColor.BLACK);
            parrafo1.add(new Phrase("TecnoBencina, COMPROBANTE", font_titulo));
            parrafo1.setAlignment(Element.ALIGN_CENTER);
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            parrafo1.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo1);

            Paragraph parrafo2 = new Paragraph();
            Font font_titulo_p2 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK);

            if (id_vale.length() > 0) {
                parrafo2.add(new Phrase("Comprobante de transaccion : codigo del vale : " + id_vale,
                        font_titulo_p2));
            } else {
                parrafo2.add(new Phrase("Comprobante de transaccion ", font_titulo_p2));
            }

            parrafo2.setAlignment(Element.ALIGN_JUSTIFIED);
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            parrafo2.add(new Phrase(Chunk.NEWLINE));
            documento.add(parrafo2);

            PdfPTable tabla = new PdfPTable(9);
            PdfPCell celda1 = new PdfPCell(new Paragraph("ID transaccion ",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda2 = new PdfPCell(
                    new Paragraph("Estado ", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda3 = new PdfPCell(new Paragraph("ID de surtidor",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda4 = new PdfPCell(
                    new Paragraph("Litros", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda5 = new PdfPCell(
                    new Paragraph("Monto", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda6 = new PdfPCell(
                    new Paragraph("Fecha", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda7 = new PdfPCell(
                    new Paragraph("ID pago", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));
            PdfPCell celda8 = new PdfPCell(new Paragraph("Precio unitario",
                    FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK)));

            tabla.addCell(celda1);
            tabla.addCell(celda2);
            tabla.addCell(celda3);
            tabla.addCell(celda4);
            tabla.addCell(celda5);
            tabla.addCell(celda6);
            tabla.addCell(celda7);
            tabla.addCell(celda8);

            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(clase.getEstado());
            tabla.addCell(String.valueOf(clase.getId_transaccion()));
            tabla.addCell(String.valueOf(clase.getLitros()));
            tabla.addCell(String.valueOf(clase.getMonto()));
            tabla.addCell(String.valueOf(clase.getFecha()));
            tabla.addCell(String.valueOf(clase.getId_pago()));
            tabla.addCell(precio_unitario);

            documento.add(tabla);
            documento.addAuthor("TecnoBencina");
            documento.addTitle("Comprobante");
            documento.addLanguage("Espaol");
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));

            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph(new Phrase(Chunk.NEWLINE)));
            documento.add(new Paragraph("texto....", font_titulo_p2));
            documento.close();
        } catch (Exception s) {
            s.getMessage();
        }

    } catch (Exception s) {
        System.out.println("" + s.getMessage());
    } finally {
        salida.close();
    }
    // }
}

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

public String createPdf() throws IOException, DocumentException {

    if (hayParaImprimir()) {

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

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

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

        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
        // step 3
        document.open();//from   ww w  .  ja va  2 s.  co  m

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

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

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

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

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

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

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

                table.addCell(cell);

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

                table.addCell(cell2);

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

        // step 5
        document.close();

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

From source file:relatorios.RelatorioCliente.java

public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento
    Document document = new Document(PageSize.A4, 30, 20, 20, 30);
    Connection conecta; // o objeto que conecta com o banco de dados
    PreparedStatement pst;//from   www  .j a va2 s.c  om
    ResultSet rs;
    conecta = ConectaBd.conectabd();

    OutputStream output;
    try {
        output = new FileOutputStream("relatorios/Relatrio de Clientes.pdf");
        try {
            PdfWriter.getInstance(document, output);
            document.open(); // adicionando um pargrafo ao documento 
            document.add(new Paragraph("                                    Relatrio de Clientes"));
            document.add(new Paragraph("\n"));
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0));
            Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8);
            PdfPTable tabela = new PdfPTable(6);
            PdfPCell cell;
            cell = new PdfPCell(new Phrase("Nome", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("CPF", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Endereo", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Cidade", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("UF", bfBold10));
            tabela.addCell(cell);
            cell = new PdfPCell(new Phrase("Telefone", bfBold10));
            tabela.addCell(cell);

            String sql = "Select * from clientes order by codigo Asc"; //orderna pelo numero do codigo ascendentemente
            try {
                pst = conecta.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    String fornec = rs.getString("nome");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("cpf");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("endereco");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("cidade");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("uf");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);
                    fornec = rs.getString("telefone");
                    cell = new PdfPCell(new Phrase(fornec, bf8));
                    tabela.addCell(cell);

                }
            } catch (SQLException error) {
                JOptionPane.showMessageDialog(null, error);
            }

            document.add(tabela);
            document.close();
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
            document.close();

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println(ex.getMessage());

    }

}