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

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

Introduction

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

Prototype

public PdfPCell() 

Source Link

Document

Constructs an empty PdfPCell.

Usage

From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java

License:Apache License

private void createHead(PdfPTable table, VisionVO vision, Context context) throws Exception {
    String bgColor = "#F2F2F2";
    String fnColor = "#000000";
    PdfPCell cell = new PdfPCell();
    cell.addElement(new Phrase("Department Balance SourceCard", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(MAX_COLSPAN);/*from   www .j  a va 2  s  .  c om*/
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(vision.getTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(MAX_COLSPAN);
    table.addCell(cell);

    String dateType = (String) context.get("dateType");
    String year = (String) context.get("startYearDate");
    String orgId = (String) context.get("orgId");
    String departmentName = "";
    String dateTypeName = "Year";
    if ("1".equals(dateType)) {
        dateTypeName = "In the first half";
    }
    if ("2".equals(dateType)) {
        dateTypeName = "In the second half";
    }
    OrganizationVO organization = new OrganizationVO();
    organization.setOrgId(orgId);
    DefaultResult<OrganizationVO> result = this.organizationService.findByUK(organization);
    if (result.getValue() != null) {
        organization = result.getValue();
        departmentName = organization.getName();
    }

    cell = new PdfPCell();
    cell.addElement(new Phrase("Department", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(departmentName, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(4);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(year + " " + dateTypeName, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportPropertyUtils.getPerspectiveTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportPropertyUtils.getObjectiveTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Weight", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Maximum\nTarget\nMinimum", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Score", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

}

From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java

License:Apache License

private void createBody(PdfPTable table, VisionVO vision) throws Exception {
    String bgColor = "#ffffff";
    String fnColor = "#000000";
    PdfPCell cell = null;//from w ww  . j a  va  2s.c  o m
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        cell = new PdfPCell();
        cell.addElement(new Phrase(perspective.getName(), this.getFont(fnColor, false)));
        this.setCellBackgroundColor(cell, bgColor);
        cell.setRowspan(perspective.getRow());
        table.addCell(cell);

        for (ObjectiveVO objective : perspective.getObjectives()) {
            cell = new PdfPCell();
            cell.addElement(new Phrase(objective.getName(), this.getFont(fnColor, false)));
            this.setCellBackgroundColor(cell, bgColor);
            cell.setRowspan(objective.getRow());
            table.addCell(cell);

            for (KpiVO kpi : objective.getKpis()) {
                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getName(), this.getFont(fnColor, false)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getWeight() + "%", this.getFont(fnColor, false)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.addElement(new Phrase(
                        "max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n" + "min: "
                                + kpi.getMin() + "\n" + "unit: " + kpi.getUnit(),
                        this.getFont(fnColor, false)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setRowspan(1);
                table.addCell(cell);

                DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0);

                cell = new PdfPCell();
                cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateRangeScore.getScore()),
                        this.getFont(dateRangeScore.getFontColor(), false)));
                this.setCellBackgroundColor(cell, dateRangeScore.getBgColor());
                cell.setRowspan(1);
                table.addCell(cell);

            }
        }
    }

}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java

License:Apache License

private void createHead(PdfPTable table, VisionVO vision, Context context) throws Exception {
    String bgColor = "#F2F2F2";
    String fnColor = "#000000";
    PdfPCell cell = new PdfPCell();
    cell.addElement(new Phrase("Personal Balance SourceCard", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(MAX_COLSPAN);/*w ww  . j  ava 2s. c  o  m*/
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(vision.getTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(MAX_COLSPAN);
    table.addCell(cell);

    String dateType = (String) context.get("dateType");
    String year = (String) context.get("startYearDate");
    String empId = (String) context.get("empId");
    String account = (String) context.get("account");
    String fullName = "";
    String jobTitle = "";
    String departmentName = "";
    String dateTypeName = "Year";
    if ("1".equals(dateType)) {
        dateTypeName = "In the first half";
    }
    if ("2".equals(dateType)) {
        dateTypeName = "In the second half";
    }
    EmployeeVO employee = new EmployeeVO();
    employee.setEmpId(empId);
    employee.setAccount(account);
    DefaultResult<EmployeeVO> result = this.employeeService.findByUK(employee);
    if (result.getValue() != null) {
        fullName = result.getValue().getEmpId() + " - " + result.getValue().getFullName();
        jobTitle = result.getValue().getEmpId() + " - " + result.getValue().getFullName();
        List<String> appendIds = this.organizationService
                .findForAppendOrganizationOids(result.getValue().getEmpId());
        List<String> appendNames = this.organizationService.findForAppendNames(appendIds);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; appendNames != null && i < appendNames.size(); i++) {
            sb.append(appendNames.get(i)).append(Constants.ID_DELIMITER);
        }
        departmentName = sb.toString();
    }

    cell = new PdfPCell();
    cell.addElement(new Phrase("Job Title", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(jobTitle, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Department", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(departmentName, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("name: " + fullName, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Annual assessment: " + year, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportPropertyUtils.getObjectiveTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(2);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportPropertyUtils.getKpiTitle(), this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(2);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Maximum\nTarget\nMinimum", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(2);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Weight", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(2);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Formula", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(2);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Score", this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(1);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(dateTypeName, this.getFont(fnColor, true)));
    this.setCellBackgroundColor(cell, bgColor);
    cell.setColspan(1);
    cell.setRowspan(1);
    table.addCell(cell);

}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java

License:Apache License

private void createBody(PdfPTable table, VisionVO vision) throws Exception {

    String bgColor = "#ffffff";
    String fnColor = "#000000";
    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            int kx = 0;
            for (KpiVO kpi : objective.getKpis()) {
                PdfPCell cell = new PdfPCell();
                if (kx == 0) {
                    cell.addElement(new Phrase(objective.getName(), this.getFont(fnColor, true)));
                    this.setCellBackgroundColor(cell, bgColor);
                    cell.setColspan(1);//from ww  w .  j a  va 2  s. c o m
                    cell.setRowspan(objective.getRow());
                    table.addCell(cell);
                }

                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getName(), this.getFont(fnColor, true)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setColspan(1);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.addElement(
                        new Phrase(
                                "max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n" + "min: "
                                        + kpi.getMin() + "\n" + "unit: " + kpi.getUnit(),
                                this.getFont(fnColor, true)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setColspan(1);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getWeight() + "%", this.getFont(fnColor, true)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setColspan(1);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.addElement(new Phrase(kpi.getFormula().getName(), this.getFont(fnColor, true)));
                this.setCellBackgroundColor(cell, bgColor);
                cell.setColspan(1);
                table.addCell(cell);

                DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0); // ?

                cell = new PdfPCell();
                cell.addElement(new Phrase(BscReportSupportUtils.parse2(dateRangeScore.getScore()),
                        this.getFont(dateRangeScore.getFontColor(), true)));
                this.setCellBackgroundColor(cell, dateRangeScore.getBgColor());
                cell.setColspan(1);
                table.addCell(cell);

                kx++;
            }
        }
    }

}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java

License:Apache License

private void createFoot(PdfPTable table, Context context) throws Exception {
    String bgColor = "#ffffff";
    String fnColor = "#000000";
    PdfPCell cell = new PdfPCell();
    cell.addElement(new Phrase("assess:", this.getFont(fnColor, true)));
    cell.setColspan(1);/*  w w  w . j  a va 2 s.  c  om*/
    cell.setRowspan(2);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(
            new Phrase(BscReportPropertyUtils.getPersonalReportClassLevel(), this.getFont(fnColor, true)));
    cell.setColspan(3);
    cell.setRowspan(2);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Total", this.getFont(fnColor, true)));
    cell.setColspan(1);
    cell.setRowspan(1);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);

    float total = 0.0f;
    if (context.get("total") != null && context.get("total") instanceof Float) {
        total = (Float) context.get("total");
    }

    cell = new PdfPCell();
    cell.addElement(new Phrase(BscReportSupportUtils.parse2(total), this.getFont(fnColor, true)));
    cell.setColspan(1);
    cell.setRowspan(1);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase("Class", this.getFont(fnColor, true)));
    cell.setColspan(1);
    cell.setRowspan(1);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(new Phrase(" ", this.getFont(fnColor, true)));
    cell.setColspan(1);
    cell.setRowspan(1);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    this.setCellBackgroundColor(cell, bgColor);
    table.addCell(cell);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorActivosFijos.java

public void crearPDFInversion(HttpServletResponse hsr1, ArrayList<HashMap> resultados,
        double granTotalDepActual, double granTotalValorActual, double granTotalValorOr) throws Exception {
    Document dcmntaf = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(dcmntaf, baos);
    System.out.println(resultados.get(0).size());

    dcmntaf.open();/*from w  ww .ja  v  a  2 s  .  c o  m*/
    dcmntaf.open();
    dcmntaf.addTitle("Sapito PDFs");
    dcmntaf.addSubject("Pdf de sapito");

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    dcmntaf.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    dcmntaf.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    dcmntaf.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Inversin"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);

    String titulo2 = "Reporte de Activos Fijos por Tipo"; //Cambiar el titulo del PDF aqui
    Font f2 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK);
    Chunk c2 = new Chunk(titulo2 + " \n ", f2);
    c2.setBackground(BaseColor.WHITE);
    Paragraph title2 = new Paragraph(c2);
    title2.setAlignment(Element.ALIGN_LEFT);
    title2.setIndentationLeft(50);
    //-------------------------  CONTENIDO -------------------------------------------------------
    dcmntaf.add(title); //Titulo del PDF
    dcmntaf.add(title2);
    PdfPTable table = new PdfPTable(4);

    //                                 PdfPCell cell;
    //                            cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK)));                     
    //                        table.addCell(cell);      
    table.addCell("Tipo de Activo fijo");
    table.addCell("Valor Original");
    table.addCell("Depreciacin Actual ");
    table.addCell("Valor Actual");
    //        Iterator it = resultados.get(0).entrySet().iterator();
    for (int i = 0; i < resultados.size(); i++) {
        table.addCell(resultados.get(i).get("tipo").toString());
        table.addCell(resultados.get(i).get("valorOriginal").toString());
        table.addCell(resultados.get(i).get("depreciacionActual").toString());
        table.addCell(resultados.get(i).get("valoreActual").toString());
    }

    //        while (it.hasNext()) {
    //            Map.Entry e = (Map.Entry) it.next();
    //            System.out.println(e.getKey() + " " + e.getValue());
    //            
    //            table.addCell(e.getValue().toString());
    //        }

    dcmntaf.add(table);

    String titulo3 = "Reporte Total de Activos Fijos"; //Cambiar el titulo del PDF aqui
    Font f3 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK);
    Chunk c3 = new Chunk(titulo3 + " \n ", f3);
    c3.setBackground(BaseColor.WHITE);

    Paragraph title3 = new Paragraph(c3);
    title3.setAlignment(Element.ALIGN_LEFT);
    title3.setIndentationLeft(50);
    dcmntaf.add(title3);

    PdfPTable table2 = new PdfPTable(3);
    //                                 PdfPCell cell;
    //                            cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK)));                     
    //                        table.addCell(cell);                        
    table2.addCell("Valor Original Total");
    table2.addCell("Depreciacin Anual Total");
    table2.addCell("Valor Total");
    table2.addCell(granTotalValorOr + "");
    table2.addCell(granTotalDepActual + "");
    table2.addCell(granTotalValorActual + "");

    dcmntaf.add(table2);

    PdfPTable table3 = new PdfPTable(1);
    table3.setWidthPercentage(100.0f);
    table3.setWidths(new float[] { 2.0f });
    table3.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Resultado", font));
    table3.addCell(cell);
    Depreciacion dep = new Depreciacion();

    String bla = a + " ";
    table3.addCell(bla);

    //-------------------------- FIN CONTENIDO -----------------
    dcmntaf.close();

    dcmntaf.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void crearPDFFactura(Map<String, Object> model, HttpServletResponse hsr1, List<Producto> tipo)
        throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();/*from www  . jav  a2 s  . c o m*/
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Ventas"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table3 = new PdfPTable(3);
    table3.setWidthPercentage(100.0f);
    table3.setWidths(new float[] { 2.0f, 2.0f, 2.0f });
    table3.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Nombre", font));
    table3.addCell(cell);
    cell.setPhrase(new Phrase("Categoria", font));
    table3.addCell(cell);
    cell.setPhrase(new Phrase("Marca", font));
    table3.addCell(cell);
    Depreciacion dep = new Depreciacion();
    for (int i = 0; i < tipo.size(); i++) {

        //a = dep.getResultado();
        //b = dep.getValorADep();
        table3.addCell(tipo.get(i).getNombreProducto());
        table3.addCell(tipo.get(i).getCategoria());
        table3.addCell(tipo.get(i).getMarca());

    }
    //        String bla = a + " ";
    //        String bl = b + " ";
    //        table3.addCell(bla);
    //        table3.addCell(bl);
    document.add(table3);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void reporteventa(Map<String, Object> model, HttpServletResponse hsr1, List<OrdenVenta> ordenventa)
        throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();/*from w  w w  .  j  a v a2 s. c o  m*/
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Ventas"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 2.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Total de ventas en el dia", font));
    table.addCell(cell);

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

        a = ordenventa.get(i).getMontoConCargos();
        b = a + b;

    }
    String bla = b + " ";
    table.addCell(bla);

    document.add(table);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void reportecompras(Map<String, Object> model, HttpServletResponse hsr1, List<OrdenCompra> ordenCompra)
        throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();//from www . j  a v a2  s  .  c o  m
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Compras"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 2.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Total de Compras en el dia", font));
    table.addCell(cell);

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

        a = ordenCompra.get(i).getCostoTotal();
        b = a + b;

    }
    String bla = b + " ";
    table.addCell(bla);

    document.add(table);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}

