Example usage for com.itextpdf.text Document addAuthor

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

Introduction

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

Prototype


public boolean addAuthor(String author) 

Source Link

Document

Adds the author to a Document.

Usage

From source file:org.jfree.chart.swt.ChartPdf.java

License:Open Source License

public static void saveChartAsPDF(File file, JFreeChart chart, int width, int height)
        throws DocumentException, FileNotFoundException, IOException {
    if (chart != null) {
        boolean success = false;
        String old = null;/*  ww  w  . j ava  2s  . com*/
        File oldFile = null;
        boolean append = file.exists();
        if (append) {
            old = file.getAbsolutePath() + ".old"; //$NON-NLS-1$
            oldFile = new File(old);
            oldFile.delete();
            file.renameTo(oldFile);
        }
        try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
            // convert chart to PDF with iText:
            Rectangle pagesize = new Rectangle(width, height);
            if (append) {
                PdfReader reader = new PdfReader(old);
                PdfStamper stamper = new PdfStamper(reader, out);
                try {
                    int n = reader.getNumberOfPages() + 1;
                    stamper.insertPage(n, pagesize);
                    PdfContentByte overContent = stamper.getOverContent(n);
                    writeChart(chart, width, height, overContent);
                    ColumnText ct = new ColumnText(overContent);
                    ct.setSimpleColumn(width - 50, 50, width - 12, height, 150, Element.ALIGN_RIGHT);
                    Paragraph paragraph = new Paragraph(String.valueOf(n),
                            new Font(FontFamily.HELVETICA, 9, Font.NORMAL, BaseColor.DARK_GRAY));
                    paragraph.setAlignment(Element.ALIGN_RIGHT);
                    ct.addElement(paragraph);
                    ct.go();
                    success = true;
                } finally {
                    stamper.close();
                    reader.close();
                    oldFile.delete();
                }
            } else {
                Document document = new Document(pagesize, 50, 50, 50, 50);
                document.addCreationDate();
                document.addCreator(Constants.APPLICATION_NAME);
                document.addAuthor(System.getProperty("user.name")); //$NON-NLS-1$
                try {
                    PdfWriter writer = PdfWriter.getInstance(document, out);
                    document.open();
                    writeChart(chart, width, height, writer.getDirectContent());
                    success = true;
                } finally {
                    document.close();
                }
            }
        }
        if (!success) {
            file.delete();
            if (oldFile != null)
                oldFile.renameTo(file);
        }
    }
}

From source file:org.me.modelos.PDFHelper.java

