Example usage for com.itextpdf.text Document Document

List of usage examples for com.itextpdf.text Document Document

Introduction

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

Prototype


public Document(Rectangle pageSize) 

Source Link

Document

Constructs a new Document -object.

Usage

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/combos.html", method = RequestMethod.GET)
public void doGetPdfCombos(HttpServletResponse response) {
    List<ComboPorModelo> combos;
    ByteArrayOutputStream baos;/*  ww w .j a  v  a 2  s  .c o m*/
    Document document;
    OutputStream os;
    combos = comboPorModeloService.findAll();
    if (combos != null) {
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, baos);
            // Escribimos
            crearPdfCombos(document, combos);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (DocumentException | IOException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/combosReporte.html", method = RequestMethod.GET)
public void doGetPdfCombosReporte(HttpServletResponse response) {
    PdfWriter writer;/*from   w  w w  .  j  a  v a 2  s . com*/
    List<ComboReporte> combos;
    ByteArrayOutputStream baos;
    Document document;
    OutputStream os;

    combos = comboService.ComboReporte();
    if (combos != null) {
        //            clienteService.iniciarRelacionesLazy(cliente);
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            writer = PdfWriter.getInstance(document, baos);
            crearPdfCombosReporte(document, combos, writer);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (IOException | DocumentException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/lavadasPendientes.html", method = RequestMethod.GET)
public void doGetPdfLavadasPendientesReporte(HttpServletResponse response) {
    List<Lavada> pendientes;
    Document document;/*  w  ww . j  av  a  2s.  com*/
    ByteArrayOutputStream baos;
    OutputStream os;

    pendientes = lavadaService.verLavadasPendientes();
    if (pendientes != null) {
        //            clienteService.iniciarRelacionesLazy(cliente);
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, baos);
            crearPdfLavadasPendientes(document, pendientes);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (IOException | DocumentException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/ventas.html", method = RequestMethod.GET)
public void doGetPdfVentasReporte(@RequestParam("tiempo") String tiempo, HttpServletResponse response) {
    Document document;/*from   w  w  w  .j a v a 2  s.co m*/
    ByteArrayOutputStream baos;
    OutputStream os;
    JFreeChart grafico;
    PdfWriter writer;
    String inicio, fin;
    SimpleDateFormat format;
    Calendar c;
    int me;
    int n;

    c = Calendar.getInstance();
    n = 10;
    switch (tiempo) {
    case "d":
        format = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy");
        fin = format.format(c.getTime());
        c.set(Calendar.DATE, c.get(Calendar.DATE) - (n - 1));
        inicio = format.format(c.getTime());
        me = Constantes.REPORTE_LAVADA_DIARIO;
        break;
    case "s":
        format = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy");
        fin = format.format(c.getTime());
        c.set(Calendar.DATE, c.get(Calendar.DATE) - (n - 1) * 7);
        inicio = format.format(c.getTime());
        me = Constantes.REPORTE_LAVADA_SEMANAL;
        break;
    case "m":
        format = new SimpleDateFormat("MMMM 'de' yyyy");
        fin = format.format(c.getTime());
        c.set(Calendar.MONTH, c.get(Calendar.MONTH) - (n - 1));
        inicio = format.format(c.getTime());
        me = Constantes.REPORTE_LAVADA_MENSUAL;
        break;
    default:
        fin = inicio = "";
        me = -1;
        break;
    }
    if (me >= 0) {
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            writer = PdfWriter.getInstance(document, baos);
            grafico = lavadaService.generarChartReporteVentas(me, n);
            crearPdfVentasReporte(document, grafico, writer, inicio, fin);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (IOException | DocumentException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/clientesFrecuentes.html", method = RequestMethod.GET)
public void doGetPdfClienteFreqReporte(HttpServletResponse response) {
    List<ClienteReporte> reporteCompras;
    ByteArrayOutputStream baos;/*from   w ww.j av a2  s.c o m*/
    Document document;
    PdfWriter writer;
    OutputStream os;
    reporteCompras = clienteService.reporteCompras(false);
    if (reporteCompras != null) {
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            writer = PdfWriter.getInstance(document, baos);
            // Escribimos
            crearPdfClientesFreq(document, reporteCompras, writer);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (DocumentException | IOException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

@RequestMapping(value = "/clientesEvo.html", method = RequestMethod.GET)
public void doGetPdfClienteEvolucionReporte(@RequestParam("id") Long id, HttpServletResponse response) {
    List<ClienteReporte> reporteCompras;
    ByteArrayOutputStream baos;/*from w  ww  .  ja va 2s  .  c o  m*/
    Document document;
    PdfWriter writer;
    OutputStream os;
    reporteCompras = clienteService.reporteComprasPorMesPorCliente(id);
    if (reporteCompras != null) {
        try {
            document = new Document(PageSize.A4);
            baos = new ByteArrayOutputStream();
            writer = PdfWriter.getInstance(document, baos);
            // Escribimos
            crearPdfClientesEvolucion(document, reporteCompras, writer);
            // Cerramos
            // Hay que configurar las cabeceras para que
            //el navegador detecte que es un <strong>PDF</strong>
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // Configuramos el content type
            response.setContentType("application/pdf");
            // Tamao
            response.setContentLength(baos.size());
            // Escribir el ByteArrayOutputStream a el ServletOutputStream
            os = response.getOutputStream();
            baos.writeTo(os);
            os.flush();
            os.close();
        } catch (DocumentException | IOException ex) {
            Logger.getLogger(PdfController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.mstoyanov.music_lessons.pdf.CreatePDF.java

License:Open Source License

public boolean exportPDF() {
    // Checks if external storage is available:
    if (!isExternalStorageWritable()) {
        Toast.makeText(context, "External storage not accessible!", Toast.LENGTH_SHORT).show();
        return false;
    }/*from   w  ww  . ja  va2s.  c om*/
    // Get the path to the user's public downloads directory:
    String fileName = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()
            + "/Schedule.pdf";
    try {
        Document document = new Document(PageSize.LETTER.rotate());
        PdfWriter.getInstance(document, new FileOutputStream(fileName));
        // Create a new letter sized document in landscape mode:
        document.setPageSize(PageSize.LETTER.rotate());
        document.setMargins(72, 36, 36, 36);
        document.open();
        addMetaData(document);
        addContent(document);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    Toast.makeText(context, "Schedule exported to external storage/Download", Toast.LENGTH_LONG).show();
    return true;
}

From source file:com.northcoders.controller.BookingReportsController.java

@FXML
private void generatePdf() throws Exception {
    BaseFont bf;//from   w w  w .ja  v  a2s.com
    Font font;
    try {
        conditions = "Filtered by: Start Date:2017-03-15 End Date:2017-03-28";

        /* Step-2: Initialize PDF documents - logical objects */
        Document my_pdf_report = new Document(PageSize.LETTER.rotate());
        PdfWriter.getInstance(my_pdf_report, new FileOutputStream("pdf_booking_report.pdf"));
        my_pdf_report.open();
        //we have four columns in our table
        PdfPTable my_report_table = new PdfPTable(6);
        //create a cell object
        PdfPCell table_cell;

        bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
        font = new Font(bf, 16);
        my_pdf_report.add(new Paragraph("Administration Report", font));
        font = new Font(bf, 12);
        my_pdf_report.add(new Paragraph("Filter applied:" + conditions, font));
        my_pdf_report.add(new Paragraph(" "));

        table_cell = new PdfPCell(new Phrase("Customer"));
        my_report_table.addCell(table_cell);
        table_cell = new PdfPCell(new Phrase("Start Date"));
        my_report_table.addCell(table_cell);
        table_cell = new PdfPCell(new Phrase("End Date"));
        my_report_table.addCell(table_cell);
        table_cell = new PdfPCell(new Phrase("Room"));
        my_report_table.addCell(table_cell);
        table_cell = new PdfPCell(new Phrase("Amount"));
        my_report_table.addCell(table_cell);
        table_cell = new PdfPCell(new Phrase("Transactions"));
        my_report_table.addCell(table_cell);

        for (Booking item : bookings) {
            String customer_b = item.getCustomerId().getId() + " " + item.getCustomerId().getFirstName() + " "
                    + item.getCustomerId().getLastName();
            table_cell = new PdfPCell(new Phrase(customer_b));
            my_report_table.addCell(table_cell);

            String date_start_b = dateToStr(item.getStartDate());
            table_cell = new PdfPCell(new Phrase(date_start_b));
            my_report_table.addCell(table_cell);

            String date_end_b = dateToStr(item.getEndDate());
            table_cell = new PdfPCell(new Phrase(date_end_b));
            my_report_table.addCell(table_cell);

            String room_b = String.valueOf(item.getRoomId().getRoomNumber());
            table_cell = new PdfPCell(new Phrase(room_b));
            my_report_table.addCell(table_cell);

            String price_b = String.format("%1$,.2f", item.getTotalPrice());
            table_cell = new PdfPCell(new Phrase(price_b));
            my_report_table.addCell(table_cell);

            String transaction_b = "";
            for (PaymentTransaction trans : item.getPaymentTransactionList()) {
                transaction_b += String.format("%1$,.2f", trans.getAmount()) + " "
                        + trans.getPaymentTypeId().getDescription() + "\n";
            }
            table_cell = new PdfPCell(new Phrase(transaction_b));
            my_report_table.addCell(table_cell);
        }

        /* Attach report table to PDF */
        my_pdf_report.add(my_report_table);
        my_pdf_report.add(new Paragraph(" "));
        font = new Font(bf, 6);
        my_pdf_report.add(new Paragraph("Report Time:" + dateTimeToStr(new Date())));
        my_pdf_report.close();

    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.pdfwriter.PrintInventoryReport.java

public void create(ObservableList list, String totalSales) {
    try {/*from  w w w.java  2  s .com*/
        Document document = new Document(PageSize.LETTER);
        document.setMargins(1, 1, 1, 1);

        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        Font font2 = new Font(Font.FontFamily.UNDEFINED, 10, Font.BOLD);
        PdfPTable table = new PdfPTable(5);
        table.setWidthPercentage(95);
        table.setWidths(new int[] { 40, 40, 40, 40, 40 });
        PdfPCell cell;

        cell = new PdfPCell(new Phrase("", font2));
        cell.setBorder(0);
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_CENTER);
        cell.setBorderWidthTop(0);

        cell.setBorderWidthBottom(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("KELNOVI SHOPPING BOTIQUE", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Pondol,Loon, Bohol", new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Phone/Fax#:000-000-000", new Font(Font.FontFamily.UNDEFINED, 9, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("SALES REPORT", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("NO."));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("PRODUCT NAME"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("PRICE"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("QUANTITY"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("AMOUNT PAYABLE"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(14);
        cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);

        for (int i = 0; i < list.size(); i++) {
            it = (ProductClass) list.get(i);

            cell = new PdfPCell(new Phrase("" + it.idProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productDescriptionProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productPriceProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + it.productQtyProperty().get()));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);
            //totalSales.setText(String.format("%,.2f",globalSales));

            cell = new PdfPCell(new Phrase(
                    String.format("%,.2f", Double.parseDouble(it.productTotalSalesProperty().get()))));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBorder(14);
            table.addCell(cell);

        }

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("TOTAL AMOUNT PAYABLE:"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(
                new Phrase("Php " + totalSales, new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Approved by:"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("MICHAEL NOVI MALUENDA II",
                new Font(Font.FontFamily.UNDEFINED, 14, Font.UNDERLINE)));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("General Manager"));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(0);
        table.addCell(cell);

        document.add(table);
        document.close();
        openFile();

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

From source file:com.primeleaf.krystal.web.action.console.OpenDocumentClassAction.java

License:Open Source License

private File generatePdfFile(ArrayList<Hit> hits, ArrayList<IndexDefinition> indexes, User loggedInUser)
        throws Exception {
    File tempPdf = File.createTempFile("tempPdf", ".pdf");
    FileOutputStream file = new FileOutputStream(tempPdf);
    Document document = new Document(PageSize.A3.rotate());
    PdfWriter.getInstance(document, file);
    document.open();/*w w  w  .j  a v  a2 s .c o m*/

    Font boldFont12 = new Font(FontFamily.HELVETICA, 12, Font.BOLD);
    Font normalFont10 = new Font(FontFamily.HELVETICA, 10, Font.NORMAL);

    int colCount = 9; //predefined columns count
    int colSize = indexes.size() + colCount;
    float[] columnWidths = new float[colSize];

    for (int i = 0; i < columnWidths.length; i++) {
        columnWidths[i] = (100 / colSize);
    }

    PdfPTable table = new PdfPTable(columnWidths);
    table.setWidthPercentage(100f);

    if (hits.size() > 0) {
        BaseColor bgColor = new BaseColor(225, 240, 255);

        insertCellPDF(table, "Document ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Revision ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Created By", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Last Modified By", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "File Size", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Created On", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Last Modified On", Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        insertCellPDF(table, "Expiry On", Element.ALIGN_CENTER, 1, boldFont12, bgColor);

        for (IndexDefinition index : indexes) {
            insertCellPDF(table, index.getIndexDisplayName(), Element.ALIGN_CENTER, 1, boldFont12, bgColor);
        }

        insertCellPDF(table, "Note", Element.ALIGN_CENTER, 1, boldFont12, bgColor);

        int count = 0;

        for (Hit hit : hits) {
            count++;
            if (count % 2 == 0) {
                bgColor = new BaseColor(240, 240, 240);
            } else {
                bgColor = new BaseColor(210, 210, 210);
            }
            insertCellPDF(table, hit.documentId + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, hit.revisionId, Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, hit.createdBy, Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, hit.modifiedBy + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, StringHelper.formatSizeText(hit.fileLength), Element.ALIGN_CENTER, 1,
                    normalFont10, bgColor);
            insertCellPDF(table, hit.created, Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, hit.modified, Element.ALIGN_CENTER, 1, normalFont10, bgColor);
            insertCellPDF(table, hit.expiryOn, Element.ALIGN_CENTER, 1, normalFont10, bgColor);

            for (String index : hit.indexValues) {
                insertCellPDF(table, index, Element.ALIGN_LEFT, 1, normalFont10, bgColor);
            }

            ArrayList<DocumentNote> documentNotes = DocumentNoteDAO.getInstance()
                    .readJournalNotes("DOCUMENTID=" + hit.documentId + " AND ACTIVE ='Y' ORDER BY 1 DESC");
            String notesData = "";
            if (documentNotes.size() > 0) {
                for (DocumentNote documentNote : documentNotes) {
                    if (!"P".equalsIgnoreCase(documentNote.getNoteType())) {
                        if (!loggedInUser.getUserName().equalsIgnoreCase(documentNote.getUserName())) {
                            continue;
                        }
                    }
                    User user = UserDAO.getInstance().readUserByName(documentNote.getUserName());
                    notesData += documentNote.getNoteData() + "\n";
                    notesData += "Posted By" + " : " + user.getRealName() + "\n";
                    notesData += "Posted On" + " : " + StringHelper.formatDate(documentNote.getCreated());
                    notesData += "\n";
                }
            }
            insertCellPDF(table, notesData, Element.ALIGN_LEFT, 1, normalFont10, bgColor);
        }
    }
    try {
        document.add(table);
        document.close();
        file.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return tempPdf;
}