Example usage for com.itextpdf.text.pdf PdfPCell setColspan

List of usage examples for com.itextpdf.text.pdf PdfPCell setColspan

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setColspan.

Prototype

public void setColspan(int colspan) 

Source Link

Document

Setter for property colspan.

Usage

From source file:Reporte.PdfVentaPersona.java

private void generarFilaTotales() throws DocumentException {
    Font fuente = new Font();
    fuente.setSize(10);/*from  www.java  2s .c  o  m*/

    PdfPCell celdaFinal = new PdfPCell(new Paragraph("Totales"));
    celdaFinal.setBackgroundColor(BaseColor.GRAY);
    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(1);
    tabla.addCell(celdaFinal);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.ventas), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);

    PdfPCell parrafo2 = new PdfPCell(new Paragraph(formatoNumero.format(this.comisiones), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);

    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonado), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);

    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonos), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);

    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.saldos), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.totalTicket), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);

    documento.add(tabla);
    documento.add(new Paragraph("Cantidad de registros : " + this.totalRegistros, fuente));
}

From source file:Reporte.PdfVentasGeneral.java

private void generarFilasTotalesFinalColombia() throws DocumentException {

    Font fuente = new Font();
    fuente.setSize(10);// w  w  w  . ja v  a  2 s  .c om

    PdfPCell celdaFinal = new PdfPCell(new Paragraph("Totales"));
    celdaFinal.setBackgroundColor(BaseColor.GRAY);
    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(2);
    tabla.addCell(celdaFinal);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalVentasColombia), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);
    PdfPCell parrafo2 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalcomisionesColombia), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);
    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalaboonadoColombia), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);
    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalabonosColombia), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);
    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalsaldosColombia), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinaltickeColombia), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);

    documento.add(tabla);

    documento.add(new Paragraph("\n"));

}

From source file:Reporte.PdfVentasGeneral.java

private void generarFilasTotalesFinalVenezuela() throws DocumentException {

    Font fuente = new Font();
    fuente.setSize(10);/*w  w  w  .  ja  va  2  s  .co m*/

    PdfPCell celdaFinal = new PdfPCell(new Paragraph("Totales"));
    celdaFinal.setBackgroundColor(BaseColor.GRAY);
    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(2);
    tabla.addCell(celdaFinal);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalVentasVenezuela), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);
    PdfPCell parrafo2 = new PdfPCell(
            new Paragraph(formatoNumero.format(this.FinalcomisionesVenezuela), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);
    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalaboonadoVenezuela), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);
    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalabonosVenezuela), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);
    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinalsaldosVenezuela), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.FinaltickeVenezuela), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);

    documento.add(tabla);

    documento.add(new Paragraph("\n"));

}

From source file:Reporte.PdfVentasGeneral.java

private void generarFilaTotalesVenezuela(String fecha) throws DocumentException {
    Font fuente = new Font();
    fuente.setSize(10);//from  ww  w.j ava2 s  . co m

    PdfPCell celdaFinal = new PdfPCell(new Paragraph(fecha));

    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(2);
    tabla.addCell(celdaFinal);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.ventasVenezuela), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);
    PdfPCell parrafo2 = new PdfPCell(new Paragraph(formatoNumero.format(this.comisionesVenezuela), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);
    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonadoVenezuela), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);
    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonosVenezuela), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);
    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.saldosVenezuela), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.totalTicketVenezuela), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);

    //        documento.add(tabla);
}

From source file:Reporte.PdfVentasGeneral.java

private void generarFilaTotalesColombia(String fecha) throws DocumentException {
    Font fuente = new Font();
    fuente.setSize(10);/* w  w  w .  ja va  2  s . c om*/

    PdfPCell celdaFinal = new PdfPCell(new Paragraph(fecha));

    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(2);
    tabla.addCell(celdaFinal);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.ventasColombia), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);
    PdfPCell parrafo2 = new PdfPCell(new Paragraph(formatoNumero.format(this.comisionesColombia), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);
    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonadoColombia), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);
    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonosColombia), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);
    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.saldosColombia), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.totalTicketColombia), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);

    //        documento.add(tabla);

}

