List of usage examples for com.itextpdf.text.pdf PdfPCell setColspan
public void setColspan(int colspan)
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);//from www . java 2 s .co m cell.setColspan(visibleColumnsSize); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); }
From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java
License:Open Source License
private void addHeading(PdfPTable table) throws DocumentException { Chunk chunk = new Chunk(String.format(messageService.message("label.requisition") + ": %s (%s)", this.requisition.getProgram().getName(), this.requisition.getFacility().getFacilityType().getName()), H1_FONT); PdfPCell cell = new PdfPCell(new Phrase(chunk)); cell.setColspan(5); cell.setPadding(10);// w w w . jav a 2s. c o m cell.setBorder(0); table.addCell(cell); }
From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java
License:Open Source License
private void insertCell(PdfPTable table, String text, int colSpan) { Chunk chunk;/*from w w w . j a v a2 s. co m*/ chunk = new Chunk(text); PdfPCell cell = table.getDefaultCell(); cell.setPhrase(new Phrase(chunk)); cell.setColspan(colSpan); table.addCell(cell); }
From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java
License:Open Source License
public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[] { 30, 20 }); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10);//from ww w .j a v a 2 s .c om summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable .addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost(requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; }
From source file:org.openmrs.module.laboratorymanagement.db.hibernate.LaboratoryDAOimpl.java
License:Open Source License
public void exportToPDF(HttpServletRequest request, HttpServletResponse response, List<Object[]> listOflabtest, String filename, String title, int conceptId) throws DocumentException, IOException { // TODO Auto-generated method stub Concept cpt = Context.getConceptService().getConcept(conceptId); System.out.println(">>>>>>list to export" + listOflabtest); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); response.setContentType("application/pdf"); Document document = new Document(); try {// w ww .j a va 2s .c o m response.setHeader("Content-Disposition", "attachment; filename=\"laboratory.pdf\""); PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); document.open(); writer.setBoxSize("art", PageSize.A4); float[] colsWidth = { 5f, 20f, 17f, 17f, 17f, 16f, 20f }; PdfPTable table = new PdfPTable(colsWidth); // add a title PdfPCell cell = new PdfPCell(new Paragraph("CD4 lab tests")); cell.setColspan(2); document.add(new Paragraph(" Laboratory tests:" + cpt.getName())); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); table.addCell("#"); table.addCell("GIVEN NAME"); table.addCell("FAMILY NAME"); table.addCell("TEST NAME"); table.addCell("TESTED ON"); table.addCell("LOCATION"); table.addCell("TEST RESULT"); for (int i = 0; i < listOflabtest.size(); i++) { Object[] labtest = listOflabtest.get(i); Person p = (Person) labtest[0]; Obs ob = (Obs) labtest[1]; table.addCell(i + 1 + ""); table.addCell(p.getGivenName() + ""); table.addCell(p.getFamilyName() + ""); table.addCell(ob.getConcept().getName() + ""); table.addCell(df.format(ob.getObsDatetime()) + ""); table.addCell(ob.getLocation() + ""); if (cpt.getDatatype().isNumeric()) { table.addCell(ob.getValueNumeric() + ""); } if (cpt.getDatatype().isCoded()) { table.addCell(ob.getValueCoded().getName() + ""); } if (cpt.getDatatype().isText()) { table.addCell(ob.getValueText() + ""); } if (cpt.getDatatype().isDate()) { table.addCell(df.format((ob.getValueDatetime())) + ""); } } document.add(table); document.getJavaScript_onLoad(); document.close(); // document.add(new Paragraph("Hello world")); // document.close(); } catch (DocumentException e) { } }
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 www. j av a 2 s. com*/ 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 ww w . ja v a2 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 a 2 s. 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.oscarehr.fax.util.PdfCoverPageCreator.java
License:Open Source License
public byte[] createCoverPage() { Document document = new Document(); ByteArrayOutputStream os = new ByteArrayOutputStream(); try {// ww w.java 2 s . c o m PdfWriter pdfWriter = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(95); PdfPCell cell = new PdfPCell(table); cell.setBorder(0); cell.setPadding(3); cell.setColspan(1); table.addCell(cell); ClinicDAO clinicDao = SpringUtils.getBean(ClinicDAO.class); Clinic clinic = clinicDao.getClinic(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); Font headerFont = new Font(bf, 28, Font.BOLD); Font infoFont = new Font(bf, 12, Font.NORMAL); if (clinic != null) { cell = new PdfPCell(new Phrase( String.format("%s\n %s, %s, %s %s", clinic.getClinicName(), clinic.getClinicAddress(), clinic.getClinicCity(), clinic.getClinicProvince(), clinic.getClinicPostal()), headerFont)); } else { cell = new PdfPCell(new Phrase("OSCAR", headerFont)); } cell.setPaddingTop(100); cell.setPaddingLeft(25); cell.setPaddingBottom(25); cell.setBorderWidthBottom(1); table.addCell(cell); PdfPTable infoTable = new PdfPTable(1); cell = new PdfPCell(new Phrase(note, infoFont)); cell.setPaddingTop(25); cell.setPaddingLeft(25); infoTable.addCell(cell); table.addCell(infoTable); document.add(table); } catch (DocumentException e) { MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e); return new byte[] {}; } catch (IOException e) { MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e); return new byte[] {}; } finally { document.close(); } return os.toByteArray(); }
From source file:org.sakaiproject.attendance.export.PDFEventExporterImpl.java
License:Educational Community License
private PdfPTable attendanceSheetTable() { List<AttendanceStatus> activeStatuses = attendanceLogic.getActiveStatusesForSite(event.getAttendanceSite()); int colSpan = activeStatuses.size() - 1; if (colSpan <= 0) { colSpan = 1;//from www. j a v a 2 s.co m } PdfPTable table = new PdfPTable(colSpan * 2); table.setWidthPercentage(100); table.setSpacingBefore(12); PdfPCell nameHeader = new PdfPCell(new Paragraph("Student Name", tableHeader)); nameHeader.setPadding(10); nameHeader.setColspan(colSpan); table.addCell(nameHeader); int numStatusHeaders = 0; for (AttendanceStatus status : activeStatuses) { if (status.getStatus() != Status.UNKNOWN) { Paragraph statusHeaderParagraph = new Paragraph(getStatusString(status.getStatus(), colSpan), tableHeader); statusHeaderParagraph.setAlignment(Element.ALIGN_CENTER); PdfPCell statusHeader = new PdfPCell(statusHeaderParagraph); statusHeader.setPadding(10); table.addCell(statusHeader); numStatusHeaders++; } } if (numStatusHeaders == 0) { Paragraph statusHeaderParagraph = new Paragraph("Status", tableHeader); statusHeaderParagraph.setAlignment(Element.ALIGN_CENTER); PdfPCell statusHeader = new PdfPCell(statusHeaderParagraph); statusHeader.setPadding(10); table.addCell(statusHeader); } Collections.sort(users, new SortNameUserComparator()); for (User user : users) { PdfPCell userCell = new PdfPCell( new Paragraph(user.getSortName() + " (" + user.getDisplayId() + ")", body)); userCell.setPadding(10); userCell.setColspan(colSpan); table.addCell(userCell); for (int i = 0; i < colSpan; i++) { // Add blank cell table.addCell(new PdfPCell(new Paragraph())); } } return table; }