public void tablaToPdf(JTable jTable, File pdfNewFile, String title) {
    try {/*from w  ww  .  j a v a2s . c o  m*/
        Font subCategoryFont = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD);
        Document document = new Document(PageSize.LETTER.rotate());
        PdfWriter writer = null;
        try {
            writer = PdfWriter.getInstance(document, new FileOutputStream(pdfNewFile));
        } catch (FileNotFoundException fileNotFoundException) {
            Message.showErrorMessage(fileNotFoundException.getMessage());
        }

        writer.setBoxSize("art", new Rectangle(150, 10, 700, 580));
        writer.setPageEvent(new HeaderFooterPageEvent());
        document.open();
        document.addTitle(title);

        document.addSubject("Reporte");
        document.addKeywords("reportes, gestion, pdf");
        document.addAuthor("Gestion de Proyectos de software");
        document.addCreator("gestion de proyectos");

        Paragraph parrafo = new Paragraph(title, subCategoryFont);

        PdfPTable table = new PdfPTable(jTable.getColumnCount());
        table.setWidthPercentage(100);
        PdfPCell columnHeader;

        for (int column = 0; column < jTable.getColumnCount(); column++) {
            Font font = new Font(Font.FontFamily.HELVETICA);
            font.setColor(255, 255, 255);
            columnHeader = new PdfPCell(new Phrase(jTable.getColumnName(column), font));
            columnHeader.setHorizontalAlignment(Element.ALIGN_LEFT);
            columnHeader.setBackgroundColor(new BaseColor(96, 125, 139));
            table.addCell(columnHeader);
        }
        table.getDefaultCell().setBackgroundColor(new BaseColor(255, 255, 255));
        table.setHeaderRows(1);
        BaseColor verdad = new BaseColor(255, 255, 255);
        BaseColor falso = new BaseColor(214, 230, 244);
        boolean bandera = false;
        for (int row = 0; row < jTable.getRowCount(); row++) {

            for (int column = 0; column < jTable.getColumnCount(); column++) {

                if (bandera) {
                    table.getDefaultCell().setBackgroundColor(verdad);
                } else {
                    table.getDefaultCell().setBackgroundColor(falso);
                }
                table.addCell(jTable.getValueAt(row, column).toString());
                bandera = !bandera;
            }

        }

        parrafo.add(table);
        document.add(parrafo);
        document.close();
        //JOptionPane.showMessageDialog(null, "Se ha creado el pdf en " + pdfNewFile.getPath(),
        //        "RESULTADO", JOptionPane.INFORMATION_MESSAGE);
    } catch (DocumentException documentException) {
        System.out.println("Se ha producido un error " + documentException);
        JOptionPane.showMessageDialog(null, "Se ha producido un error" + documentException, "ERROR",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.openmrs.module.laboratorymanagement.db.hibernate.LaboratoryDAOimpl.java

License:Open Source License

public void exportPatientReportToPDF(HttpServletRequest request, HttpServletResponse response,
        Map<ConceptName, List<Object[]>> mappedLabExam, String filename, String title, int patientId)
        throws DocumentException, IOException {

    Document document = new Document();
    Patient patient = Context.getPatientService().getPatient(patientId);
    // List<PatientBill> patientBills =
    // (List<PatientBill>)request.getAttribute("reportedPatientBillsPrint");

    /*//from www .j a v  a  2 s  .  c  o  m
     * PatientBill pb = null;
     * 
     * pb = Context.getService(BillingService.class).getPatientBill(
     * Integer.parseInt(request.getParameter("patientBills")));
     */
    /*
     * String filename = pb.getBeneficiary().getPatient().getPersonName()
     * .toString().replace(" ", "_"); filename =
     * pb.getBeneficiary().getPolicyIdNumber().replace(" ", "_") + "_" +
     * filename + ".pdf";
     */
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "report"); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(0, 0, 2382, 3369));
    writer.setBoxSize("art", PageSize.A4);

    HeaderFooterMgt event = new HeaderFooterMgt();
    writer.setPageEvent(event);

    document.open();
    document.setPageSize(PageSize.A4);
    // document.setPageSize(new Rectangle(0, 0, 2382, 3369));

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().toString());// the name of the author

    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.ITALIC));

    // Report title
    Chunk chk = new Chunk("Printed on : " + (new SimpleDateFormat("dd-MMM-yyyy").format(new Date())));
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    Paragraph todayDate = new Paragraph();
    todayDate.setAlignment(Element.ALIGN_RIGHT);
    todayDate.add(chk);
    document.add(todayDate);
    document.add(fontTitle.process("REPUBLIQUE DU RWANDA\n"));
    document.add(fontTitle.process("POLICE NATIONALE\n"));
    document.add(fontTitle.process("KACYIRU POLICE HOSPITAL\n"));
    document.add(fontTitle.process("B.P. 6183 KIGALI\n"));
    document.add(fontTitle.process("Tl : 584897\n"));
    document.add(fontTitle.process("E-mail : medical@police.gov.rw"));
    // End Report title

    document.add(new Paragraph("\n"));
    chk = new Chunk("Laboratory results");
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    chk.setUnderline(0.2f, -2f);
    Paragraph pa = new Paragraph();
    pa.add(chk);
    pa.setAlignment(Element.ALIGN_CENTER);
    document.add(pa);
    document.add(new Paragraph("\n"));

    document.add(fontTitle.process("Family Name: " + patient.getFamilyName() + "\n"));
    document.add(fontTitle.process("Given name: " + patient.getGivenName() + "\n"));
    document.add(fontTitle.process("Age: " + patient.getAge() + "\n"));

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.ITALIC));
    // Table of identification;
    PdfPTable table = null;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    // tableHeader.addCell(table);

    // document.add(tableHeader);

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

    // Table of lab report items;
    float[] colsWidth = { 6f, 3f, 6f };
    table = new PdfPTable(colsWidth);
    table.setWidthPercentage(100f);
    BaseColor bckGroundTitle = new BaseColor(170, 170, 170);
    BaseColor bckGroundTitl = new BaseColor(Color.yellow);

    // table Header
    PdfPCell cell = new PdfPCell(fontTitleSelector.process("Exam"));

    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Result"));
    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Normal Range"));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);
    /*
     * cell = new PdfPCell(fontTitleSelector.process("Date "));
     * cell.setBackgroundColor(bckGroundTitle); table.addCell(cell);
     */

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    // empty row
    FontSelector fontTotals = new FontSelector();
    fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

    // ===========================================================
    for (ConceptName cptName : mappedLabExam.keySet()) {

        cell = new PdfPCell(fontTitleSelector.process("" + cptName));
        cell.setBackgroundColor(bckGroundTitl);

        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);

        List<Object[]> labExamHistory = mappedLabExam.get(cptName);
        for (Object[] labExam : labExamHistory) {
            // table Header
            // Object[] labe = listOflabtest.get(i);
            Obs ob = (Obs) labExam[0];
            cell = new PdfPCell(fontTitleSelector.process("" + ob.getConcept().getName()));

            table.addCell(cell);
            if (ob.getConcept().getDatatype().isNumeric()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueNumeric()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isCoded()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueCoded().getName()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isText()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueText()));
                table.addCell(cell);

            }

            cell = new PdfPCell(fontTitleSelector.process("" + (labExam[1] != null ? labExam[1] : "-")));
            table.addCell(cell);

            fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

            // empty row
            // FontSelector fontTotals = new FontSelector();
            fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

        }

    }

    cell = new PdfPCell(fontTitleSelector.process("Names, Signature et Stamp of Lab Chief\n"
            //+ Context.getAuthenticatedUser().getPersonName()));
            + Context.getUserService().getUser(140).getPersonName()));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    // ================================================================
    table.addCell(cell);

    document.add(table);

    // Table of signatures;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    cell = new PdfPCell(fontTitleSelector.process(" "));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(
            "Names, Signature and  Stamp of Provider\n" + Context.getAuthenticatedUser().getPersonName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    document.add(table);
    document.close();

    document.close();
}

From source file:org.openmrs.module.mohtracportal.util.FileExporter.java

License:Open Source License

/**
 * @param request// w  ww  .ja  v  a 2 s.c o m
 * @param response
 * @param res
 * @param filename
 * @param title
 * @param from
 * @param to
 * @param selectedUsers
 * @throws Exception
 */