From source file:Reporte.PdfVentasSaldos.java

private void generarFilaTotales() throws DocumentException {
    Font fuente = new Font();
    fuente.setSize(10);/*  w ww  .ja va 2s  .  c  om*/
    PdfPCell celdaFinal = new PdfPCell(new Paragraph("Totales"));
    celdaFinal.setBackgroundColor(BaseColor.GRAY);
    NumberFormat formatoNumero = NumberFormat.getNumberInstance();
    celdaFinal.setColspan(2);
    tabla.addCell(celdaFinal);

    PdfPCell parrafox = new PdfPCell(new Paragraph(formatoNumero.format(this.saldoAnterior), fuente));
    parrafox.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafox);

    PdfPCell parrafo1 = new PdfPCell(new Paragraph(formatoNumero.format(this.ventas), fuente));
    parrafo1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo1);
    PdfPCell parrafo2 = new PdfPCell(new Paragraph(formatoNumero.format(this.comisiones), fuente));
    parrafo2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo2);
    PdfPCell parrafo3 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonado), fuente));
    parrafo3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo3);
    PdfPCell parrafo4 = new PdfPCell(new Paragraph(formatoNumero.format(this.abonos), fuente));
    parrafo4.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo4);
    PdfPCell parrafo5 = new PdfPCell(new Paragraph(formatoNumero.format(this.saldos), fuente));
    parrafo5.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo5);

    PdfPCell parrafo6 = new PdfPCell(new Paragraph(formatoNumero.format(this.totalTicket), fuente));
    parrafo6.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(parrafo6);
    documento.add(tabla);
    if (this.forma.equalsIgnoreCase("POSITIVOS")) {
        documento.add(new Paragraph("Cantidad de registros : " + this.totalRegistrosP, fuente));
    } else {
        documento.add(new Paragraph("Cantidad de registros : " + this.totalRegistrosN, fuente));
    }
}

From source file:ReportGeneration.GenerateReport.java

