Example usage for com.itextpdf.text Rectangle NO_BORDER

List of usage examples for com.itextpdf.text Rectangle NO_BORDER

Introduction

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

Prototype

int NO_BORDER

To view the source code for com.itextpdf.text Rectangle NO_BORDER.

Click Source Link

Document

This represents a rectangle without borders.

Usage

From source file:org.fossa.rolp.util.PdfFormatHelper.java

License:Open Source License

public static PdfPTable buildFooterHalbjahrDatumLine(String datumString, Font footerFont)
        throws DocumentException {
    PdfPCell leftCell = new PdfPCell(new Phrase(datumString, footerFont));
    leftCell.setBorder(Rectangle.NO_BORDER);
    leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
    centerCell.setBorder(Rectangle.NO_BORDER);
    centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
    rightCell.setBorder(Rectangle.NO_BORDER);
    rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(100f);// w w  w.j  a v a2 s  . c  o  m
    table.addCell(leftCell);
    table.addCell(centerCell);
    table.addCell(rightCell);
    table.setWidths(new float[] { 0.3f, 0.3f, 0.3f });
    return table;
}

From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java

License:GNU General Public License

private PdfPTable createColontitleTable(String topLeft, String topRight, String bottomLeft,
        String bottomRight) {//  w w w. ja  va2s  .  c  o m
    PdfPTable head = new PdfPTable(2);
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        // colontitle.setLeading(0);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        // cell.setPaddingLeft(2);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        Paragraph p = new Paragraph(topRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setPaddingBottom(6);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setPaddingLeft(3);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomLeft, getSansRegularBold(18));
        p.setAlignment(Paragraph.ALIGN_LEFT);
        p.setExtraParagraphSpace(0);
        p.setIndentationLeft(0);
        p.setSpacingBefore(0);
        cell.setPhrase(p);
        // cell.addElement(p);
        head.addCell(cell);
    }
    {
        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setPaddingTop(2);
        cell.setPaddingBottom(6);
        cell.setBorder(Rectangle.TOP);
        cell.setBorderWidthTop(2);
        cell.setBorderColor(SORTAVALA_GREEN);
        Paragraph p = new Paragraph(bottomRight, getSansRegularBold(10));
        p.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPhrase(p);
        head.addCell(cell);
    }
    final Document document = myDoc;
    Rectangle page = document.getPageSize();
    head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
    return head;
}

From source file:org.inspira.condominio.pdf.DocumentoEgresos.java

public void exportarPdf(String destino) throws IOException, DocumentException {
    File file = new File(destino);
    file.getParentFile().mkdirs();/* w  w  w. ja va  2  s  .c o  m*/
    PdfWriter.getInstance(documento, new FileOutputStream(file));
    documento.open();
    documento.add(new Paragraph(
            "Periodo: ".concat(
                    DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(new Date())),
            F_NORMAL));
    documento.add(new Paragraph(admin, F_NORMAL));
    Paragraph heading = new Paragraph("Gastos ".concat(tipoDeGasto),
            new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD, new BaseColor(0x000000)));
    heading.setSpacingBefore(16f);
    heading.setSpacingAfter(16f);
    Paragraph heading2 = new Paragraph("Autoriz",
            new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000)));
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    Paragraph heading3 = new Paragraph("Vo. Bo.",
            new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL, new BaseColor(0x000000)));
    PdfPCell cell1 = new PdfPCell(heading2);
    cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell1.setColspan(1);
    cell1.setFixedHeight(20f);
    cell1.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell2 = new PdfPCell(heading3);
    cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell2.setColspan(1);
    cell2.setFixedHeight(20f);
    cell2.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);
    table.setSpacingBefore(16f);
    table.setSpacingAfter(32f);

    documento.add(heading);
    agregarTablaEgresos(egresos);
    documento.add(table);
    agregarZonaVistoBueno();
    documento.close();
}

From source file:org.inspira.condominio.pdf.DocumentoEgresos.java