public void exportToPDF(HttpServletRequest request, HttpServletResponse response, List<Object> res,
        String filename, String title, String from, String to, List<Integer> selectedUsers) throws Exception {
    SimpleDateFormat sdf = Context.getDateFormat();
    Document document = new Document();

    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    HeaderFooter event = new HeaderFooter();
    writer.setPageEvent(event);

    document.open();
    document.setPageSize(PageSize.A4);

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().getFamilyName() + " "
            + Context.getAuthenticatedUser().getPersonName().getGivenName());// the name of the author

    PersonService ps = Context.getPersonService();

    String users = "";
    for (Integer usrId : selectedUsers) {
        users += ps.getPerson(usrId).getPersonName() + "; ";
    }

    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));

    title = MohTracUtil.getMessage("mohtracportal.report.title", null) + "      : " + title;
    String underLine = "";
    int count = 0;
    while (count < title.length()) {
        count += 1;
        underLine += "_";
    }

    document.add(fontTitle.process(title));// Report title
    if (from.trim().compareTo("") != 0)
        document.add(fontTitle
                .process("\n" + MohTracUtil.getMessage("mohtracportal.from", null) + "      : " + from));// from
    if (to.trim().compareTo("") != 0)
        document.add(
                fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.to", null) + "        : " + to));// to
    document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.report.created.on", null)
            + " : " + sdf.format(new Date())));// Report date
    document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.report.created.by", null)
            + " : " + Context.getAuthenticatedUser().getPersonName()));// Report
    // author

    Integer numberOfPatients = res.size();
    document.add(fontTitle.process("\n" + MohTracUtil.getMessage("mohtracportal.numberOfPatients", null) + " : "
            + numberOfPatients.toString()));// Number of patients

    if (users.trim().compareTo("") != 0)
        document.add(fontTitle.process(
                "\n" + MohTracUtil.getMessage("mohtracportal.patient.enterers", null) + " : " + users));// enterer(s)
    document.add(fontTitle.process("\n" + underLine));// Report title
    document.add(new Paragraph("\n\n"));

    boolean hasPrivToViewPatientNames = Context.getAuthenticatedUser().hasPrivilege("View Patient Names");

    // PdfLine line;
    PdfPTable table = null;
    if (hasPrivToViewPatientNames == true) {
        float[] colsWidth = { 1.2f, 5f, 2.7f, 2.7f, 4.2f, 2.7f };
        table = new PdfPTable(colsWidth);
    } else {
        float[] colsWidth = { 1.2f, 2.7f, 2.7f, 4.2f, 2.7f };
        table = new PdfPTable(colsWidth);
    }

    // column number
    table.setTotalWidth(540f);

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));
    BaseColor bckGroundTitle = new BaseColor(170, 170, 170);

    // table Header
    PdfPCell cell = new PdfPCell(
            fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.report.list.no", null)));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);

    if (hasPrivToViewPatientNames) {
        cell = new PdfPCell(
                fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.patient.names", null)));
        cell.setBackgroundColor(bckGroundTitle);
        table.addCell(cell);
    }

    cell = new PdfPCell(fontTitleSelector.process(MohTracPortalTag
            .getIdentifierTypeNameByIdAsString("" + MohTracConfigurationUtil.getTracNetIdentifierTypeId())));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(MohTracPortalTag.getIdentifierTypeNameByIdAsString(
            "" + MohTracConfigurationUtil.getLocalHealthCenterIdentifierTypeId())));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);

    cell = new PdfPCell(
            fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.patient.date.created", null) + "("
                    + Context.getDateFormat().toPattern() + ")"));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);

    cell = new PdfPCell(
            fontTitleSelector.process(MohTracUtil.getMessage("mohtracportal.numberOfEncounters", null)));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    // empty row
    FontSelector fontEmptyCell = new FontSelector();
    fontEmptyCell.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    int ids = 0;

    for (Object patient : res) {
        Object[] o = (Object[]) patient;
        ids += 1;

        cell = new PdfPCell(fontselector.process(ids + ""));
        if (o[2].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(238, 238, 238));
        if (o[3].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(224, 0, 0));
        table.addCell(cell);

        if (hasPrivToViewPatientNames) {
            String names = MohTracPortalTag.getPersonNames(Integer.valueOf(o[0].toString()));
            cell = new PdfPCell(fontselector.process(names + ""));
            if (names.compareTo("-") == 0)
                cell.setBackgroundColor(new BaseColor(224, 224, 240));
            if (o[2].toString().compareTo("1") == 0)
                cell.setBackgroundColor(new BaseColor(238, 238, 238));
            if (o[3].toString().compareTo("1") == 0)
                cell.setBackgroundColor(new BaseColor(224, 0, 0));
            table.addCell(cell);
        }

        String tracnetId = MohTracPortalTag.personIdentifierByPatientIdAndIdentifierTypeId(
                Integer.valueOf(o[0].toString()), MohTracConfigurationUtil.getTracNetIdentifierTypeId());
        cell = new PdfPCell(fontselector.process(tracnetId + ""));
        if (tracnetId.compareTo("-") == 0)
            cell.setBackgroundColor(new BaseColor(224, 224, 240));
        if (o[2].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(238, 238, 238));
        if (o[3].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(224, 0, 0));
        table.addCell(cell);

        String cohortId = MohTracPortalTag.personIdentifierByPatientIdAndIdentifierTypeId(
                Integer.valueOf(o[0].toString()),
                MohTracConfigurationUtil.getLocalHealthCenterIdentifierTypeId());
        cell = new PdfPCell(fontselector.process(cohortId + ""));
        if (cohortId.compareTo("-") == 0)
            cell.setBackgroundColor(new BaseColor(224, 224, 240));
        if (o[2].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(238, 238, 238));
        if (o[3].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(224, 0, 0));
        table.addCell(cell);

        cell = new PdfPCell(fontselector.process(sdf.format(o[1]) + ""));
        if (o[2].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(238, 238, 238));
        if (o[3].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(224, 0, 0));
        table.addCell(cell);

        String numberOfEncounters = MohTracPortalTag
                .getNumberOfEncounterByPatient(Integer.valueOf(o[0].toString()));
        cell = new PdfPCell(fontselector.process(numberOfEncounters + ""));
        if (numberOfEncounters.compareTo("-") == 0)
            cell.setBackgroundColor(new BaseColor(224, 224, 240));
        if (o[2].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(238, 238, 238));
        if (o[3].toString().compareTo("1") == 0)
            cell.setBackgroundColor(new BaseColor(224, 0, 0));
        table.addCell(cell);
    }

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

    log.info("pdf file created");
}