public void print() {

    FileOutputStream fileOut = null;
    try {//from  ww  w  .  jav  a  2  s . c  om
        Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);
        //Document document = new Document(); //Create PDF cocument
        fileOut = new FileOutputStream(new File("report.pdf"));
        PdfWriter writer = PdfWriter.getInstance(document, fileOut);
        document.open(); //Open the document for writting
        PdfPTable table = new PdfPTable(5); //Create a table with 7 columns. 6 the first column
        //is for labeling the day, and the rest are for displaying actual time table entries.
        document.add(new Paragraph("  RFID ATTENDANCE SYSTEM  "));
        table.setWidthPercentage(100);
        PdfPCell cell;
        cell = new PdfPCell();
        cell.setColspan(1);
        cell.addElement(new Phrase("S/N"));
        table.addCell(cell);
        cell = new PdfPCell();
        cell.addElement(new Phrase("Name"));
        table.addCell(cell);
        cell = new PdfPCell();
        cell.addElement(new Phrase("Matricule Number"));
        table.addCell(cell);
        cell = new PdfPCell();
        cell.addElement(new Phrase("Date"));
        table.addCell(cell);
        cell = new PdfPCell();
        cell.addElement(new Phrase("Time"));
        table.addCell(cell);
        int i = 0;
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        String date2 = df.format(jXDatePicker2.getDate()).toString();
        String date3 = df.format(jXDatePicker3.getDate()).toString();

        genReport = DataBase.getInstance();
        genReport.connect();
        String query = "select `registered personel`.Name, `registered personel`.Matricule_Number, `Attendance Record`.Date, `Attendance Record`.Time from `Registered Personel` join `Attendance Record` on `registered personel`.Tag_ID =`Attendance Record`.`Registered Personel_Tag_ID`  where Date>='"
                + date2 + "' AND Date<='" + date3 + "'";

        genReport.query(query);

        records = genReport.getResultSet();
        while (records.next()) {
            studName = records.getString(1);
            cell = new PdfPCell();
            cell.addElement(new Phrase("" + i));
            table.addCell(cell);
            cell = new PdfPCell();
            cell.addElement(new Phrase(records.getString(1)));
            table.addCell(cell);
            cell = new PdfPCell();
            cell.addElement(new Phrase(records.getString(2)));
            table.addCell(cell);
            cell = new PdfPCell();
            cell.addElement(new Phrase(records.getString(3)));
            table.addCell(cell);
            cell = new PdfPCell();
            cell.addElement(new Phrase(records.getString(4)));
            table.addCell(cell);
            i++;
        }
        document.add(table);
        document.close();
    } catch (Exception ex) {
        Logger.getLogger(GenerateReport.class.getName()).log(Level.SEVERE, null, ex);
    } finally {

        try {
            fileOut.close();
        } catch (IOException ex) {
            Logger.getLogger(GenerateReport.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private PdfPCell renderPdfCell(BandElement bandElement, Object value, int gridRow, int rowSpan, int colSpan,
        boolean image, int column) {
    Map<String, Object> style = buildCellStyleMap(bandElement, value, gridRow, column, colSpan);

    FontFactoryImp fact = new FontFactoryImp();
    com.itextpdf.text.Font fnt;//from w w w .  ja v  a 2s . c o m
    if (bandElement != null) {
        fontName = (String) style.get(StyleFormatConstants.FONT_NAME_KEY);
        int size = ((Float) style.get(StyleFormatConstants.FONT_SIZE)).intValue();
        fnt = getFont(size);
    } else {
        fnt = getFont(10);
    }

    PdfPCell cell;
    if (image) {
        if (value == null) {
            cell = new PdfPCell(new Phrase(IMAGE_NOT_FOUND));
        } else {
            ImageBandElement ibe = (ImageBandElement) bandElement;
            try {
                byte[] imageBytes = getImage((String) value);
                cell = getImageCell(ibe, imageBytes, column, colSpan);
            } catch (Exception e) {
                cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
            }
        }
    } else if (bandElement instanceof HyperlinkBandElement) {
        Hyperlink hyperlink = ((HyperlinkBandElement) bandElement).getHyperlink();
        Anchor anchor = new Anchor(hyperlink.getText(), fnt);
        anchor.setReference(hyperlink.getUrl());
        Phrase ph = new Phrase();
        ph.add(anchor);
        cell = new PdfPCell(ph);
    } else if (bandElement instanceof ReportBandElement) {
        Report report = ((ReportBandElement) bandElement).getReport();
        ExporterBean eb = null;
        try {
            eb = getSubreportExporterBean(report);
            PdfExporter subExporter = new PdfExporter(eb);
            subExporter.export();
            PdfPTable innerTable = subExporter.getTable();
            cell = new PdfPCell(innerTable);
        } catch (Exception e) {
            cell = new PdfPCell();
            e.printStackTrace();
        } finally {
            if ((eb != null) && (eb.getResult() != null)) {
                eb.getResult().close();
            }
        }
    } else if ((bandElement instanceof VariableBandElement) && (VariableFactory
            .getVariable(((VariableBandElement) bandElement).getVariable()) instanceof TotalPageNoVariable)) {
        try {
            cell = new PdfPCell(Image.getInstance(total));
        } catch (BadElementException e) {
            cell = new PdfPCell(new Phrase("NA"));
        }

    } else if (bandElement instanceof ImageColumnBandElement) {
        try {
            String v = StringUtil.getValueAsString(value, null);
            if (StringUtil.BLOB.equals(v)) {
                cell = new PdfPCell(new Phrase(StringUtil.BLOB));
            } else {
                byte[] bytes = StringUtil.decodeImage(v);
                cell = getImageCell(bandElement, bytes, column, colSpan);
            }
        } catch (Exception e) {
            e.printStackTrace();
            cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
        }
    } else {
        String stringValue;
        if (style.containsKey(StyleFormatConstants.PATTERN)) {
            stringValue = StringUtil.getValueAsString(value, (String) style.get(StyleFormatConstants.PATTERN),
                    getReportLanguage());
        } else {
            stringValue = StringUtil.getValueAsString(value, null, getReportLanguage());
        }
        if (stringValue == null) {
            stringValue = "";
        }
        if (stringValue.startsWith("<html>")) {
            StringReader reader = new StringReader(stringValue);
            List<Element> elems = new ArrayList<Element>();
            try {
                elems = HTMLWorker.parseToList(reader, new StyleSheet());
                Phrase ph = new Phrase();
                for (int i = 0; i < elems.size(); i++) {
                    Element elem = (Element) elems.get(i);
                    ph.add(elem);
                }
                cell = new PdfPCell(ph);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Phrase ph = new Phrase(stringValue, fnt);
                cell = new PdfPCell(ph);
            }

        } else {
            Phrase ph = new Phrase(stringValue, fnt);
            cell = new PdfPCell(ph);
        }
    }

    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setUseDescender(true); // needed for a cell without padding
    cell.setMinimumHeight(MINIMUM_HEIGHT); // needed if there is a row in which all cells are empty

    if (bandElement != null) {
        cell.setRotation(bandElement.getTextRotation());
    }

    if (colSpan > 1) {
        cell.setColspan(colSpan);
    }

    if (rowSpan > 1) {
        cell.setRowspan(rowSpan);
    }

    if (style != null) {

        updateFont(style, fnt);

        if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
            cell.setBackgroundColor(new BaseColor(val));
        }
        if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
            if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            }
        }

        if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
            if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_TOP);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            }
        }

        if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT);
            cell.setPaddingLeft(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_RIGHT);
            cell.setPaddingRight(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP);
            cell.setPaddingTop(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_BOTTOM);
            cell.setPaddingBottom(val);
        }
        cell.setBorderWidth(0);

        if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
            cell.setBorderWidthLeft(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
            cell.setBorderColorLeft(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
            cell.setBorderWidthRight(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
            cell.setBorderColorRight(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
            cell.setBorderWidthTop(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
            cell.setBorderColorTop(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
            cell.setBorderWidthBottom(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
            cell.setBorderColorBottom(new BaseColor(color));
        }

        // for subreports we use default no wrap
        if (cell.getTable() == null) {
            cell.setNoWrap(true);
            if (bandElement != null) {
                if (bandElement.isWrapText()) {
                    cell.setNoWrap(false);
                }
            }
        }

        // to see a background image all cells must not have any background!
        if (bean.getReportLayout().getBackgroundImage() != null) {
            cell.setBackgroundColor(null);
        }
    }
    return cell;
}

From source file:rs.marko.helper.Kreiranje.java

public static File createPdfStatistika(List<Stavkadnevneberbe> stavke, Date pocetak, Date kraj) {
    Document document = new Document();
    File yourFile = null;//from www.j  av  a  2 s  .  co  m
    try {
        yourFile = new File(System.getProperty("user.home") + "/Desktop/" + pocetak + "_" + kraj + ".pdf");
        if (!yourFile.exists()) {
            yourFile.createNewFile();
        }
        FileOutputStream oFile = new FileOutputStream(yourFile, false);
        document.setPageSize(PageSize.A4.rotate());
        PdfWriter.getInstance(document, oFile);
        document.open();
        //                        String text = "";
        //                        for (int i = 0; i < 10000; i++) {
        //                                text += "test";
        //              ,          }
        //            String jmbg = stavke.get(0).getDobavljac().getJmbg();

        PdfPTable table = new PdfPTable(
                new float[] { 300f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(0f);
        table.setSpacingAfter(0f);
        Paragraph p = new Paragraph("Od: " + pocetak + " do: " + kraj);
        p.add(new Paragraph(" "));
        document.add(p);
        PdfPCell c = new PdfPCell(new Phrase(""));
        //            PdfPCell c1 = new PdfPCell(new Phrase("Sifra"));
        //            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            c1.setRowspan(2);
        //            c1.setColspan(2);
        //            table.addCell(c1);
        PdfPCell c1 = new PdfPCell(new Phrase("Dobavljac"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        c1.setRowspan(2);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Tacne"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("I Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("II Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("III Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Svega"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(3);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cena"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        Font font = new Font(BaseFont.createFont(), 10, Font.NORMAL);

        //                table.setHeaderRows(3);
        List<String> jmbgovi = new ArrayList<>();
        Map<Double, Double> kt = new HashMap<>();
        Map<Double, Double> k1 = new HashMap<>();
        Map<Double, Double> k2 = new HashMap<>();
        Map<Double, Double> k3 = new HashMap<>();

        Map<Double, Double> ukupnoTacneVrednost = new HashMap<>();
        Map<Double, Double> ukupnoPrvaKlasaVrednost = new HashMap<>();
        Map<Double, Double> ukupnoDrugaKlasaVrednost = new HashMap<>();
        Map<Double, Double> ukupnoTrecaKlasaVrednost = new HashMap<>();
        for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
            if (!jmbgovi.contains(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg())) {
                jmbgovi.add(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg());
            }
        }
        Double ukupnoKolicinaTacne = 0.0;
        Double ukupnoKolicinaPrvaKlasa = 0.0;
        Double ukupnoKolicinaDrugaKlasa = 0.0;
        Double ukupnoKolicinaTrecaKlasa = 0.0;
        Double ukupnoCenaTacne = 0.0;
        Double ukupnoCenaPrvaKlasa = 0.0;
        Double ukupnoCenaDrugaKlasa = 0.0;
        Double ukupnoCenaTrecaKlasa = 0.0;
        Double ukupanIznosSvih = 0.0;
        for (String j : jmbgovi) {
            String imeDobavljaca = null;
            for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
                if (stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg().equals(j)) {
                    if (imeDobavljaca == null) {
                        imeDobavljaca = stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getIme() + " "
                                + stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getPrezime();

                    }
                    if (!kt.containsKey(stavkaDnevneBerbe.getCenatacne())
                            && stavkaDnevneBerbe.getTacne() != 0) {
                        kt.put(stavkaDnevneBerbe.getCenatacne(), new Double(0));
                    }
                    if (!k1.containsKey(stavkaDnevneBerbe.getCenaprvaklasa())
                            && stavkaDnevneBerbe.getCenaprvaklasa() != 0) {
                        k1.put(stavkaDnevneBerbe.getCenaprvaklasa(), new Double(0));
                    }
                    if (!k2.containsKey(stavkaDnevneBerbe.getCenadrugaklasa())
                            && stavkaDnevneBerbe.getCenadrugaklasa() != 0) {
                        k2.put(stavkaDnevneBerbe.getCenadrugaklasa(), new Double(0));
                    }
                    if (!k3.containsKey(stavkaDnevneBerbe.getCenatrecaklasa())
                            && stavkaDnevneBerbe.getCenatrecaklasa() != 0) {
                        k3.put(stavkaDnevneBerbe.getCenatrecaklasa(), new Double(0));
                    }
                }
            }
            for (Stavkadnevneberbe s : stavke) {
                if (s.getDnevnaberba().getDobavljac().getJmbg().equals(j)) {
                    if (kt.containsKey(s.getCenatacne())) {
                        kt.put(s.getCenatacne(), kt.get(s.getCenatacne()) + s.getTacne());
                    }
                    if (k1.containsKey(s.getCenaprvaklasa())) {
                        k1.put(s.getCenaprvaklasa(), k1.get(s.getCenaprvaklasa()) + s.getPrvaklasa());
                    }
                    if (k2.containsKey(s.getCenadrugaklasa())) {
                        k2.put(s.getCenadrugaklasa(), k2.get(s.getCenadrugaklasa()) + s.getDrugaklasa());
                    }
                    if (k3.containsKey(s.getCenatrecaklasa())) {
                        k3.put(s.getCenatrecaklasa(), k3.get(s.getCenatrecaklasa()) + s.getTrecaklasa());
                    }
                }
            }
            c1 = new PdfPCell(new Phrase(imeDobavljaca));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            c1.setColspan(2);
            table.addCell(c1);
            Iterator it = kt.entrySet().iterator();
            Double ukupnoKolicinaT = 0.0;
            Double ukupnoCenaT = 0.0;
            Double ukupanIznos = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaT += (Double) pair.getValue();
                ukupnoCenaT += (Double) pair.getKey();
                ukupanIznos += ((Double) pair.getValue() * (Double) pair.getKey());
                //ukupno vrednost
                if (ukupnoTacneVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoTacneVrednost.put((Double) pair.getKey(),
                            ukupnoTacneVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoTacneVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaT, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznos, 2) + "", font));
            table.addCell(c1);

            it = k1.entrySet().iterator();
            Double ukupnoKolicinaP = 0.0;
            Double ukupnoCenaP = 0.0;
            Double ukupanIznosP = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaP += (Double) pair.getValue();
                ukupnoCenaP += (Double) pair.getKey();
                ukupanIznosP += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoPrvaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoPrvaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaP, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosP, 2) + "", font));
            table.addCell(c1);

            it = k2.entrySet().iterator();
            Double ukupnoKolicinaD = 0.0;
            Double ukupnoCenaD = 0.0;
            Double ukupanIznosD = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaD += (Double) pair.getValue();
                ukupnoCenaD += (Double) pair.getKey();
                ukupanIznosD += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoDrugaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoDrugaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaD, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosD, 2) + "", font));
            table.addCell(c1);

            it = k3.entrySet().iterator();
            Double ukupnoKolicinaTr = 0.0;
            Double ukupnoCenaTr = 0.0;
            Double ukupanIznosT = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaTr += (Double) pair.getValue();
                ukupnoCenaTr += (Double) pair.getKey();
                ukupanIznosT += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoTrecaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoTrecaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaTr, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosT, 2) + "", font));
            table.addCell(c1);
            Double ukupnoKolicina = ukupnoKolicinaT + ukupnoKolicinaP + ukupnoKolicinaD + ukupnoKolicinaTr;
            Double ukupnoVrednost = ukupanIznos + ukupanIznosP + ukupanIznosD + ukupanIznosT;
            Double ukupnoCena = ukupnoVrednost / ukupnoKolicina;
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicina, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupnoCena, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupnoVrednost, 2) + "", font));
            table.addCell(c1);

            ukupanIznosSvih += ukupnoVrednost;

            ukupnoKolicinaTacne += ukupnoKolicinaT;
            ukupnoKolicinaPrvaKlasa += ukupnoKolicinaP;
            ukupnoKolicinaDrugaKlasa += ukupnoKolicinaD;
            ukupnoKolicinaTrecaKlasa += ukupnoKolicinaTr;

            ukupnoCenaTacne += ukupanIznos;
            ukupnoCenaPrvaKlasa += ukupanIznosP;
            ukupnoCenaDrugaKlasa += ukupanIznosD;
            ukupnoCenaTrecaKlasa += ukupanIznosT;

            kt.clear();
            k1.clear();
            k2.clear();
            k3.clear();
        }
        c1 = new PdfPCell(new Phrase("UKUPNO"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaTacne + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaTacne + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaPrvaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaPrvaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaDrugaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaDrugaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaTrecaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaTrecaKlasa + "", font));
        table.addCell(c1);

        Double ukupnoKolicinaSve = ukupnoKolicinaTacne + ukupnoKolicinaPrvaKlasa + ukupnoKolicinaDrugaKlasa
                + ukupnoKolicinaTrecaKlasa;
        Double prosecnaCena = ukupanIznosSvih / ukupnoKolicinaSve;

        c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaSve, 2) + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(round(prosecnaCena, 2) + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(round(ukupanIznosSvih, 2) + "", font));
        table.addCell(c1);

        //PDV
        c1 = new PdfPCell(new Phrase("PDV"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        table.addCell(c);

        Iterator it = ukupnoTacneVrednost.entrySet().iterator();
        Double ukupnoTacnePdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            if ((Double) pair.getKey() == 110) {
                ukupnoTacnePdv += (((Double) pair.getValue() / (Double) pair.getKey()) * 106);
            } else {
                ukupnoTacnePdv += (Double) pair.getValue();
            }
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoTacnePdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoPrvaKlasaVrednost.entrySet().iterator();
        Double ukupnoPrvaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoPrvaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoPrvaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoDrugaKlasaVrednost.entrySet().iterator();
        Double ukupnoDrugaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoDrugaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoDrugaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoTrecaKlasaVrednost.entrySet().iterator();
        Double ukupnoTrecaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoTrecaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoTrecaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        c = new PdfPCell(new Phrase(""));
        c.setColspan(2);
        table.addCell(c);

        Double ukupnoSvePDV = ukupnoTacnePdv + ukupnoPrvaKlasaPdv + ukupnoDrugaKlasaPdv + ukupnoTrecaKlasaPdv;
        c1 = new PdfPCell(new Phrase(round(ukupnoSvePDV * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);

        c = new PdfPCell(new Phrase(""));
        c.setColspan(10);
        table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);

        c1 = new PdfPCell(new Phrase("DOBITAK"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);

        c1 = new PdfPCell(
                new Phrase(round((ukupnoSvePDV * (110.0f / 100.0f)) - ukupanIznosSvih, 2) + "", font));
        table.addCell(c1);

        document.add(table);
        document.add(new Paragraph(" "));
    } catch (DocumentException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    }
    document.close();
    return yourFile;
}

From source file:Sales.SalesController.java

@FXML
private void PrintReciept(MouseEvent event) {
    try {/*from  w  w w  .j  a  v a 2  s .c  o  m*/
        Image im = Image.getInstance("khamals.png");
        FileOutputStream sa = new FileOutputStream("Reciept.pdf");
        im.scaleAbsolute(150f, 150f);
        // im.setAbsolutePosition(25,50);
        im.setBackgroundColor(BaseColor.PINK);
        Document doc = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter writer = PdfWriter.getInstance(doc, sa);
        PdfPTable table = new PdfPTable(6);
        String sh = "                                     Date and Time Of Sale : "
                + Calendar.getInstance().getTime().toGMTString() + "\n\n";
        String header = "                                                                 KHAMALS \n"
                + "                                              DESIGNER AND SHOWROOM EXPERT \n "
                + "                                  MOLYKO BUEA  LAST FLOOR ECKO BANK BUILDING\n ";
        String metda = "    INVOICE NUMBER :" + this.RecieptId.getText() + " \n " + "  SALES PERSON ID :"
                + this.CashierName.getText() + " \n   CUSTOMER NAME :" + this.CustomerName.getText() + "\n\n";

        PdfPCell cell = new PdfPCell(new Phrase("\nRECIEPT"));
        cell.setColspan(6);
        cell.setHorizontalAlignment(2);
        doc.open();
        doc.add(im);
        doc.add(cell);
        System.out.println(doc.leftMargin());
        doc.add(new Paragraph(header));
        doc.add(new Paragraph(sh));
        doc.add(new Paragraph(metda));
        table.addCell("S/N");
        table.addCell("PRODUCT NAME");
        table.addCell("DESCRIPTION");
        table.addCell("QUANTITY");
        table.addCell("UNIT PRICE");
        table.addCell("TOTAL PRICE");
        table.setTotalWidth(1000000);
        for (int i = 0; i < Cart.getItems().size(); i++) {
            table.addCell(this.idex.getCellData(i).toString());
            table.addCell(this.p.getCellData(i).toString());
            table.addCell(this.dsc.getCellData(i).toString());
            table.addCell(this.qt.getCellData(i).toString());
            table.addCell(this.p.getCellData(i).toString());
            table.addCell(this.tp.getCellData(i).toString());
        }

        String footer = " \n                                                                                 Total Amount:         "
                + tot.getText() + ""
                + "                                                                                   SIGNATURES \n"
                + "\nCUSTOMER                                      SALES PERSON ";

        doc.add(table);
        doc.add(new Paragraph(footer));
        doc.addCreationDate();
        doc.addAuthor(this.CashierName.getText());
        doc.close();

        Desktop.getDesktop().open(new File("Reciept.pdf"));

    } catch (Exception sd) {
        System.out.println("Error Message :" + sd.getMessage());
    } finally {

    }

}