List of usage examples for com.itextpdf.text.pdf PdfPCell setBackgroundColor
public void setBackgroundColor(final BaseColor backgroundColor)
From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java
License:Open Source License
private void setBlankFooter(PdfPTable table, Integer visibleColumnsSize) { PdfPCell cell = new PdfPCell(new Phrase(" ")); cell.setBorder(0);/*w w w . j a v a2s . com*/ cell.setColspan(visibleColumnsSize); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); }
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"); /*/*ww w. ja va 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 .j a va 2 s .co 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.opentox.ontology.components.Algorithm.java
License:Open Source License
@Override public PDFObject getPDF() { PDFObject pdf = new PDFObject(); pdf.setPdfTitle(getMeta().identifier); pdf.setPdfKeywords(getMeta().subject); Paragraph p1 = new Paragraph( new Chunk("OpenTox - Algorithm Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14))); pdf.addElement(p1);//from w w w .j av a 2s . co m try { PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 10, 50 }); PdfPCell cell = new PdfPCell(new Paragraph("Algorithm Presentation - General")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("Name"); table.addCell(getMeta().getName()); table.addCell("Title"); table.addCell(getMeta().title); table.addCell("Subject"); table.addCell(getMeta().subject); table.addCell("Description"); table.addCell(getMeta().description); table.addCell("Identifier"); table.addCell(getMeta().identifier); pdf.addElement(table); pdf.addElement(new Paragraph("\n\n\n")); table = new PdfPTable(2); table.setWidths(new int[] { 10, 50 }); cell = new PdfPCell(new Paragraph("General Meta Information")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("Type"); table.addCell(getMeta().type); table.addCell("Creator"); table.addCell(getMeta().creator); table.addCell("Publisher"); table.addCell(getMeta().publisher); table.addCell("Relation"); table.addCell(getMeta().relation); table.addCell("Rights"); table.addCell(getMeta().rights); table.addCell("Source"); table.addCell(getMeta().source); table.addCell("Provenance"); table.addCell(getMeta().provenance); table.addCell("Contributor"); table.addCell(getMeta().contributor); table.addCell("Language"); table.addCell(getMeta().language.getDisplayLanguage()); table.addCell("Created on"); table.addCell(getMeta().date.toString()); table.addCell("Formats"); ArrayList<MediaType> listMedia = getMeta().format; String formatTableEntry = ""; for (int i = 0; i < listMedia.size(); i++) { formatTableEntry += listMedia.get(i).toString(); if (i < listMedia.size() - 1) { formatTableEntry += "\n"; } } table.addCell(formatTableEntry); table.addCell("Audience"); ArrayList<Audience> audiences = getMeta().audience; String auds = ""; for (int i = 0; i < audiences.size(); i++) { auds += audiences.get(i).getName(); if (i < audiences.size() - 1) { auds += "\n"; } } table.addCell(auds); pdf.addElement(table); pdf.addElement(new Paragraph("\n\n\n")); table = new PdfPTable(4); table.setWidths(new int[] { 30, 30, 30, 30 }); cell = new PdfPCell(new Paragraph("Algorithm Parameters")); cell.setColspan(4); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("Parameter Name"); table.addCell("XSD DataType"); table.addCell("Default Value"); table.addCell("Scope"); Map<String, AlgorithmParameter> algParameters = getMeta().getParameters(); Set<Entry<String, AlgorithmParameter>> entrySet = algParameters.entrySet(); for (Entry e : entrySet) { String pName = (String) e.getKey(); AlgorithmParameter ap = (AlgorithmParameter) e.getValue(); table.addCell(pName); table.addCell(ap.dataType.getURI()); table.addCell(ap.paramValue.toString()); table.addCell(ap.paramScope.toString()); } pdf.addElement(table); pdf.addElement(new Paragraph("\n\n\n")); table = new PdfPTable(1); cell = new PdfPCell(new Paragraph("Ontologies")); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); OTAlgorithmTypes type = getMeta().getAlgorithmType(); table.addCell(type.getURI()); Set<Resource> superOntologies = type.getSuperEntities(); Iterator<Resource> it = superOntologies.iterator(); while (it.hasNext()) { table.addCell(it.next().getURI()); } pdf.addElement(table); } catch (final DocumentException ex) { YaqpLogger.LOG.log(new Warning(getClass(), "XCF316 - Pdf Exception :" + ex.toString())); } return pdf; }
From source file:org.opentox.ontology.components.User.java
License:Open Source License
@Override public PDFObject getPDF() { PDFObject pdf = new PDFObject(); pdf.setPdfTitle(getUserName());/*from www . j a v a 2 s . com*/ pdf.setPdfKeywords("User, " + getUserName() + ", Account"); pdf.setSubject("User Account Information for user " + getUserName()); Paragraph p1 = new Paragraph( new Chunk("OpenTox - User Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14))); pdf.addElement(p1); try { PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 30, 50 }); PdfPCell cell = new PdfPCell(new Paragraph("User Account Information")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("UserName"); table.addCell(getUserName()); table.addCell("First Name"); table.addCell(getFirstName()); table.addCell("Last Name"); table.addCell(getLastName()); table.addCell("e-mail"); table.addCell(getEmail()); table.addCell("UserGroup"); table.addCell(getUserGroup().getName()); table.addCell("Authorization Level"); table.addCell(Integer.toString(getUserGroup().getLevel())); table.addCell("Organization"); table.addCell(getOrganization()); table.addCell("Country"); table.addCell(getCountry()); table.addCell("City"); table.addCell(getCity()); table.addCell("Address"); table.addCell(getAddress()); table.addCell("Web Page"); table.addCell(getWebpage()); table.addCell("Created on"); table.addCell(getTimeStamp()); pdf.addElement(table); } catch (DocumentException ex) { YaqpLogger.LOG.log( new Warning(getClass(), "XEI909 - Error while generating " + "PDF representation for User")); } return pdf; }
From source file:org.opentox.ontology.components.UserGroup.java
License:Open Source License
@Override public PDFObject getPDF() { PDFObject pdf = new PDFObject(); Paragraph p1 = new Paragraph( new Chunk("OpenTox - UserGroup Report\n\n", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14))); pdf.addElement(p1);//from w w w. ja v a2s . c o m try { PdfPTable table = new PdfPTable(2); table.setWidths(new int[] { 30, 50 }); PdfPCell cell = new PdfPCell(new Paragraph("UserGroup General Information")); cell.setColspan(2); cell.setBackgroundColor(new BaseColor(0xC0, 0xC0, 0xC0)); table.addCell(cell); table.addCell("Name"); table.addCell(getName()); table.addCell("Authorization Level"); table.addCell(Integer.toString(getLevel())); pdf.addElement(table); } catch (DocumentException ex) { YaqpLogger.LOG.log(new Warning(getClass(), "XPI908 - Error while generating " + "PDF representation for User Group ")); } return pdf; }
From source file:org.patientview.radar.service.impl.PdfDocumentDataBuilder.java
License:Open Source License
private PdfPCell createHeadingCell(String text) { PdfPCell cell = createBaseCell(text, new Font(BASE_FONT, BASE_FONT_SIZE, Font.BOLD)); cell.setBackgroundColor(new BaseColor(0xDE, 0xDE, 0xDE)); return cell;//from ww w. ja v a 2 s .c o m }
From source file:org.sharegov.cirm.utils.PDFExportUtil.java
License:Apache License
private static void createTable(Section subCatPart, Json allData) throws DocumentException { Json metaData = allData.at("metaData"); PdfPTable table = null;/*from w ww.ja v a 2 s . co m*/ PdfPCell c1 = null; int columns = metaData.at("columns").asInteger(); table = new PdfPTable(columns); table.setWidthPercentage(100); if (columns == 9) { int[] widths = { 10, 20, 12, 12, 4, 6, 6, 8, 8 }; table.setWidths(widths); } else { int[] widths = { 10, 25, 12, 12, 4, 6, 6, 8 }; table.setWidths(widths); } // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); c1 = new PdfPCell(new Phrase(metaData.at("boid").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("type").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("fullAddress").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("city").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("zip").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("hasStatus").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("createdDate").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); c1 = new PdfPCell(new Phrase(metaData.at("lastActivityUpdatedDate").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); if (columns == 9) { c1 = new PdfPCell(new Phrase(metaData.at("gisColumn").asString(), smallBold)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(c1); } table.setHeaderRows(1); List<Json> data = allData.at("data").asJsonList(); for (Json dataValue : data) { if (!dataValue.at("hasCaseNumber").asString().isEmpty()) c1 = new PdfPCell(new Phrase(dataValue.at("hasCaseNumber").asString(), smallFont)); else c1 = new PdfPCell(new Phrase(GenUtils.makeCaseNumber(dataValue.at("boid").asLong()), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("label").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("fullAddress").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("Street_Address_City").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("Zip_Code").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("hasStatus").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("hasDateCreated").asString(), smallFont)); table.addCell(c1); c1 = new PdfPCell(new Phrase(dataValue.at("lastActivityUpdatedDate").asString(), smallFont)); table.addCell(c1); if (columns == 9) { c1 = new PdfPCell(new Phrase(dataValue.at("gisColumn").asString(), smallFont)); table.addCell(c1); } } subCatPart.add(table); }
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);/*from ww w . j a va 2 s .com*/ 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);//from w w w . j a va2 s .com cell.setBorder(Rectangle.NO_BORDER); if (color != null) cell.setBackgroundColor(color); table.addCell(cell); }