From source file:org.openmrs.module.tracpatienttransfer.util.FileExporter.java

License:Open Source License

/**
 * @param request/*from w  w w  . java  2  s. c  o m*/
 * @param response
 * @param res
 * @param filename
 * @param title
 * @throws Exception
 */
public void exportToPDF(HttpServletRequest request, HttpServletResponse response, List<Integer> res,
        String filename, String title) throws Exception {

    SimpleDateFormat sdf = Context.getDateFormat();

    Document document = new Document();

    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));

    float[] colsWidth = { 1.6f, 2.7f, 2.7f, 8f, 10.5f, 4f, 5f, 7.5f };//, 9.3f };
    PdfPTable table = new PdfPTable(colsWidth); // column number

    HeaderFooter event = new HeaderFooter(table);
    writer.setPageEvent(event);

    document.setPageSize(PageSize.A4.rotate());
    document.open();

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().getFamilyName() + " "
            + Context.getAuthenticatedUser().getPersonName().getGivenName());// the name of the author

    ObsService os = Context.getObsService();
    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.HELVETICA, 8.0f, Font.BOLD));
    document.add(
            fontTitle.process(MohTracUtil.getMessage("tracpatienttransfer.report", null) + "    : " + title));// Report title
    document.add(fontTitle.process("\n" + MohTracUtil.getMessage("tracpatienttransfer.report.createdon", null)
            + " : " + sdf.format(new Date())));// Report date
    document.add(fontTitle.process("\n" + MohTracUtil.getMessage("tracpatienttransfer.report.createdby", null)
            + " : " + Context.getAuthenticatedUser().getPersonName()));// Report
    // author
    document.add(new Paragraph("\n"));

    Paragraph para = new Paragraph("" + title.toUpperCase());
    para.setAlignment(Element.ALIGN_CENTER);
    para.setFont(new Font(FontFamily.HELVETICA, 8.0f, Font.BOLD));
    document.add(para);

    table.setWidthPercentage(100.0f);

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.HELVETICA, 8, Font.BOLD));

    // top line of table
    for (int i = 0; i < 8; i++) {
        PdfPCell pdfPCell = new PdfPCell(fontTitleSelector.process(" "));
        pdfPCell.setBorder(PdfPCell.BOTTOM);
        table.addCell(pdfPCell);
    }

    boolean hasRoleToViewPatientsNames = Context.getAuthenticatedUser().hasPrivilege("View Patient Names");

    // table Header
    PdfPCell cell = new PdfPCell(
            fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.number")));
    cell.setBorder(Rectangle.LEFT);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(Context.getPatientService()
            .getPatientIdentifierType(TracPatientTransferConfigurationUtil.getTracNetIdentifierTypeId())
            .getName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(
            fontTitleSelector.process(Context.getPatientService()
                    .getPatientIdentifierType(
                            TracPatientTransferConfigurationUtil.getLocalHealthCenterIdentifierTypeId())
                    .getName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    if (hasRoleToViewPatientsNames) {
        cell = new PdfPCell(
                fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.names")));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
    }

    cell = new PdfPCell(
            fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.reasonofexit")));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(
            fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.general.exitwhen")));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(ContextProvider.getMessage("Encounter.provider")));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(
            fontTitleSelector.process(ContextProvider.getMessage("tracpatienttransfer.report.location")));
    cell.setBorder(Rectangle.RIGHT);
    table.addCell(cell);

    //      cell = new PdfPCell(fontTitleSelector
    //            .process("Resumed? (reason - by who?)"));
    //      cell.setBorder(Rectangle.RIGHT);
    //      table.addCell(cell);

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.HELVETICA, 7, Font.NORMAL));

    // empty row
    FontSelector fontEmptyCell = new FontSelector();
    fontEmptyCell.addFont(new Font(FontFamily.HELVETICA, 7, Font.NORMAL));

    int ids = 0;

    for (Integer obsId : res) {
        Obs obs = os.getObs(obsId);
        Integer patientId = obs.getPersonId();
        ids += 1;

        cell = new PdfPCell(fontselector.process(ids + "."));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        String tracnetId = TransferOutInPatientTag.personIdentifierByPatientIdAndIdentifierTypeId(patientId,
                TracPatientTransferConfigurationUtil.getTracNetIdentifierTypeId());
        cell = new PdfPCell(fontselector.process(tracnetId + ""));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        String localIdentifierTypeId = TransferOutInPatientTag.personIdentifierByPatientIdAndIdentifierTypeId(
                patientId, TracPatientTransferConfigurationUtil.getLocalHealthCenterIdentifierTypeId());
        cell = new PdfPCell(fontselector.process(localIdentifierTypeId + ""));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        if (hasRoleToViewPatientsNames) {
            String names = TransferOutInPatientTag.getPersonNames(patientId);
            cell = new PdfPCell(fontselector.process(names + ""));
            if (ids == 1)
                cell.setBorder(Rectangle.TOP);
            else
                cell.setBorder(Rectangle.NO_BORDER);
            table.addCell(cell);
        }

        String conceptValue = TransferOutInPatientTag.conceptValueByObs(obs);

        conceptValue += ((obs.getValueCoded().getConceptId()
                .intValue() == TransferOutInPatientConstant.PATIENT_TRANSFERED_OUT)
                        ? " (" + TransferOutInPatientTag.getObservationValueFromEncounter(obs,
                                TransferOutInPatientConstant.TRANSFER_OUT_TO_A_LOCATION) + ")"
                        : (obs.getValueCoded().getConceptId()
                                .intValue() == TransferOutInPatientConstant.PATIENT_DEAD)
                                        ? " (" + TransferOutInPatientTag.getObservationValueFromEncounter(obs,
                                                TransferOutInPatientConstant.CAUSE_OF_DEATH) + ")"
                                        : "");

        cell = new PdfPCell(fontselector.process(conceptValue));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        cell = new PdfPCell(fontselector.process(sdf.format(obs.getObsDatetime())));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        /*
         * cell=newPdfPCell(fontselector.process(TransferOutInPatientTag.
         * getProviderByObs(obs))); if(ids==1)
         * cell.setBorder(Rectangle.TOP); else
         * cell.setBorder(Rectangle.NO_BORDER);
         */table.addCell(cell);

        cell = new PdfPCell(fontselector.process(obs.getLocation().getName()));
        if (ids == 1)
            cell.setBorder(Rectangle.TOP);
        else
            cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);

        //         cell = new PdfPCell(fontselector.process(TransferOutInPatientTag
        //               .obsVoidedReason(obs)));
        //         if (ids == 1)
        //            cell.setBorder(Rectangle.TOP);
        //         else
        //            cell.setBorder(Rectangle.NO_BORDER);
        //         table.addCell(cell);
    }

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

    log.info("pdf file created");
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

License:Open Source License

/**
 * Writes given charts into target PDF file.
 * /*from   ww  w  .j a  v  a2 s  .c  om*/
 * @param file
 * @param charts
 * @param annotations
 * @throws IOException
 */
public synchronized void writeChartAsPDF(File file, List<Object> chartObjects) throws IOException {
    Rectangle pagesize = new Rectangle(this.width, this.height);
    Document document = new Document(pagesize, 50, 50, 50, 50);
    try {
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        document.addAuthor("CDK-Taverna 2.0");
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        for (int i = 0; i < chartObjects.size(); i++) {
            Object obj = chartObjects.get(i);
            if (obj instanceof JFreeChart) {
                JFreeChart chart = (JFreeChart) obj;
                this.addChartPageToPDF(chart, cb);
            } else if (obj instanceof String) {
                String annotation = (String) obj;
                this.addAnnotationToPDF(annotation, document);
            }
            document.newPage();
        }
    } catch (DocumentException e) {
        ErrorLogger.getInstance().writeError(CDKTavernaException.CANT_CREATE_PDF_FILE + file.getPath(),
                this.getClass().getSimpleName(), e);
    }
    document.close();
}

From source file:org.opentox.io.publishable.PDFObject.java

License:Open Source License

public void publish(YaqpIOStream stream) throws YaqpException {
    if (stream == null) {
        throw new NullPointerException("Cannot public pdf to a null output stream");
    }/*  w ww  .jav  a  2  s .co  m*/
    try {
        Document doc = new Document();
        try {
            PdfWriter.getInstance(doc, (OutputStream) stream.getStream());
        } catch (ClassCastException ex) {
            throw new ClassCastException("The stream you provided is not a valid output stream");
        }
        doc.open();
        doc.addAuthor(pdfAuthor);
        doc.addCreationDate();
        doc.addProducer();
        doc.addSubject(subject);
        doc.addCreator(pdfCreator);
        doc.addTitle(pdfTitle);
        doc.addKeywords(pdfKeywords);
        doc.addHeader("License", "GNU GPL v3");
        Image image = null;
        try {
            image = Image.getInstance(new URL(OpenToxLogoUrl));
        } catch (Exception ex) {// OpenTox Logo was not found on the web...
            try {// use the cached image instead
                YaqpLogger.LOG.log(new Trace(getClass(), "OpenTox Logo not found at " + OpenToxLogoUrl));
                image = Image.getInstance(alternativeLogoPath);
            } catch (Exception ex1) {// if no image at local folder
                YaqpLogger.LOG.log(new Debug(getClass(),
                        "OpenTox Logo not found at " + alternativeLogoPath + " :: " + ex1));
            }
        }
        if (image != null) {
            image.scalePercent(40);
            image.setAnnotation(new Annotation(0, 0, 0, 0, "http://opentox.org"));
            Chunk ck_ot = new Chunk(image, -5, -30);
            doc.add(ck_ot);
        }
        try {
            Image yaqp = Image.getInstance(yaqpLogo);
            yaqp.scalePercent(30);
            yaqp.setAnnotation(new Annotation(0, 0, 0, 0, "https://opentox.ntua.gr"));
            yaqp.setAlt("YAQP(R), yet another QSAR Project");
            Chunk ck_yaqp = new Chunk(yaqp, 15, -30);
            doc.add(ck_yaqp);
        } catch (Exception ex) {
            YaqpLogger.LOG
                    .log(new Warning(getClass(), "YAQP Logo not found at " + kinkyDesignLogo + " :: " + ex));
        }
        doc.add(new Paragraph("\n\n\n"));
        for (Element e : elements) {
            doc.add(e);
        }
        doc.close();
    } catch (DocumentException ex) {
        String message = "Error while generating PDF representation.";
        YaqpLogger.LOG.log(new Warning(getClass(), message));
        throw new YaqpException(XPDF18, message, ex);
    }

}

From source file:org.restate.project.controller.PaymentReceiptController.java

License:Open Source License

@RequestMapping(method = RequestMethod.GET, value = "receipt.print")
public void downloadDocument(HttpServletResponse response,
        @RequestParam(value = "id", required = false) Integer id) throws Exception {

    if (id == null) {
        return;/*from  w w w.j  ava  2  s .c  o m*/
    }

    // creation of the document with a certain size and certain margins
    // may want to use PageSize.LETTER instead
    // Document document = new Document(PageSize.A4, 50, 50, 50, 50);

    Document doc = new Document();
    PdfWriter docWriter = null;

    DecimalFormat df = new DecimalFormat("0.00");
    File tmpFile = File.createTempFile("paymentReceipt", ".pdf");

    try {

        //special font sizes
        Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12);

        //file path

        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(tmpFile));

        //document header attributes
        doc.addAuthor("betterThanZero");
        doc.addCreationDate();
        doc.addProducer();
        doc.addCreator("MySampleCode.com");
        doc.addTitle("Report with Column Headings");
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        Paragraph paragraph = new Paragraph("iText  is a library that allows you to create and "
                + "manipulate PDF documents. It enables developers looking to enhance web and other "
                + "applications with dynamic PDF document generation and/or manipulation.");

        //specify column widths
        float[] columnWidths = { 1.5f, 2f, 5f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(90f);

        //insert column headings
        insertCell(table, "Order No", Element.ALIGN_RIGHT, 1, bfBold12);
        insertCell(table, "Account No", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "Account Name", Element.ALIGN_LEFT, 1, bfBold12);
        insertCell(table, "Order Total", Element.ALIGN_RIGHT, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);
        //create section heading by cell merging
        insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);
        double orderTotal, total = 0;

        //just some random data to fill
        for (int x = 1; x < 5; x++) {

            insertCell(table, "10010" + x, Element.ALIGN_RIGHT, 1, bf12);
            insertCell(table, "ABC00" + x, Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, "This is Customer Number ABC00" + x, Element.ALIGN_LEFT, 1, bf12);

            orderTotal = Double.valueOf(df.format(Math.random() * 1000));
            total = total + orderTotal;
            insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12);

        }
        //merge the cells to create a footer for that section
        insertCell(table, "New York Total...", Element.ALIGN_RIGHT, 3, bfBold12);
        insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12);

        //repeat the same as above to display another location
        insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);
        insertCell(table, "California Orders ...", Element.ALIGN_LEFT, 4, bfBold12);
        orderTotal = 0;

        for (int x = 1; x < 7; x++) {

            insertCell(table, "20020" + x, Element.ALIGN_RIGHT, 1, bf12);
            insertCell(table, "XYZ00" + x, Element.ALIGN_LEFT, 1, bf12);
            insertCell(table, "This is Customer Number XYZ00" + x, Element.ALIGN_LEFT, 1, bf12);

            orderTotal = Double.valueOf(df.format(Math.random() * 1000));
            total = total + orderTotal;
            insertCell(table, df.format(orderTotal), Element.ALIGN_RIGHT, 1, bf12);

        }
        insertCell(table, "California Total...", Element.ALIGN_RIGHT, 3, bfBold12);
        insertCell(table, df.format(total), Element.ALIGN_RIGHT, 1, bfBold12);

        //add the PDF table to the paragraph
        paragraph.add(table);
        // add the paragraph to the document
        doc.add(paragraph);

    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();

        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }

        response.setHeader("Content-disposition", "attachment; filename=" + "sampleDoc" + ".pdf");
        response.setContentType("application/pdf");
        OutputStream outputStream = response.getOutputStream();
        FileInputStream fileInputStream = new FileInputStream(tmpFile);

        IOUtils.copy(fileInputStream, outputStream);
        fileInputStream.close();
        outputStream.flush();

        tmpFile.delete();
    }

}

