List of usage examples for com.lowagie.text.pdf PdfPCell setPaddingTop
public void setPaddingTop(float paddingTop)
From source file:org.revager.export.ProtocolPDFExporter.java
License:Open Source License
/** * Write the findings to the protocol./* ww w. j a v a 2s .c o m*/ * * @param protocol * the protocol * @param attachExtRefs * true if the external references should be part of the protocol * * @throws ExportException * If an error occurs while writing the findings to the protocol */ protected void writeFindings(Protocol protocol, boolean attachExtRefs) throws ExportException { try { /* * Define fonts */ Font plainFontTitle = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9, Font.NORMAL, Color.WHITE); Font boldFontTitle = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10, Font.NORMAL, Color.WHITE); Font plainFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font boldFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font italicFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 10); Font boldItalicFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLDOBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED), 10); /* * Write findings */ PdfPTable tableBase = new PdfPTable(1); tableBase.setWidthPercentage(100); tableBase.setSplitRows(false); tableBase.getDefaultCell().setBorderWidth(0); tableBase.getDefaultCell().setPadding(0); for (Finding f : protocol.getFindings()) { tableBase.addCell(createVerticalStrut(PDFTools.cmToPt(0.7f), 1)); PdfPCell cellFinding = new PdfPCell(); cellFinding.setBorderColor(Color.GRAY); cellFinding.setBorderWidth(0.5f); PdfPTable tableTitle = new PdfPTable(3); tableTitle.setWidthPercentage(100); /* * Print title of the finding */ Phrase phraseTitle = new Phrase(translate("Finding") + " " + f.getId(), boldFontTitle); PdfPCell cellTitle = new PdfPCell(phraseTitle); cellTitle.setBackgroundColor(bgColorTitle); cellTitle.setBorderWidth(0); cellTitle.setPadding(padding); cellTitle.setPaddingBottom(padding * 1.5f); cellTitle.setHorizontalAlignment(Element.ALIGN_LEFT); tableTitle.addCell(cellTitle); /* * Print severity of the finding */ Phrase phraseSeverity = new Phrase(findMgmt.getLocalizedSeverity(f), plainFontTitle); PdfPCell cellSeverity = new PdfPCell(phraseSeverity); cellSeverity.setBackgroundColor(bgColorTitle); cellSeverity.setBorderWidth(0); cellSeverity.setPadding(padding); cellSeverity.setPaddingTop(padding * 1.1f); cellSeverity.setHorizontalAlignment(Element.ALIGN_CENTER); tableTitle.addCell(cellSeverity); /* * Print the meeting date and time of the finding */ String meetingDate = sdfDate.format(protocol.getDate().getTime()); PdfPCell cellMeeting = new PdfPCell(new Phrase(meetingDate, plainFontTitle)); cellMeeting.setBackgroundColor(bgColorTitle); cellMeeting.setBorderWidth(0); cellMeeting.setPadding(padding); cellMeeting.setPaddingTop(padding * 1.1f); cellMeeting.setHorizontalAlignment(Element.ALIGN_RIGHT); tableTitle.addCell(cellMeeting); /* * Description */ Phrase phraseDesc = new Phrase(f.getDescription(), plainFont); phraseDesc.setLeading(leading); PdfPCell cellDesc = new PdfPCell(); cellDesc.addElement(phraseDesc); cellDesc.setBorderWidth(0); cellDesc.setPadding(padding); cellDesc.setColspan(3); tableTitle.addCell(cellDesc); cellFinding.addElement(tableTitle); /* * List point used for lists */ Phrase phraseListPoint = new Phrase("", boldFont); phraseListPoint.setLeading(leading * 0.93f); PdfPCell cellListPoint = new PdfPCell(); cellListPoint.addElement(phraseListPoint); cellListPoint.setBorderWidth(0); cellListPoint.setPadding(padding); cellListPoint.setPaddingLeft(padding * 2); /* * Table of references */ if (f.getReferences().size() > 0 || (f.getExternalReferences().size() > 0 && attachExtRefs == true)) { PdfPTable tableRefs = new PdfPTable(new float[] { 0.04f, 0.96f }); tableRefs.setWidthPercentage(100); PdfPCell cellRefTitle = new PdfPCell(new Phrase(translate("References:"), boldItalicFont)); cellRefTitle.setBorderWidth(0); cellRefTitle.setPadding(padding); cellRefTitle.setPaddingTop(padding * 3); cellRefTitle.setPaddingBottom(0); cellRefTitle.setColspan(2); tableRefs.addCell(cellRefTitle); /* * Textual references */ for (String ref : f.getReferences()) { Phrase phraseRef = new Phrase(ref, plainFont); phraseRef.setLeading(leading); PdfPCell cellRef = new PdfPCell(); cellRef.addElement(phraseRef); cellRef.setBorderWidth(0); cellRef.setPadding(padding); tableRefs.addCell(cellListPoint); tableRefs.addCell(cellRef); } /* * External file references */ if (attachExtRefs == true) { for (File ref : findMgmt.getExtReferences(f)) { Phrase phraseRef = new Phrase(); phraseRef.add(new Chunk(ref.getName(), plainFont)); phraseRef.add(new Chunk(" (" + translate("File Attachment") + ")", italicFont)); phraseRef.setFont(plainFont); phraseRef.setLeading(leading); PdfPCell cellRef = new PdfPCell(); cellRef.addElement(phraseRef); cellRef.setBorderWidth(0); cellRef.setPadding(padding); tableRefs.addCell(cellListPoint); cellRef.setCellEvent(new PDFCellEventExtRef(pdfWriter, ref)); tableRefs.addCell(cellRef); } } cellFinding.addElement(tableRefs); } /* * Table of aspects */ if (f.getAspects().size() > 0) { PdfPTable tableAspects = new PdfPTable(new float[] { 0.04f, 0.96f }); tableAspects.setWidthPercentage(100); PdfPCell cellAspTitle = new PdfPCell(new Phrase(translate("Aspects:"), boldItalicFont)); cellAspTitle.setBorderWidth(0); cellAspTitle.setPadding(padding); cellAspTitle.setPaddingTop(padding * 3); cellAspTitle.setPaddingBottom(0); cellAspTitle.setColspan(2); tableAspects.addCell(cellAspTitle); for (String asp : f.getAspects()) { Phrase phraseAsp = new Phrase(asp, plainFont); phraseAsp.setLeading(leading); PdfPCell cellAsp = new PdfPCell(); cellAsp.addElement(phraseAsp); cellAsp.setBorderWidth(0); cellAsp.setPadding(padding); tableAspects.addCell(cellListPoint); tableAspects.addCell(cellAsp); } cellFinding.addElement(tableAspects); } /* * Vertical strut at the end of the table */ PdfPTable tableStrut = new PdfPTable(1); tableStrut.setWidthPercentage(100); tableStrut.addCell(createVerticalStrut(padding, 1)); cellFinding.addElement(tableStrut); tableBase.addCell(cellFinding); } pdfDoc.add(tableBase); } catch (Exception e) { /* * Not part of unit testing because this exception is only thrown if * an internal error occurs. */ throw new ExportException(translate("Cannot put findings into the PDF document.")); } }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
/** * Get PdfPTable containing the ring width data for this series * //from w w w .ja v a 2 s. com * @return PdfPTable * @throws DocumentException */ private void getElementTable() throws DocumentException { PdfPTable tbl = new PdfPTable(5); PdfPCell headerCell = new PdfPCell(); tbl.setWidthPercentage(100f); float[] widths = { 0.1f, 0.4f, 0.2f, 0.1f, 0.2f }; tbl.setWidths(widths); // Set up header headerCell.setPhrase(new Phrase("Element", tableHeaderFont)); headerCell.setBorderWidthBottom(headerLineWidth); headerCell.setBorderWidthTop(headerLineWidth); headerCell.setBorderWidthLeft(0); headerCell.setBorderWidthRight(0); headerCell.setPaddingTop(5); headerCell.setPaddingBottom(5); tbl.addCell(headerCell); headerCell.setPhrase(new Phrase("Comments", tableHeaderFont)); tbl.addCell(headerCell); headerCell.setPhrase(new Phrase("Taxon", tableHeaderFont)); tbl.addCell(headerCell); headerCell.setPhrase(new Phrase("# Rings", tableHeaderFont)); tbl.addCell(headerCell); headerCell.setPhrase(new Phrase("Dates", tableHeaderFont)); tbl.addCell(headerCell); // Loop through rows for (org.tellervo.desktop.sample.Element e : this.elements) { Sample s = null; try { s = e.load(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); continue; } // Find element details for this series SearchParameters param = new SearchParameters(SearchReturnObject.DERIVED_SERIES); param.addSearchConstraint(SearchParameterName.SERIESDBID, SearchOperator.EQUALS, s.getIdentifier().getValue().toString()); EntitySearchResource<TridasObject> searchResource = new EntitySearchResource<TridasObject>(param, TridasObject.class); searchResource.setProperty(TellervoResourceProperties.ENTITY_REQUEST_FORMAT, TellervoRequestFormat.COMPREHENSIVE); TellervoResourceAccessDialog dialog = new TellervoResourceAccessDialog(searchResource); searchResource.query(); dialog.setVisible(true); List<TridasObject> oblist = searchResource.getAssociatedResult(); if (oblist.size() != 1) { System.out.println(e.getName() + " has more than one (or no) associated objects so skipping"); continue; } TridasObject obj = oblist.get(0); List<TridasElement> ellist = obj.getElements(); if (ellist.size() != 1) { System.out.println(e.getName() + " has more than one (or no) associated element so skipping"); continue; } TridasElement el = ellist.get(0); // make lab code LabCode labcode = new LabCode(); labcode.appendSiteCode(((TridasObjectEx) obj).getLabCode()); labcode.setElementCode(el.getTitle()); PdfPCell dataCell = new PdfPCell(); dataCell.setBorderWidthBottom(0); dataCell.setBorderWidthTop(0); dataCell.setBorderWidthLeft(0); dataCell.setBorderWidthRight(0); dataCell.setPaddingTop(5); dataCell.setPaddingBottom(5); dataCell.setHorizontalAlignment(Element.ALIGN_LEFT); // Title Column dataCell.setPhrase(new Phrase(LabCodeFormatter.getSamplePrefixFormatter().format(labcode).toString(), tableBodyFont)); tbl.addCell(dataCell); // Comments Column if (el.getComments() != null) dataCell.setPhrase(new Phrase(el.getComments(), tableBodyFont)); else dataCell.setPhrase(new Phrase(" ", tableBodyFont)); tbl.addCell(dataCell); // Taxon Column dataCell.setHorizontalAlignment(Element.ALIGN_LEFT); dataCell.setPhrase(new Phrase(el.getTaxon().getNormal().toString(), tableBodyFont)); tbl.addCell(dataCell); // Rings Column dataCell.setHorizontalAlignment(Element.ALIGN_CENTER); dataCell.setPhrase(new Phrase(String.valueOf(s.countRings()), tableBodyFont)); tbl.addCell(dataCell); // Dates column String datingLabel; String datingType = s.getSeries().getInterpretation().getDating().getType().value().toString(); datingLabel = s.getSeries().getInterpretation().getFirstYear().getValue().toString(); if (datingType == "Absolute") { datingLabel += s.getSeries().getInterpretation().getFirstYear().getSuffix().toString(); } datingLabel += " - " + String.valueOf( s.getSeries().getInterpretation().getFirstYear().getValue().intValue() + s.countRings() - 1); if (datingType == "Relative") { datingLabel += " (Rel. Date)"; } dataCell.setHorizontalAlignment(Element.ALIGN_LEFT); dataCell.setPhrase(new Phrase(datingLabel, tableBodyFont)); tbl.addCell(dataCell); } // Add table to document document.add(tbl); }
From source file:storemanagment.Printing.java
public PdfPCell createImageCell(String path) throws IOException { PdfPCell cell = null; try {// w ww. j av a 2 s . co m Image img = Image.getInstance(path); cell = new PdfPCell(img, true); cell.setFixedHeight(30); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(10); } catch (BadElementException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } return cell; }
From source file:storemanagment.Printing.java
public PdfPCell createImageCellCrip(String path, PdfWriter writer) throws IOException, DocumentException { PdfPCell cell = null; try {/*from w w w . j a va2 s . co m*/ Image img = Image.getInstance(path); float w = img.getScaledWidth(); float h = img.getScaledHeight(); PdfTemplate t = writer.getDirectContent().createTemplate(w, h); t.ellipse(0, 0, w, h); t.newPath(); t.addImage(img, w, 0, 0, h, 0, -600); Image clipped = Image.getInstance(t); cell = new PdfPCell(clipped, true); // cell.setFixedHeight(30); // cell.setBorder(Rectangle.NO_BORDER); //cell.setBorder(R); cell.setPaddingTop(10); } catch (BadElementException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } return cell; }
From source file:tk.diginspect.main.SoOFSignatories.java
public void createPDF() { doc = new Document(PageSize.A4); try {/*from w ww . j a va 2s .co m*/ String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/RFO"; File dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } String strFinalname, strFilename2, strFilenames; String filename = sp.getString("EstablishmentName", null); String strfilename = filename.replaceAll("\\W+", "-"); String inspector = sp.getString("FDRO1", null); String inspby = inspector.replaceAll("\\W+", "-"); File file = new File(dir, strfilename + "-" + strFile + "-" + inspby + ".pdf"); strFilename2 = strfilename + "-" + strFile + "-" + inspby; strFilenames = strFilename2 + ".pdf"; strFinalname = path + "/" + strFilenames; savePreferences("fileName", strFinalname); FileOutputStream fOut = new FileOutputStream(file); PdfWriter.getInstance(doc, fOut); doc.open(); FDALetterhead(); // General Info Table float[] table1columnWidths = { 1f, 1f, 1f, 1f }; PdfPTable table1 = new PdfPTable(table1columnWidths); table1.setWidthPercentage(110f); table1.setSpacingAfter(20f); insertCell(table1, "INSPECTION REPORT", Element.ALIGN_CENTER, 4, "#8EBAFF", 1, 0); insertCell(table1, "Name of Establishment", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("EstablishmentName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Plant/Office Address", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PlantOfficeAddress", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Warehouse Address", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("WarehouseAddress", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Owner", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Owner", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Telephone Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("TelNumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Fax No", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("FaxNumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Classification", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); String Classification = sp.getString("MainClass", null) + ", " + sp.getString("SecClass", null) + ", " + sp.getString("ThirdClass", null) + ", " + sp.getString("FourthClass", ""); insertCell(table1, Classification, Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Product/s:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Products", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Manner of Notification", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Notification", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Purpose of Inspection", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Inspection", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Registered Pharmacist / Authorized Representative / Person", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "Name", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PharmacistName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Reg. No. (PRC-ID)", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcID", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Date Issued", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcDateIssued", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Validity", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcValidity", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Position", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PharmacistPosition", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Person/s Interviewed", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("InterviewedName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Position", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("InterviewedPosition", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "License to Operate", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTONumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Renewal", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTORenewalDate", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Validity", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTOValidity", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Payment of Appropriate Fee", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "OR Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("ORNum", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Amount", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, "Php " + sp.getString("ORAmount", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Date of Payment", Element.ALIGN_LEFT, 0, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("ORDate", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "RSN", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 1); insertCell(table1, sp.getString("RSN", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 1); doc.add(table1); footer(); // 2nd Page doc.newPage(); FDALetterhead(); PdfPTable table2 = new PdfPTable(1); table2.setWidthPercentage(110f); table2.setSpacingAfter(20f); insertCell(table2, "Observation Findings:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell1(table2, sp.getString("ObservationFindings", ""), 1, 1, 600f); doc.add(table2); footer(); // 3rd Page doc.newPage(); FDALetterhead(); PdfPTable table3 = new PdfPTable(1); table3.setWidthPercentage(110f); table3.setSpacingAfter(20f); insertCell(table3, "Directives:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 1); nested(table3, 0.1f, 2f, R.string.directives1, sp.getBoolean("Directives1", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives2, sp.getBoolean("Directives2", false), Element.ALIGN_LEFT); nested(table3, 0.2f, 2f, R.string.directives3, sp.getBoolean("Directives3", false), Element.ALIGN_RIGHT); nested(table3, 0.2f, 2f, R.string.directives4, sp.getBoolean("Directives4", false), Element.ALIGN_RIGHT); nested(table3, 0.1f, 2f, R.string.directives5, sp.getBoolean("Directives5", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives6, sp.getBoolean("Directives6", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives7, sp.getBoolean("Directives7", false), Element.ALIGN_LEFT); String Directives8 = getResources().getString(R.string.directives8); PdfPCell cellDirectives8 = new PdfPCell(new Paragraph(Font.TIMES_ROMAN, Directives8)); cellDirectives8.setPaddingLeft(50); cellDirectives8.setPaddingTop(5); cellDirectives8.setPaddingBottom(5); cellDirectives8.setPaddingRight(5); cellDirectives8.setBorderWidthTop(0); cellDirectives8.setBorderWidthBottom(0); table3.addCell(cellDirectives8); String Directives = sp.getString("Directives8", null); boolean Directives9 = false, Directives10 = false; if (Directives.equals(R.string.directives9)) { Directives9 = true; Directives10 = false; } else if (Directives.equals(R.string.directives10)) { Directives9 = false; Directives10 = true; } else { Directives9 = false; Directives10 = false; } nested(table3, 0.3f, 2f, R.string.directives9, Directives9, Element.ALIGN_RIGHT); nested(table3, 0.3f, 2f, R.string.directives10, Directives10, Element.ALIGN_RIGHT); insertCell(table3, "Inspected By:", Element.ALIGN_CENTER, 1, "#8EBAFF", 1, 0); PdfPTable signature1 = new PdfPTable(2); sig(signature1, "FDRO1"); sig(signature1, "FDRO2"); insertCell(signature1, sp.getString("FDRO1", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, sp.getString("FDRO2", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, "Food-Drug Regulation Officer", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Food-Drug Regulation Officer", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Date: " + dateStarted, Element.ALIGN_LEFT, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Time: " + timeS, Element.ALIGN_LEFT, 1, "#FFFFFF", 1, 0); sig(signature1, "EstRep1"); sig(signature1, "EstRep2"); insertCell(signature1, sp.getString("EstRep1", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, sp.getString("EstRep2", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, "Establishments Representative", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); insertCell(signature1, "Establishments Representative", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); PdfPCell nesthousing1 = new PdfPCell(signature1); table3.addCell(nesthousing1); doc.add(table3); footer(); // 4th Page doc.newPage(); FDALetterhead(); PdfPTable table4 = new PdfPTable(1); table4.setWidthPercentage(110f); table4.setSpacingAfter(20f); insertCell(table4, "(FDA USE ONLY)", Element.ALIGN_CENTER, 1, "#8EBAFF", 1, 1); insertCell(table4, "Compliance Made by the Company", Element.ALIGN_LEFT, 1, "#FFFFFF", 0, 0); nested(table4, 0.1f, 2f, R.string.CAPA, false, Element.ALIGN_LEFT); nested(table4, 0.2f, 2f, R.string.Accepted, false, Element.ALIGN_RIGHT); nested(table4, 0.2f, 2f, R.string.NotAccepted, false, Element.ALIGN_RIGHT); insertCell(table4, "Recommendation (to Licensing) :", Element.ALIGN_LEFT, 1, "#FFFFFF", 0, 0); insertCell1(table4, "", 0, 0, 100f); PdfPTable signature2 = new PdfPTable(2); insertCell1(signature2, "", 0, 0, 50f); insertCell1(signature2, "", 0, 0, 50f); insertCell(signature2, "Print Name & Signature of FDRO/s", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature2, "Date", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature2, "Reviewed by:", Element.ALIGN_LEFT, 2, "#8EBAFF", 1, 1); insertCell1(signature2, "", 0, 0, 50f); insertCell1(signature2, "", 0, 0, 50f); insertCell(signature2, "Print Name & Signature of Team Leader/Supervisor", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); insertCell(signature2, "Date", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); PdfPCell nesthousing2 = new PdfPCell(signature2); table4.addCell(nesthousing2); doc.add(table4); footer(); } catch (DocumentException de) { Log.e("PDFCreator", "DocumentException:" + de); } catch (FileNotFoundException e) { Log.e("PDFCreator", "ioException:" + e); } finally { doc.close(); } }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
private PdfPCell headCell(String name, Font font) { PdfPCell pdfCell = new PdfPCell(new Phrase(name, font)); pdfCell.setMinimumHeight(font.getSize() * 2f); pdfCell.setHorizontalAlignment(Element.ALIGN_LEFT); pdfCell.setVerticalAlignment(Element.ALIGN_CENTER); pdfCell.setPaddingBottom(font.getSize() * 0.5f); pdfCell.setPaddingTop(font.getSize() * 0.5f); pdfCell.setPaddingLeft(font.getSize()); pdfCell.setPaddingRight(font.getSize()); return pdfCell; }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
private PdfPCell nameCell(String name, String webauthId, String department) { Phrase phrase = new Phrase(); phrase.add(new Chunk(name, tableNameFont)); phrase.add(Chunk.NEWLINE);/* ww w .ja va 2s . c om*/ StringBuilder otherDetails = new StringBuilder(); if (webauthId != null && webauthId.trim().length() > 0) { otherDetails.append(webauthId); } if (department != null && department.trim().length() > 0) { if (otherDetails.length() > 0) { otherDetails.append(" "); } otherDetails.append(department); } phrase.add(new Chunk(otherDetails.toString(), tableOtherFont)); PdfPCell pdfCell = new PdfPCell(phrase); pdfCell.setMinimumHeight(tableNameFont.getSize() * 2f); pdfCell.setHorizontalAlignment(Element.ALIGN_LEFT); pdfCell.setVerticalAlignment(Element.ALIGN_CENTER); pdfCell.setPaddingBottom(tableNameFont.getSize() * 0.5f); pdfCell.setPaddingTop(tableNameFont.getSize() * 0.5f); pdfCell.setPaddingLeft(tableNameFont.getSize()); pdfCell.setPaddingRight(tableNameFont.getSize()); return pdfCell; }