From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java

public void reporteinventario(Map<String, Object> model, HttpServletResponse hsr1, List<Inventario> inventario)
        throws Exception {
    Document document = new Document();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);

    document.open();/*  www .  j a v a  2s.  c  o  m*/
    document.addTitle("Sapito PDFs");
    document.addSubject("Pdf de sapito");
    Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30);
    font1.setColor(BaseColor.BLACK);
    Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24);
    font2.setColor(BaseColor.BLACK);
    document.add(new Paragraph("TAILS 2015", font1));
    document.add(new Paragraph("Reportes Direccin\n", font2));

    //------------------------ TAIS  ______________________________
    Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg"));
    document.add(tais);

    //---------------------  BODY    ---------------------------------------------------------
    Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png"));
    body.setAlignment(Image.UNDERLYING);
    body.setTransparency(new int[] { 0x00, 0x10 });
    body.setAbsolutePosition(50, 250);
    document.add(body);
    //-------------------------------------------------------------------------------------------
    Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg"));
    footer.setAbsolutePosition(50, 20);
    document.add(footer);
    //----------------------  TITLE ---------------------------
    String titulo = "Reporte de Inventarios"; //Cambiar el titulo del PDF aqui
    Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK);
    Chunk c = new Chunk(titulo + " \n ", f);
    c.setBackground(BaseColor.WHITE);
    Paragraph title = new Paragraph(c);
    title.setAlignment(Element.ALIGN_CENTER);
    //-------------------------  CONTENIDO -------------------------------------------------------
    document.add(title); //Titulo del PDF

    TextoPdf x = (TextoPdf) model.get("todoTexto");
    document.add(new Paragraph(x.getTodoTexto()));

    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100.0f);
    table.setWidths(new float[] { 2.0f });
    table.setSpacingBefore(10);

    // define font for table header row
    Font font = FontFactory.getFont(FontFactory.COURIER_BOLD);
    font.setColor(BaseColor.WHITE);

    // define table header cell
    PdfPCell cell = new PdfPCell();
    cell.setBackgroundColor(BaseColor.BLUE);
    cell.setPadding(5);

    // write table header 
    cell.setPhrase(new Phrase("Total de Inventarios", font));
    table.addCell(cell);

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

        a = inventario.get(i).getPrecioUnitario();
        b = a + b;

    }
    String bla = b + " ";
    table.addCell(bla);

    document.add(table);

    //-------------------------- FIN CONTENIDO -----------------
    document.close();

    byte[] bytes = baos.toByteArray();

    hsr1.setContentType("application/pdf");
    hsr1.setContentLength(bytes.length);
    hsr1.getOutputStream().write(bytes);
}