From source file:org.sharegov.cirm.utils.PDFExportUtil.java

License:Apache License

private static void addMetaData(Document doc) {
    doc.addTitle("My title");
    doc.addSubject("My subject");
    doc.addKeywords("itext, java, export");
    doc.addAuthor("");
    doc.addCreator("");
}

From source file:org.sistemafinanciero.rest.impl.CuentaBancariaRESTService.java

License:Apache License

@Override
public Response getEstadoCuentaPdf(BigInteger idCuentaBancaria, Long desde, Long hasta) {
    Date dateDesde = (desde != null ? new Date(desde) : null);
    Date dateHasta = (desde != null ? new Date(hasta) : null);

    //dando formato a las fechas
    SimpleDateFormat fechaformato = new SimpleDateFormat("dd/MM/yyyy");
    String fechaDesde = fechaformato.format(dateDesde);
    String fechaHasta = fechaformato.format(dateHasta);

    Set<Titular> titulares = cuentaBancariaServiceNT.getTitulares(idCuentaBancaria, true);
    List<String> emails = new ArrayList<String>();
    for (Titular titular : titulares) {
        PersonaNatural personaNatural = titular.getPersonaNatural();
        String email = personaNatural.getEmail();
        if (email != null)
            emails.add(email);//from  w w  w  .jav a 2s .co m
    }
    CuentaBancariaView cuentaBancariaView = cuentaBancariaServiceNT.findById(idCuentaBancaria);
    List<EstadocuentaBancariaView> list = cuentaBancariaServiceNT.getEstadoCuenta(idCuentaBancaria, dateDesde,
            dateHasta);

    /**obteniendo la moneda y dando formato**/
    Moneda moneda = monedaServiceNT.findById(cuentaBancariaView.getIdMoneda());
    NumberFormat df1 = NumberFormat.getCurrencyInstance();
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    dfs.setCurrencySymbol("");
    dfs.setGroupingSeparator(',');
    dfs.setMonetaryDecimalSeparator('.');
    ((DecimalFormat) df1).setDecimalFormatSymbols(dfs);

    /**PDF**/
    ByteArrayOutputStream outputStream = null;
    outputStream = new ByteArrayOutputStream();

    Document document = new Document();
    try {
        PdfWriter.getInstance(document, outputStream);
        document.open();

        document.addTitle("Estado de Cuenta");
        document.addSubject("Estado de Cuenta");
        document.addKeywords("email");
        document.addAuthor("Cooperativa de Ahorro y Crdito Caja Ventura");
        document.addCreator("Cooperativa de Ahorro y Crdito Caja Ventura");

        Paragraph saltoDeLinea = new Paragraph();
        document.add(saltoDeLinea);
    } catch (DocumentException e1) {
        e1.printStackTrace();
    }

    /******************* TITULO ******************/
    try {
        //Image img = Image.getInstance("/images/logo_coop_contrato.png");
        Image img = Image.getInstance("//usr//share//jboss//archivos//logoCartilla//logo_coop_contrato.png");
        img.setAlignment(Image.LEFT | Image.UNDERLYING);
        document.add(img);

        Paragraph parrafoPrincipal = new Paragraph();
        parrafoPrincipal.setSpacingAfter(30);
        //parrafoPrincipal.setSpacingBefore(50);
        parrafoPrincipal.setAlignment(Element.ALIGN_CENTER);
        parrafoPrincipal.setIndentationLeft(100);
        parrafoPrincipal.setIndentationRight(50);

        Paragraph parrafoSecundario = new Paragraph();
        parrafoSecundario.setSpacingAfter(20);
        parrafoSecundario.setSpacingBefore(-20);
        parrafoSecundario.setAlignment(Element.ALIGN_LEFT);
        parrafoSecundario.setIndentationLeft(160);
        parrafoSecundario.setIndentationRight(10);

        Chunk titulo = new Chunk("ESTADO DE CUENTA");
        Font fuenteTitulo = new Font(FontFamily.UNDEFINED, 13, Font.BOLD);
        titulo.setFont(fuenteTitulo);
        parrafoPrincipal.add(titulo);

        Font fuenteDatosCliente = new Font(FontFamily.UNDEFINED, 10);
        Date fechaSistema = new Date();
        SimpleDateFormat formatFecha = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        String fechaActual = formatFecha.format(fechaSistema);

        if (cuentaBancariaView.getTipoPersona() == TipoPersona.NATURAL) {
            Chunk clientePNNombres = new Chunk("CLIENTE       : " + cuentaBancariaView.getSocio() + "\n");
            Chunk clientePNDni = new Chunk(cuentaBancariaView.getTipoDocumento() + "                : "
                    + cuentaBancariaView.getNumeroDocumento() + "\n");
            //Chunk clientePNTitulares = new Chunk("TITULAR(ES): " + cuentaBancariaView.getTitulares() + "\n");
            Chunk clientePNFecha = new Chunk("FECHA          : " + fechaActual + "\n\n");

            Chunk tipoCuentaPN = new Chunk("CUENTA " + cuentaBancariaView.getTipoCuenta() + " N "
                    + cuentaBancariaView.getNumeroCuenta() + "\n");
            Chunk tipoMonedaPN;

            if (cuentaBancariaView.getIdMoneda().compareTo(BigInteger.ZERO) == 0) {
                tipoMonedaPN = new Chunk("MONEDA: " + "DOLARES AMERICANOS" + "\n");
            } else if (cuentaBancariaView.getIdMoneda().compareTo(BigInteger.ONE) == 0) {
                tipoMonedaPN = new Chunk("MONEDA: " + "NUEVOS SOLES" + "\n");
            } else {
                tipoMonedaPN = new Chunk("MONEDA: " + "EUROS" + "\n");
            }

            Chunk fechaEstadoCuenta = new Chunk("ESTADO DE CUENTA DEL " + fechaDesde + " AL " + fechaHasta);
            //obteniedo titulares
            /*String tPN = cuentaBancariaView.getTitulares();
            String[] arrayTitulares = tPN.split(",");
            Chunk clientePNTitulares = new Chunk("Titular(es):");
            for (int i = 0; i < arrayTitulares.length; i++) {
               String string = arrayTitulares[i];
            }*/

            clientePNNombres.setFont(fuenteDatosCliente);
            clientePNDni.setFont(fuenteDatosCliente);
            //clientePNTitulares.setFont(fuenteDatosCliente);
            clientePNFecha.setFont(fuenteDatosCliente);
            tipoCuentaPN.setFont(fuenteDatosCliente);
            tipoMonedaPN.setFont(fuenteDatosCliente);
            fechaEstadoCuenta.setFont(fuenteDatosCliente);

            parrafoSecundario.add(clientePNNombres);
            parrafoSecundario.add(clientePNDni);
            //parrafoSecundario.add(clientePNTitulares);
            parrafoSecundario.add(clientePNFecha);
            parrafoSecundario.add(tipoCuentaPN);
            parrafoSecundario.add(tipoMonedaPN);
            parrafoSecundario.add(fechaEstadoCuenta);

        } else {
            Chunk clientePJNombre = new Chunk("CLIENTE       : " + cuentaBancariaView.getSocio() + "\n");
            Chunk clientePJRuc = new Chunk(cuentaBancariaView.getTipoDocumento() + "               : "
                    + cuentaBancariaView.getNumeroDocumento() + "\n");
            //Chunk clientePJTitulares = new Chunk("TITULAR(ES): " + cuentaBancariaView.getTitulares() + "\n");
            Chunk clientePJFecha = new Chunk("FECHA          : " + fechaActual + "\n\n");

            Chunk tipoCuentaPJ = new Chunk("CUENTA " + cuentaBancariaView.getTipoCuenta() + " N "
                    + cuentaBancariaView.getNumeroCuenta() + "\n");
            Chunk tipoMonedaPJ;

            if (cuentaBancariaView.getIdMoneda().compareTo(BigInteger.ZERO) == 0) {
                tipoMonedaPJ = new Chunk("MONEDA: " + "DOLARES AMERICANOS" + "\n");
            } else if (cuentaBancariaView.getIdMoneda().compareTo(BigInteger.ONE) == 0) {
                tipoMonedaPJ = new Chunk("MONEDA: " + "NUEVOS SOLES" + "\n");
            } else {
                tipoMonedaPJ = new Chunk("MONEDA: " + "EUROS" + "\n");
            }

            Chunk fechaEstadoCuenta = new Chunk("ESTADO DE CUENTA DEL " + fechaDesde + " AL " + fechaHasta);
            //obteniedo titulares
            /*String tPN = cuentaBancariaView.getTitulares();
            String[] arrayTitulares = tPN.split(",");
            Chunk clientePNTitulares = new Chunk("Titular(es):");
            for (int i = 0; i < arrayTitulares.length; i++) {
               String string = arrayTitulares[i];
            }*/

            clientePJNombre.setFont(fuenteDatosCliente);
            clientePJRuc.setFont(fuenteDatosCliente);
            //clientePJTitulares.setFont(fuenteDatosCliente);
            clientePJFecha.setFont(fuenteDatosCliente);
            tipoCuentaPJ.setFont(fuenteDatosCliente);
            tipoMonedaPJ.setFont(fuenteDatosCliente);
            fechaEstadoCuenta.setFont(fuenteDatosCliente);

            parrafoSecundario.add(clientePJNombre);
            parrafoSecundario.add(clientePJRuc);
            //parrafoSecundario.add(clientePJTitulares);
            parrafoSecundario.add(clientePJFecha);
            parrafoSecundario.add(tipoCuentaPJ);
            parrafoSecundario.add(tipoMonedaPJ);
            parrafoSecundario.add(fechaEstadoCuenta);

        }

        document.add(parrafoPrincipal);
        document.add(parrafoSecundario);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Font fontTableCabecera = new Font(FontFamily.UNDEFINED, 9, Font.BOLD);
    Font fontTableCuerpo = new Font(FontFamily.UNDEFINED, 9, Font.NORMAL);

    float[] columnWidths = { 5f, 4f, 2.8f, 10f, 3.5f, 4f, 2.8f };
    PdfPTable table = new PdfPTable(columnWidths);
    table.setWidthPercentage(100);

    PdfPCell cellFechaHoraCabecera = new PdfPCell(new Paragraph("FECHA Y HORA", fontTableCabecera));
    PdfPCell cellTransaccionCabecera = new PdfPCell(new Paragraph("TIPO TRANS.", fontTableCabecera));
    PdfPCell cellOperacionCabecera = new PdfPCell(new Paragraph("NUM. OP.", fontTableCabecera));
    PdfPCell cellReferenciaCabecera = new PdfPCell(new Paragraph("REFERENCIA", fontTableCabecera));
    PdfPCell cellMontoCabecera = new PdfPCell(new Paragraph("MONTO", fontTableCabecera));
    PdfPCell cellSaldoDisponibleCabecera = new PdfPCell(new Paragraph("DISPONIBLE", fontTableCabecera));
    PdfPCell cellEstado = new PdfPCell(new Paragraph("ESTADO", fontTableCabecera));

    table.addCell(cellFechaHoraCabecera);
    table.addCell(cellTransaccionCabecera);
    table.addCell(cellOperacionCabecera);
    table.addCell(cellReferenciaCabecera);
    table.addCell(cellMontoCabecera);
    table.addCell(cellSaldoDisponibleCabecera);
    table.addCell(cellEstado);

    for (EstadocuentaBancariaView estadocuentaBancariaView : list) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String fecHoraFormat = sdf.format(estadocuentaBancariaView.getHora());

        PdfPCell cellFechaHora = new PdfPCell(new Paragraph(fecHoraFormat, fontTableCuerpo));
        table.addCell(cellFechaHora);
        PdfPCell cellTipoTrasaccion = new PdfPCell(
                new Paragraph(estadocuentaBancariaView.getTipoTransaccionTransferencia(), fontTableCuerpo));
        table.addCell(cellTipoTrasaccion);
        PdfPCell cellNumOperacion = new PdfPCell(
                new Paragraph(estadocuentaBancariaView.getNumeroOperacion().toString(), fontTableCuerpo));
        table.addCell(cellNumOperacion);
        PdfPCell cellReferencia = new PdfPCell(
                new Paragraph(estadocuentaBancariaView.getReferencia(), fontTableCuerpo));
        table.addCell(cellReferencia);
        PdfPCell cellMonto = new PdfPCell(
                new Paragraph(df1.format(estadocuentaBancariaView.getMonto()), fontTableCuerpo));
        table.addCell(cellMonto);
        PdfPCell cellSaldoDisponible = new PdfPCell(
                new Paragraph(df1.format(estadocuentaBancariaView.getSaldoDisponible()), fontTableCuerpo));
        table.addCell(cellSaldoDisponible);
        if (estadocuentaBancariaView.getEstado()) {
            PdfPCell cellEstadoActivo = new PdfPCell(new Paragraph("Activo", fontTableCuerpo));
            table.addCell(cellEstadoActivo);
        } else {
            PdfPCell cellEstadoExtornado = new PdfPCell(new Paragraph("Extornado", fontTableCuerpo));
            table.addCell(cellEstadoExtornado);
        }
    }

    Paragraph saldoDisponible = new Paragraph();
    saldoDisponible.setAlignment(Element.ALIGN_CENTER);
    Chunk textoSaldoDisponible = new Chunk(
            "SALDO DISPONIBLE: " + moneda.getSimbolo() + df1.format(cuentaBancariaView.getSaldo()),
            fontTableCabecera);
    textoSaldoDisponible.setFont(fontTableCabecera);
    saldoDisponible.add(textoSaldoDisponible);

    try {
        document.add(table);
        document.add(saldoDisponible);
    } catch (DocumentException e) {
        e.printStackTrace();
    }

    document.close();

    return Response.ok(outputStream.toByteArray()).type("application/pdf").build();
}