private void agregarZonaVistoBueno() throws DocumentException {
    PdfPCell cell1 = new PdfPCell(new Phrase("", F_NORMAL));
    cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell1.setColspan(5);/* www . j  a v  a  2  s.  c  o m*/
    cell1.setFixedHeight(20f);
    cell1.setBorder(Rectangle.BOTTOM);
    PdfPCell cell2 = new PdfPCell(new Phrase("", F_NORMAL));
    cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell2.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell2.setColspan(1);
    cell2.setFixedHeight(20f);
    cell2.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell3 = new PdfPCell(new Phrase("", F_NORMAL));
    cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell3.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell3.setColspan(5);
    cell3.setFixedHeight(20f);
    cell3.setBorder(Rectangle.BOTTOM);
    PdfPCell cell4 = new PdfPCell(new Phrase(presidente, F_NORMAL));
    cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell4.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell4.setColspan(5);
    cell4.setFixedHeight(20f);
    cell4.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell5 = new PdfPCell(new Phrase("", F_NORMAL));
    cell5.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell5.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell5.setColspan(1);
    cell5.setFixedHeight(20f);
    cell5.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell6 = new PdfPCell(new Phrase("", F_NORMAL));
    cell6.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell6.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell6.setColspan(5);
    cell6.setFixedHeight(20f);
    cell6.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell7 = new PdfPCell(new Phrase(("(Administrador)"), F_NORMAL));
    cell7.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell7.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell7.setColspan(5);
    cell7.setFixedHeight(20f);
    cell7.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell8 = new PdfPCell(new Phrase("", F_NORMAL));
    cell8.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell8.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell8.setColspan(1);
    cell8.setFixedHeight(20f);
    cell8.setBorder(Rectangle.NO_BORDER);
    PdfPCell cell9 = new PdfPCell(new Phrase(("(Presidente comit de vigilancia)"), F_NORMAL));
    cell9.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    cell9.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell9.setColspan(5);
    cell9.setFixedHeight(20f);
    cell9.setBorder(Rectangle.NO_BORDER);
    PdfPTable table = new PdfPTable(11);
    table.setWidthPercentage(100);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    table.addCell(cell4);
    table.addCell(cell5);
    table.addCell(cell6);
    table.addCell(cell7);
    table.addCell(cell8);
    table.addCell(cell9);
    documento.add(table);
}

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");

    /*// w w w .  j av  a 2s.co 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.tracpatienttransfer.util.FileExporter.java

License:Open Source License

/**
 * @param request//from  www.ja  v a2 s . co 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.opensrp.web.utils.PdfUtil.java

License:Open Source License

public static ByteArrayOutputStream generatePdf(List<String> data, int width, int height, int copiesImage,
        int columnLimit) {
    try {/*from  w w  w.j a  va  2  s .  co  m*/
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        Document document = new Document();
        document.setMargins(MARGINS[0], MARGINS[1], MARGINS[2], MARGINS[3]);

        PdfWriter.getInstance(document, byteArrayOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(columnLimit);
        table.setTotalWidth(TABLE_WIDTH);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);

        int length = 0;
        int count = 0;

        for (String str : data) {
            if (str.length() > 0 && str.length() <= 5) {
                length = 54;
            } else if (str.length() >= 6 && str.length() <= 9) {
                length = 44;
            } else if (str.length() >= 10 && str.length() <= 11) {
                length = 36;
            } else if (str.length() >= 12 && str.length() <= 14) {
                length = 27;
            } else if (str.length() >= 15 && str.length() <= 17) {
                length = 22;
            } else {
                length = 15;
            }
            Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
            hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);

            QRCodeWriter qrCodeWriter = new QRCodeWriter();
            BitMatrix byteMatrix = null;

            byteMatrix = qrCodeWriter.encode(str, BarcodeFormat.QR_CODE, width, height, hintMap);

            int matrixWidth = byteMatrix.getWidth();
            int matrixHeight = byteMatrix.getHeight();
            BufferedImage image = new BufferedImage(matrixWidth, matrixHeight, BufferedImage.TYPE_INT_RGB);
            image.createGraphics();
            Graphics2D graphics = (Graphics2D) image.getGraphics();
            graphics.setColor(Color.WHITE);
            graphics.fillRect(0, 0, matrixWidth + 5, matrixHeight + 5);
            graphics.setFont(graphics.getFont().deriveFont(13f));
            graphics.setColor(Color.BLACK);
            graphics.drawString(str, length, height - 10);
            for (int i = 0; i < matrixHeight; i++) {
                for (int j = 0; j < matrixHeight; j++) {
                    if (byteMatrix.get(i, j)) {
                        graphics.fillRect((i), j, 1, 1);
                    }
                }
            }
            Image itextImage = null;
            itextImage = Image.getInstance(Toolkit.getDefaultToolkit().createImage(image.getSource()), null);

            for (int i = 0; i < copiesImage; i++) {
                PdfPCell cell = new PdfPCell(itextImage);
                cell.setBorder(Rectangle.NO_BORDER);
                count++;
                table.addCell(cell);
            }
        }
        for (int i = 0; i < 6; i++) {
            if (count % columnLimit != 0) {
                PdfPCell cell = new PdfPCell(new Phrase());
                cell.setBorder(Rectangle.NO_BORDER);
                table.addCell(cell);
                count++;
            }
        }
        document.add(table);
        document.close();

        return byteArrayOutputStream;
    } catch (Exception e) {
        return null;
    }
}

From source file:org.qnot.passtab.PDFOutput.java

License:Open Source License

private void addCell(PdfPTable table, String str, boolean bold, boolean fill, boolean rightBorder,
        boolean bottomBorder) {
    Phrase phrase = withColor ? new Phrase(str, bold ? fontBold : font) : new Phrase(str, font);

    PdfPCell cell = new PdfPCell(phrase);

    cell.setBorder(Rectangle.NO_BORDER);
    cell.setPadding(0f);//from  w w w.ja  v  a  2  s .c  o  m
    cell.setPaddingTop(2f);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);

    if (rightBorder) {
        cell.setBorderWidthRight(1f);
        cell.setPaddingRight(3f);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    }
    if (bottomBorder) {
        cell.setBorderWidthBottom(1f);
        cell.setPaddingBottom(3f);
    }

    if (fill && this.withColor) {
        cell.setGrayFill(0.80f);
    }

    table.addCell(cell);
}

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

License:Apache License

private void addCell(PdfPTable table, String name, int align, Font font, BaseColor color) {
    PdfPCell cell = new PdfPCell(new Phrase(name, font));
    cell.setHorizontalAlignment(align);/*  ww  w  . j  a va  2s.  co  m*/
    cell.setBorder(Rectangle.NO_BORDER);
    if (color != null)
        cell.setBackgroundColor(color);
    table.addCell(cell);
}

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

License:Apache License

private void addCell(PdfPCell cell, PdfPTable table, String name, int align, Font font, BaseColor color) {
    cell = new PdfPCell(new Phrase(name, font));
    cell.setHorizontalAlignment(align);/*w w  w . ja  va2 s  .com*/
    cell.setBorder(Rectangle.NO_BORDER);
    if (color != null)
        cell.setBackgroundColor(color);
    table.addCell(cell);
}