List of usage examples for com.lowagie.text.pdf PdfPCell setPadding
public void setPadding(float padding)
From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java
License:Open Source License
private PdfPTable createReplyHeader() { PdfPCell cell; PdfPTable infoTable = new PdfPTable(1); cell = new PdfPCell(new Phrase("", headerFont)); cell.setBorder(0);// ww w.j a v a 2 s .c o m cell.setPaddingLeft(25); infoTable.addCell(cell); cell.setPhrase(new Phrase(getResource("msgConsReq"), bigBoldFont)); cell.setPadding(0); cell.setBorder(0); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.addCell(cell); if (reqFrm.pwb.equals("1")) { cell.setPhrase(new Phrase(getResource("msgPleaseReplyPatient"), boldFont)); } else if (org.oscarehr.common.IsPropertiesOn.isMultisitesEnable()) { cell.setPhrase(new Phrase("", boldFont)); } else { cell.setPhrase(new Phrase(String.format("%s %s %s", getResource("msgPleaseReplyPart1"), clinic.getClinicName(), getResource("msgPleaseReplyPart2")), boldFont)); } infoTable.addCell(cell); // The last cell in the table is extended to the maximum available height; // inserting a blank cell here prevents the last border used to underline text from // being displaced to the bottom of this table. cell.setPhrase(new Phrase(" ", font)); cell.setBorder(0); cell.setColspan(2); infoTable.addCell(cell); return infoTable; }
From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java
License:Open Source License
/** * Creates the table containing additional information * about the reason for the consultation request. * @return the table produced/* w w w . j a v a2 s . c o m*/ */ private PdfPTable createConsultDetailTable() { PdfPTable infoTable; PdfPCell cell; infoTable = new PdfPTable(1); cell = new PdfPCell(); infoTable.addCell(setInfoCell2(cell, getResource("msgReason"))); infoTable.addCell(setDataCell2(cell, reqFrm.reasonForConsultation)); if (getlen(reqFrm.clinicalInformation) > 1) { infoTable.addCell(setInfoCell(cell, getResource("msgClinicalInfom"))); infoTable.addCell(setDataCell(cell, divy(reqFrm.clinicalInformation))); } if (getlen(reqFrm.concurrentProblems) > 1) { if (props.getProperty("significantConcurrentProblemsTitle", "").length() > 1) { infoTable.addCell(setInfoCell(cell, props.getProperty("significantConcurrentProblemsTitle", ""))); } else { infoTable.addCell(setInfoCell(cell, getResource("msgSigProb"))); } infoTable.addCell(setDataCell(cell, divy(reqFrm.concurrentProblems))); } if (getlen(reqFrm.currentMedications) > 1) { if (props.getProperty("currentMedicationsTitle", "").length() > 1) { infoTable.addCell(setInfoCell(cell, props.getProperty("currentMedicationsTitle", ""))); } else { infoTable.addCell(setInfoCell(cell, getResource("msgCurrMed"))); } infoTable.addCell(setDataCell(cell, divy(reqFrm.currentMedications))); } if (getlen(reqFrm.allergies) > 1) { infoTable.addCell(setInfoCell(cell, getResource("msgAllergies"))); infoTable.addCell(setDataCell(cell, divy(reqFrm.allergies))); } if (getlen(reqFrm.ocularExamination) > 1) { infoTable.addCell(setInfoCell(cell, getResource("msgOcularExamination"))); infoTable.addCell(setDataCell(cell, divy(reqFrm.ocularExamination))); } ProviderDao proDAO = (ProviderDao) SpringUtils.getBean("providerDao"); org.oscarehr.common.model.Provider pro = proDAO.getProvider(reqFrm.providerNo); String billingNo = pro.getBillingNo(); DemographicDao demoDAO = (DemographicDao) SpringUtils.getBean("demographicDao"); Demographic demo = demoDAO.getDemographic(reqFrm.demoNo); pro = proDAO.getProvider(demo.getProviderNo()); String famDocBillingNo = pro.getBillingNo(); //infoTable.addCell(setFooterCell(cell, getResource("msgAssociated2"), reqFrm.getProviderName(reqFrm.providerNo) + ((getlen(billingNo) > 0) ? " (" + billingNo + ")" : ""))); //infoTable.addCell(setFooterCell(cell, getResource("msgFamilyDoc2"), reqFrm.getFamilyDoctor() + ((getlen(famDocBillingNo) > 0) ? " (" + famDocBillingNo + ")" : ""))); if (props.getProperty("CONSULTATION_SIGNATURE_LINE1") != null) { cell.setPadding(0); cell.setBorder(0); cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE1"))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); if (props.getProperty("CONSULTATION_SIGNATURE_LINE2") != null) { cell.setPadding(0); cell.setBorder(0); cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE2"))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); } if (props.getProperty("CONSULTATION_SIGNATURE_LINE3") != null) { cell.setPadding(0); cell.setBorder(0); cell.setPhrase(new Phrase(props.getProperty("CONSULTATION_SIGNATURE_LINE3"))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); } } else { infoTable.addCell(setFooterCell(cell, getResource("msgAssociated2"), reqFrm.getFamilyDoctor() + ((getlen(famDocBillingNo) > 0) ? " (" + famDocBillingNo + ")" : ""))); infoTable.addCell( setFooterCell(cell, getResource("msgCreatedBy"), reqFrm.getProviderName(reqFrm.providerNo) + ((getlen(billingNo) > 0) ? " (" + billingNo + ")" : ""))); } if (getlen(reqFrm.signatureImg) > 0) { addSignature(infoTable); } return infoTable; }
From source file:oscar.oscarEncounter.oscarConsultationRequest.pageUtil.ConsultationPDFCreator.java
License:Open Source License
private void addSignature(PdfPTable infoTable) { float[] tableWidths; PdfPCell cell; tableWidths = new float[] { 0.55f, 2.75f }; PdfPTable table = new PdfPTable(tableWidths); cell = new PdfPCell(new Phrase(getResource("msgSignature") + ":", infoFont)); cell.setBorder(0);/*w w w . jav a2 s .c o m*/ cell.setHorizontalAlignment(PdfPCell.ALIGN_BOTTOM); table.addCell(cell); try { DigitalSignatureDao digitalSignatureDao = (DigitalSignatureDao) SpringUtils .getBean("digitalSignatureDao"); DigitalSignature digitalSignature = digitalSignatureDao.find(Integer.parseInt(reqFrm.signatureImg)); if (digitalSignature != null) { Image image = Image.getInstance(digitalSignature.getSignatureImage()); image.scalePercent(80f); image.setBorder(0); cell = new PdfPCell(image); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(table); cell.setBorder(0); cell.setPadding(0); cell.setColspan(1); infoTable.addCell(cell); return; } } catch (Exception e) { logger.error("Unexpected error.", e); } }
From source file:oscar.oscarLab.ca.all.pageUtil.LabPDFCreator.java
License:Open Source License
private void addLabCategory(String header) throws DocumentException { float[] mainTableWidths = { 5f, 3f, 1f, 3f, 2f, 4f, 2f }; PdfPTable table = new PdfPTable(mainTableWidths); table.setHeaderRows(3);/*from w w w. jav a 2s .c o m*/ table.setWidthPercentage(100); PdfPCell cell = new PdfPCell(); // category name cell.setPadding(3); cell.setPhrase(new Phrase(" ")); cell.setBorder(0); cell.setColspan(7); table.addCell(cell); cell.setBorder(15); cell.setPadding(3); cell.setColspan(2); cell.setPhrase(new Phrase(header.replaceAll("<br\\s*/*>", "\n"), new Font(bf, 12, Font.BOLD))); table.addCell(cell); cell.setPhrase(new Phrase(" ")); cell.setBorder(0); cell.setColspan(5); table.addCell(cell); // table headers cell.setColspan(1); cell.setBorder(15); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new Color(210, 212, 255)); cell.setPhrase(new Phrase("Test Name(s)", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Result", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Abn", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Reference Range", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Units", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Date/Time Completed", boldFont)); table.addCell(cell); cell.setPhrase(new Phrase("Status", boldFont)); table.addCell(cell); // add test results int obrCount = handler.getOBRCount(); int linenum = 0; cell.setBorder(12); cell.setBorderColor(Color.BLACK); // cell.setBorderColor(Color.WHITE); cell.setBackgroundColor(new Color(255, 255, 255)); if (handler.getMsgType().equals("MEDVUE")) { //cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPhrase(new Phrase(handler.getRadiologistInfo(), boldFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase(new Phrase(handler.getOBXComment(1, 1, 1).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); } else { for (int j = 0; j < obrCount; j++) { boolean obrFlag = false; int obxCount = handler.getOBXCount(j); for (int k = 0; k < obxCount; k++) { String obxName = handler.getOBXName(j, k); if (!handler.getOBXResultStatus(j, k).equals("TDIS")) { // ensure that the result is a real result if ((!handler.getOBXResultStatus(j, k).equals("DNS") && !obxName.equals("") && handler.getObservationHeader(j, k).equals(header)) || (handler.getMsgType().equals("EPSILON") && handler.getOBXIdentifier(j, k).equals(header) && !obxName.equals("")) || (handler.getMsgType().equals("PFHT") && !obxName.equals("") && handler.getObservationHeader(j, k).equals(header))) { // <<-- DNS only needed for // MDS messages String obrName = handler.getOBRName(j); // add the obrname if necessary if (!obrFlag && !obrName.equals("") && !(obxName.contains(obrName) && obxCount < 2)) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPhrase(new Phrase(obrName, boldFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell.setColspan(1); obrFlag = true; } // add the obx results and info Font lineFont = new Font(bf, 8, Font.NORMAL, getTextColor(handler.getOBXAbnormalFlag(j, k))); // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase(new Phrase((obrFlag ? " " : "") + obxName, lineFont)); table.addCell(cell); cell.setPhrase(new Phrase(handler.getOBXResult(j, k).replaceAll("<br\\s*/*>", "\n"), lineFont)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPhrase(new Phrase( (handler.isOBXAbnormal(j, k) ? handler.getOBXAbnormalFlag(j, k) : "N"), lineFont)); table.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase(new Phrase(handler.getOBXReferenceRange(j, k), lineFont)); table.addCell(cell); cell.setPhrase(new Phrase(handler.getOBXUnits(j, k), lineFont)); table.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPhrase(new Phrase(handler.getTimeStamp(j, k), lineFont)); table.addCell(cell); cell.setPhrase(new Phrase(handler.getOBXResultStatus(j, k), lineFont)); table.addCell(cell); if (!handler.getMsgType().equals("PFHT")) { // add obx comments if (handler.getOBXCommentCount(j, k) > 0) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) { cell.setPhrase(new Phrase( handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); } cell.setPadding(3); cell.setColspan(1); } } // if (DNS) } else if ((handler.getMsgType().equals("EPSILON") && handler.getOBXIdentifier(j, k).equals(header) && obxName.equals("")) || (handler.getMsgType().equals("PFHT") && obxName.equals("") && handler.getObservationHeader(j, k).equals(header))) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase( new Phrase(handler.getOBXResult(j, k).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); cell.setPadding(3); cell.setColspan(1); } if (handler.getMsgType().equals("PFHT") && !handler.getNteForOBX(j, k).equals("") && handler.getNteForOBX(j, k) != null) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPhrase( new Phrase(handler.getNteForOBX(j, k).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); cell.setPadding(3); cell.setColspan(1); if (handler.getOBXCommentCount(j, k) > 0) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) { cell.setPhrase(new Phrase( handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); } cell.setPadding(3); cell.setColspan(1); } } } else { if (handler.getOBXCommentCount(j, k) > 0) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); for (int l = 0; l < handler.getOBXCommentCount(j, k); l++) { cell.setPhrase(new Phrase( handler.getOBXComment(j, k, l).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); } cell.setPadding(3); cell.setColspan(1); } } // if (!handler.getOBXResultStatus(j, k).equals("TDIS")) } if (!handler.getMsgType().equals("PFHT")) { // add obr comments if (handler.getObservationHeader(j, 0).equals(header)) { cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_LEFT); for (int k = 0; k < handler.getOBRCommentCount(j); k++) { // the obrName should only be set if it has not been // set already which will only have occured if the // obx name is "" or if it is the same as the obr name if (!obrFlag && handler.getOBXName(j, 0).equals("")) { // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPhrase(new Phrase(handler.getOBRName(j), boldFont)); table.addCell(cell); obrFlag = true; } // cell.setBackgroundColor(getHighlightColor(linenum)); linenum++; cell.setPaddingLeft(100); cell.setPhrase( new Phrase(handler.getOBRComment(j, k).replaceAll("<br\\s*/*>", "\n"), font)); table.addCell(cell); cell.setPadding(3); } cell.setColspan(1); } } } // for (j) } // if (isMEDVUE) document.add(table); }
From source file:oscar.oscarLab.ca.all.pageUtil.LabPDFCreator.java
License:Open Source License
private void createInfoTable() throws DocumentException { //Create patient info table PdfPCell cell = new PdfPCell(); cell.setBorder(0);// w w w . ja v a2s .co m float[] pInfoWidths = { 2f, 4f, 3f, 2f }; PdfPTable pInfoTable = new PdfPTable(pInfoWidths); cell.setPhrase(new Phrase("Patient Name: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getPatientName(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Home Phone: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getHomePhone(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Date of Birth: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getDOB(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Work Phone: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getWorkPhone(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Age: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getAge(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Sex: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getSex(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Health #: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getHealthNum(), font)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase("Patient Location: ", boldFont)); pInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getPatientLocation(), font)); pInfoTable.addCell(cell); //Create results info table PdfPTable rInfoTable = new PdfPTable(2); cell.setPhrase(new Phrase("Date of Service: ", boldFont)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getServiceDate(), font)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase("Date Received: ", boldFont)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase(dateLabReceived, font)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase("Report Status: ", boldFont)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase((handler.getOrderStatus().equals("F") ? "Final" : (handler.getOrderStatus().equals("C") ? "Corrected" : "Partial")), font)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase("Client Ref. #: ", boldFont)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getClientRef(), font)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase("Accession #: ", boldFont)); rInfoTable.addCell(cell); cell.setPhrase(new Phrase(handler.getAccessionNum(), font)); rInfoTable.addCell(cell); //Create client table float[] clientWidths = { 2f, 3f }; Phrase clientPhrase = new Phrase(); PdfPTable clientTable = new PdfPTable(clientWidths); clientPhrase.add(new Chunk("Requesting Client: ", boldFont)); clientPhrase.add(new Chunk(handler.getDocName(), font)); cell.setPhrase(clientPhrase); clientTable.addCell(cell); clientPhrase = new Phrase(); clientPhrase.add(new Chunk("cc: Client: ", boldFont)); clientPhrase.add(new Chunk(handler.getCCDocs(), font)); cell.setPhrase(clientPhrase); clientTable.addCell(cell); //Create header info table float[] tableWidths = { 2f, 1f }; PdfPTable table = new PdfPTable(tableWidths); if (multiID.length > 1) { cell = new PdfPCell(new Phrase("Version: " + versionNum + " of " + multiID.length, boldFont)); cell.setBackgroundColor(new Color(210, 212, 255)); cell.setPadding(3); cell.setColspan(2); table.addCell(cell); } cell = new PdfPCell(new Phrase("Detail Results: Patient Info", boldFont)); cell.setBackgroundColor(new Color(210, 212, 255)); cell.setPadding(3); table.addCell(cell); cell.setPhrase(new Phrase("Results Info", boldFont)); table.addCell(cell); // add the created tables to the document table = addTableToTable(table, pInfoTable, 1); table = addTableToTable(table, rInfoTable, 1); table = addTableToTable(table, clientTable, 2); table.setWidthPercentage(100); document.add(table); }
From source file:oscar.oscarLab.ca.all.pageUtil.LabPDFCreator.java
License:Open Source License
private PdfPTable addTableToTable(PdfPTable main, PdfPTable add, int colspan) { PdfPCell cell = new PdfPCell(add); cell.setPadding(3); cell.setColspan(colspan);//from w ww .j a v a 2 s. co m main.addCell(cell); return main; }
From source file:questions.tables.RotatedCells.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . j a va 2s . co m*/ PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); float[] widths = { 1, 4 }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(40); PdfPCell cell; cell = new PdfPCell(new Paragraph("test 1")); cell.setPadding(4); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.addCell("Cell without any rotation."); cell = new PdfPCell(new Paragraph("test 2")); cell.setPadding(4); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setRotation(90); table.addCell(cell); table.addCell("Cell rotated 90 degrees."); cell = new PdfPCell(new Paragraph("test 3")); cell.setPadding(4); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setRotation(180); table.addCell(cell); table.addCell("Cell upside down."); cell = new PdfPCell(new Paragraph("test 4")); cell.setPadding(4); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setRotation(270); table.addCell(cell); table.addCell("Cell rotated 270 degrees."); document.add(table); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5: we close the document document.close(); }
From source file:test.itext.html.AimsPdf.java
License:Open Source License
public static void addTitle(Document doc, String text) throws IOException, BadElementException, DocumentException { float[] widths = { 62f, 164f, 62f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100);// w w w. ja v a 2s .c om table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setSpacingAfter(10); Image image = Image.getInstance("app_title.gif"); image.scalePercent(70); PdfPCell cell = new PdfPCell(image); cell.setPadding(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); Paragraph title = new Paragraph(text, FontFactory.getFont("arial", 12, Font.BOLD)); cell = new PdfPCell(title); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); image = Image.getInstance("title_shot.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); doc.add(table); table = new PdfPTable(1); table.setWidthPercentage(100); cell = new PdfPCell(); cell.setBackgroundColor(Color.BLACK); cell.setFixedHeight(1); table.addCell(cell); doc.add(table); }
From source file:test.itext.html.AimsPdf.java
License:Open Source License
public static void addScreenShorts(Document doc, String text) throws BadElementException, IOException, DocumentException { Paragraph heading = new Paragraph("Screenshots", FontFactory.getFont("arial", 10, Font.UNDERLINE | Font.BOLDITALIC)); heading.setSpacingAfter(12f);/*from ww w.j a v a 2 s. c om*/ doc.add(heading); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(80); table.setHorizontalAlignment(Element.ALIGN_CENTER); Image image = Image.getInstance("screen_shoot1.gif"); image.scalePercent(70); PdfPCell cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot2.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot3.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot4.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot5.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); image = Image.getInstance("screen_shoot6.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); // doc.add(new Paragraph("\n")); doc.add(table); }
From source file:tk.diginspect.main.SoOFSignatories.java
private void insertCell(PdfPTable table, String text, int align, int colspan, String color, float BorderWidthTop, float BorderWidthBottom) { PdfPCell cell = new PdfPCell(new Paragraph(Font.TIMES_ROMAN, text)); cell.setHorizontalAlignment(align);//from w w w . j a va 2 s . com cell.setColspan(colspan); cell.setBackgroundColor(WebColors.getRGBColor(color)); cell.setPadding(5); cell.setBorderWidthTop(BorderWidthTop); cell.setBorderWidthBottom(BorderWidthBottom); table.addCell(cell); }