List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingRight
public void setPaddingRight(float paddingRight)
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds the Assessments Table - The assessment fields for the encounter * * @param tabFieldMultiMap multimap of the encounter's tab fields * @param prescriptionItems a list of the encounter's prescriptions * @param problemItems a list of the encounter's problems * @return PdfPTable the itext table to add to the document */// w ww. ja va 2s . c o m private PdfPTable getAssessments(TabFieldMultiMap tabFieldMultiMap, List<PrescriptionItem> prescriptionItems, List<ProblemItem> problemItems) { PdfPTable table = getDefaultTable(3); //Set table to span 3 columns to counteract tablesize for dispensed prescriptions table.addCell(getDefaultHeaderCell("Assessments", 3)); // Row 1 PdfPCell cellMSH = new PdfPCell(table.getDefaultCell()); TabFieldItem msh = tabFieldMultiMap.getMostRecentOrEmpty("medicalSurgicalHistory", null); cellMSH.addElement(getStyledPhrase("Medical Surgical History: ", outputStringOrNA(msh.getValue()))); cellMSH.setColspan(3); table.addCell(cellMSH); // Row 2 PdfPCell cellCM = new PdfPCell(table.getDefaultCell()); TabFieldItem cm = tabFieldMultiMap.getMostRecentOrEmpty("currentMedication", null); cellCM.addElement(getStyledPhrase("Medication: ", outputStringOrNA(cm.getValue()))); cellCM.setColspan(3); table.addCell(cellCM); // Row 3 PdfPCell cellSH = new PdfPCell(table.getDefaultCell()); TabFieldItem sh = tabFieldMultiMap.getMostRecentOrEmpty("socialHistory", null); cellSH.addElement(getStyledPhrase("Social History: ", outputStringOrNA(sh.getValue()))); cellSH.setColspan(3); table.addCell(cellSH); // Row 4 PdfPCell cellAssesment = new PdfPCell(table.getDefaultCell()); TabFieldItem assessment = tabFieldMultiMap.getMostRecentOrEmpty("assessment", null); cellAssesment.addElement(getStyledPhrase("Assessment: ", outputStringOrNA(assessment.getValue()))); cellAssesment.setColspan(3); table.addCell(cellAssesment); // Row 5 PdfPCell cellFH = new PdfPCell(table.getDefaultCell()); TabFieldItem fh = tabFieldMultiMap.getMostRecentOrEmpty("familyHistory", null); cellFH.addElement(getStyledPhrase("Family History: ", outputStringOrNA(fh.getValue()))); cellFH.setColspan(3); table.addCell(cellFH); // Row 6 PdfPCell cellTreatment = new PdfPCell(table.getDefaultCell()); TabFieldItem treatment = tabFieldMultiMap.getMostRecentOrEmpty("procedure_counseling", null); cellTreatment.addElement(getStyledPhrase("Procedure/Counseling: ", outputStringOrNA(treatment.getValue()))); cellTreatment.setColspan(3); table.addCell(cellTreatment); // Loop through and add any potential Custom Field Names // Row 7+ , set cells to colspan of 2 so they fill the whole page for (String customField : tabFieldMultiMap.getCustomFieldNameList()) { String value = tabFieldMultiMap.getMostRecentOrEmpty(customField, null).getValue(); PdfPCell customCell = new PdfPCell(table.getDefaultCell()); customCell.setColspan(3); customCell.addElement(getStyledPhrase(customField + " :", outputStringOrNA(value))); table.addCell(customCell); } // AJ Saclayan Dispensed Table Paragraph prescriptionsTitle = new Paragraph("Dispensed Prescription(s):", getTitleFont()); PdfPCell prescriptionCell = new PdfPCell(table.getDefaultCell()); prescriptionCell.setPaddingRight(10); prescriptionCell.addElement(prescriptionsTitle); prescriptionCell.setColspan(3); table.addCell(prescriptionCell); table.completeRow(); if (!prescriptionItems.isEmpty()) { //Create Dispensed Table. Paragraph originalMedsTitle = new Paragraph("Original", getTitleFont()); PdfPCell cell = new PdfPCell(originalMedsTitle); table.addCell(cell); Paragraph replacedMedsTitle = new Paragraph("Replacement", getTitleFont()); cell = new PdfPCell(replacedMedsTitle); table.addCell(cell); table.completeRow(); for (PrescriptionItem prescription : prescriptionItems) { String medicationForm = prescription.getMedicationForm(); if (medicationForm == null || medicationForm.equals("")) { medicationForm = "N/A"; } else { medicationForm = medicationForm.trim(); } if (prescription.getReplacementMedicationName() != null) { Paragraph originalMedName = new Paragraph( "Prescription #" + prescription.getId() + " - Replaced \n" + prescription.getAmount() + " " + prescription.getName() + " (" + medicationForm + ")", getValueFont()); cell = new PdfPCell(originalMedName); table.addCell(cell); Paragraph replacedMedName = new Paragraph("Prescription #" + prescription.getReplacementId() + " \n" + prescription.getReplacementAmount() + " " + prescription.getReplacementMedicationName(), getValueFont()); cell = new PdfPCell(replacedMedName); table.addCell(cell); } else { Paragraph medName = new Paragraph("Prescription #" + prescription.getId() + "\n" + prescription.getAmount() + " " + prescription.getName() + " (" + medicationForm + ")", getValueFont()); cell = new PdfPCell(medName); table.addCell(cell); Paragraph blankCell = new Paragraph(" ", getValueFont()); cell = new PdfPCell(blankCell); table.addCell(cell); } table.completeRow(); } } // Get Problems Paragraph problemsTitle = new Paragraph("Problem(s):", getTitleFont()); PdfPCell problemsCell = new PdfPCell(table.getDefaultCell()); problemsCell.addElement(problemsTitle); for (ProblemItem problem : problemItems) { Paragraph probText = new Paragraph(" - " + problem.getName(), getValueFont()); problemsCell.addElement(probText); } table.addCell(problemsCell); table.completeRow(); return table; }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Adds the fields for the cheif complaint to the passed in table * * @param table the PdfPTable object to add the rows to * @param chiefComplaint the chief complaint as a string or null * @param tabFieldMultiMap multimap of the encounter's tab fields *//* w ww . j a v a 2 s . c o m*/ private void addChiefComplaintSectionToTable(PdfPTable table, String chiefComplaint, TabFieldMultiMap tabFieldMultiMap) { PdfPCell cellCC = new PdfPCell(table.getDefaultCell()); cellCC.addElement(getStyledPhrase("Chief Complaint: ", outputStringOrNA(chiefComplaint))); cellCC.setColspan(2); table.addCell(cellCC); // Known Field Names // Put styled phrase into a cell, then add it to the table PdfPCell onsetC = new PdfPCell(table.getDefaultCell()); onsetC.addElement(getStyledPhrase("Onset: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("onset", chiefComplaint).getValue()))); table.addCell(onsetC); PdfPCell fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("Quality: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("quality", chiefComplaint).getValue()))); table.addCell(fieldCell); fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("Severity: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("severity", chiefComplaint).getValue()))); table.addCell(fieldCell); fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("Provokes: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("provokes", chiefComplaint).getValue()))); table.addCell(fieldCell); fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("Palliates: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("palliates", chiefComplaint).getValue()))); table.addCell(fieldCell); fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("TimeOfDay: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("timeOfDay", chiefComplaint).getValue()))); table.addCell(fieldCell); fieldCell = new PdfPCell(table.getDefaultCell()); fieldCell.setPaddingRight(5); fieldCell.addElement(getStyledPhrase("Radiation: ", outputStringOrNA(tabFieldMultiMap.getMostRecentOrEmpty("radiation", chiefComplaint).getValue()))); table.addCell(fieldCell); // Physical Examination PdfPCell cellPE = new PdfPCell(table.getDefaultCell()); TabFieldItem fieldItem = tabFieldMultiMap.getMostRecentOrEmpty("physicalExamination", chiefComplaint); cellPE.addElement(getStyledPhrase("Physical Examination: ", outputStringOrNA(fieldItem.getValue()))); cellPE.setColspan(2); table.addCell(cellPE); // Narrative PdfPCell cellNarrative = new PdfPCell(table.getDefaultCell()); fieldItem = tabFieldMultiMap.getMostRecentOrEmpty("narrative", chiefComplaint); cellNarrative.addElement(getStyledPhrase("Narrative: ", outputStringOrNA(fieldItem.getValue()))); cellNarrative.setColspan(2); table.addCell(cellNarrative); // add an empty row to add spacing between chief complaints table.addCell(" "); table.completeRow(); }
From source file:fll.web.playoff.ScoresheetGenerator.java
License:Open Source License
public void writeFile(final OutputStream out, final boolean orientationIsPortrait) throws DocumentException { // This creates our new PDF document and declares its orientation Document pdfDoc;// w ww.ja v a 2 s . c om if (orientationIsPortrait) { pdfDoc = new Document(PageSize.LETTER); // portrait } else { pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape } PdfWriter.getInstance(pdfDoc, out); // Measurements are always in points (72 per inch) // This sets up 1/2 inch margins side margins and 0.35in top and bottom // margins pdfDoc.setMargins(0.5f * POINTS_PER_INCH, 0.5f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH); pdfDoc.open(); // Header cell with challenge title to add to both scoresheets final Paragraph titleParagraph = new Paragraph(); final Chunk titleChunk = new Chunk(m_pageTitle, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14, Font.NORMAL, BaseColor.WHITE)); titleParagraph.setAlignment(Element.ALIGN_CENTER); titleParagraph.add(titleChunk); titleParagraph.add(Chunk.NEWLINE); final Chunk swVersionChunk = new Chunk("SW version: " + Version.getVersion(), FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE)); titleParagraph.add(swVersionChunk); if (null != m_revision) { final Chunk revisionChunk = new Chunk(" Descriptor revision: " + m_revision, FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE)); titleParagraph.add(revisionChunk); } final PdfPCell head = new PdfPCell(); head.setColspan(2); head.setBorder(1); head.setPaddingTop(0); head.setPaddingBottom(3); head.setBackgroundColor(new BaseColor(64, 64, 64)); head.setVerticalAlignment(Element.ALIGN_TOP); head.addElement(titleParagraph); // Cells for score field, and 2nd check initials final Phrase des = new Phrase("Data Entry Score _______", ARIAL_8PT_NORMAL); final PdfPCell desC = new PdfPCell(des); desC.setBorder(0); desC.setPaddingTop(9); desC.setPaddingRight(36); desC.setHorizontalAlignment(Element.ALIGN_RIGHT); final Phrase sci = new Phrase("2nd Check Initials _______", ARIAL_8PT_NORMAL); final PdfPCell sciC = new PdfPCell(sci); sciC.setBorder(0); sciC.setPaddingTop(9); sciC.setPaddingRight(36); sciC.setHorizontalAlignment(Element.ALIGN_RIGHT); // Create a table with a grid cell for each scoresheet on the page PdfPTable wholePage = getTableForPage(orientationIsPortrait); wholePage.setWidthPercentage(100); for (int i = 0; i < m_numSheets; i++) { if (i > 0 && (orientationIsPortrait || (i % 2) == 0)) { pdfDoc.newPage(); wholePage = getTableForPage(orientationIsPortrait); wholePage.setWidthPercentage(100); } // This table is a single score sheet final PdfPTable scoreSheet = new PdfPTable(2); // scoreSheet.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM // | Rectangle.RIGHT | Rectangle.TOP); //FIXME DEBUG should be NO_BORDER scoreSheet.getDefaultCell().setBorder(Rectangle.NO_BORDER); scoreSheet.getDefaultCell().setPaddingRight(1); scoreSheet.getDefaultCell().setPaddingLeft(0); scoreSheet.addCell(head); final PdfPTable teamInfo = new PdfPTable(7); teamInfo.setWidthPercentage(100); teamInfo.setWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, .9f }); // Time label cell final Paragraph timeP = new Paragraph("Time:", ARIAL_10PT_NORMAL); timeP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell timeLc = new PdfPCell(scoreSheet.getDefaultCell()); timeLc.addElement(timeP); teamInfo.addCell(timeLc); // Time value cell final Paragraph timeV = new Paragraph(null == m_time[i] ? SHORT_BLANK : m_time[i], COURIER_10PT_NORMAL); final PdfPCell timeVc = new PdfPCell(scoreSheet.getDefaultCell()); timeVc.addElement(timeV); teamInfo.addCell(timeVc); // Table label cell final Paragraph tblP = new Paragraph("Table:", ARIAL_10PT_NORMAL); tblP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell tblLc = new PdfPCell(scoreSheet.getDefaultCell()); tblLc.addElement(tblP); teamInfo.addCell(tblLc); // Table value cell final Paragraph tblV = new Paragraph(m_table[i], COURIER_10PT_NORMAL); final PdfPCell tblVc = new PdfPCell(scoreSheet.getDefaultCell()); tblVc.addElement(tblV); teamInfo.addCell(tblVc); // Round number label cell final Paragraph rndP = new Paragraph("Round:", ARIAL_10PT_NORMAL); rndP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell rndlc = new PdfPCell(scoreSheet.getDefaultCell()); rndlc.addElement(rndP); teamInfo.addCell(rndlc); // Round number value cell final Paragraph rndV = new Paragraph(m_round[i], COURIER_10PT_NORMAL); final PdfPCell rndVc = new PdfPCell(scoreSheet.getDefaultCell()); // rndVc.setColspan(2); rndVc.addElement(rndV); teamInfo.addCell(rndVc); final PdfPCell temp1 = new PdfPCell(scoreSheet.getDefaultCell()); // temp1.setColspan(2); temp1.addElement(new Paragraph("Judge ____", ARIAL_8PT_NORMAL)); teamInfo.addCell(temp1); // Team number label cell final Paragraph nbrP = new Paragraph("Team #:", ARIAL_10PT_NORMAL); nbrP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell nbrlc = new PdfPCell(scoreSheet.getDefaultCell()); nbrlc.addElement(nbrP); teamInfo.addCell(nbrlc); // Team number value cell final Paragraph nbrV = new Paragraph(null == m_number[i] ? SHORT_BLANK : String.valueOf(m_number[i]), COURIER_10PT_NORMAL); final PdfPCell nbrVc = new PdfPCell(scoreSheet.getDefaultCell()); nbrVc.addElement(nbrV); teamInfo.addCell(nbrVc); // Team division label cell final Paragraph divP = new Paragraph(m_divisionLabel[i], ARIAL_10PT_NORMAL); divP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell divlc = new PdfPCell(scoreSheet.getDefaultCell()); divlc.addElement(divP); divlc.setColspan(2); teamInfo.addCell(divlc); // Team division value cell final Paragraph divV = new Paragraph(m_division[i], COURIER_10PT_NORMAL); final PdfPCell divVc = new PdfPCell(scoreSheet.getDefaultCell()); divVc.setColspan(2); divVc.addElement(divV); teamInfo.addCell(divVc); final PdfPCell temp2 = new PdfPCell(scoreSheet.getDefaultCell()); // temp2.setColspan(2); temp2.addElement(new Paragraph("Team ____", ARIAL_8PT_NORMAL)); teamInfo.addCell(temp2); // Team name label cell final Paragraph nameP = new Paragraph("Team Name:", ARIAL_10PT_NORMAL); nameP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell namelc = new PdfPCell(scoreSheet.getDefaultCell()); namelc.setColspan(2); namelc.addElement(nameP); teamInfo.addCell(namelc); // Team name value cell final Paragraph nameV = new Paragraph(m_name[i], COURIER_10PT_NORMAL); final PdfPCell nameVc = new PdfPCell(scoreSheet.getDefaultCell()); nameVc.setColspan(5); nameVc.addElement(nameV); teamInfo.addCell(nameVc); // add team info cell to the team table final PdfPCell teamInfoCell = new PdfPCell(scoreSheet.getDefaultCell()); teamInfoCell.addElement(teamInfo); teamInfoCell.setColspan(2); scoreSheet.addCell(teamInfoCell); if (null != m_goalsTable) { final PdfPCell goalCell = new PdfPCell(m_goalsTable); goalCell.setBorder(0); goalCell.setPadding(0); goalCell.setColspan(2); scoreSheet.addCell(goalCell); } scoreSheet.addCell(desC); scoreSheet.addCell(sciC); if (null != m_copyright) { final Phrase copyright = new Phrase("\u00A9" + m_copyright, f6i); final PdfPCell copyrightC = new PdfPCell(scoreSheet.getDefaultCell()); copyrightC.addElement(copyright); copyrightC.setBorder(0); copyrightC.setHorizontalAlignment(Element.ALIGN_CENTER); copyrightC.setColspan(2); scoreSheet.addCell(copyrightC); } // the cell in the whole page table that will contain the single score // sheet final PdfPCell scoresheetCell = new PdfPCell(scoreSheet); scoresheetCell.setBorder(0); scoresheetCell.setPadding(0); // Interior borders between scoresheets on a page if (!orientationIsPortrait) { if (i % 2 == 0) { scoresheetCell.setPaddingRight(0.1f * POINTS_PER_INCH); } else { scoresheetCell.setPaddingLeft(0.1f * POINTS_PER_INCH); } } // Add the current scoresheet to the page wholePage.addCell(scoresheetCell); // Add the current table of scoresheets to the document if (orientationIsPortrait || (i % 2 != 0)) { pdfDoc.add(wholePage); } } // Add a blank cells to complete the table of the last page if (!orientationIsPortrait && m_numSheets % 2 != 0) { final PdfPCell blank = new PdfPCell(); blank.setBorder(0); wholePage.addCell(blank); pdfDoc.add(wholePage); } pdfDoc.close(); }
From source file:fll.web.playoff.ScoresheetGenerator.java
License:Open Source License
/** * Stores the goal cells that are inserted into the output after the team name * headers and before the scoring/initials blanks at the bottom of the * scoresheet./*ww w.ja v a 2 s .co m*/ */ private void setChallengeInfo(final ChallengeDescription description) { setPageTitle(description.getTitle()); if (null != description.getRevision()) { setRevisionInfo(description.getRevision()); } if (null != description.getCopyright()) { m_copyright = description.getCopyright(); } else { m_copyright = null; } final PerformanceScoreCategory performanceElement = description.getPerformance(); // use ArrayList as we will be doing indexed access in the loop final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals()); final float[] relativeWidths = new float[3]; relativeWidths[0] = 4; relativeWidths[1] = 48; relativeWidths[2] = 48; m_goalsTable = new PdfPTable(relativeWidths); String prevCategory = null; for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) { final AbstractGoal goal = goals.get(goalIndex); if (!goal.isComputed()) { final String category = goal.getCategory(); // add category cell if needed boolean firstRowInCategory = false; if (!StringUtils.equals(prevCategory, category)) { if (!StringUtils.isEmpty(category)) { // find out how many future goals have the same category int categoryRowSpan = 1; for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) { final AbstractGoal otherGoal = goals.get(otherIndex); if (!otherGoal.isComputed()) { if (StringUtils.equals(category, otherGoal.getCategory())) { ++categoryRowSpan; } else { break; } } } final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL); final PdfPCell categoryCell = new PdfPCell(catPara); categoryCell.setBorderWidthTop(1); categoryCell.setBorderWidthBottom(0); categoryCell.setBorderWidthLeft(0); categoryCell.setBorderWidthRight(0); categoryCell.setVerticalAlignment(Element.ALIGN_CENTER); categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER); categoryCell.setRotation(90); categoryCell.setRowspan(categoryRowSpan); m_goalsTable.addCell(categoryCell); } // first row in a new category, which may be empty firstRowInCategory = true; } // This is the text for the left hand "label" cell final String title = goal.getTitle(); final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL); final PdfPCell goalLabel = new PdfPCell(p); goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT); goalLabel.setVerticalAlignment(Element.ALIGN_CENTER); if (firstRowInCategory) { goalLabel.setBorderWidthTop(1); goalLabel.setBorderWidthBottom(0); goalLabel.setBorderWidthLeft(0); goalLabel.setBorderWidthRight(0); } else { goalLabel.setBorder(0); } goalLabel.setPaddingRight(9); goalLabel.setVerticalAlignment(Element.ALIGN_TOP); if (StringUtils.isEmpty(category)) { // category column and goal label column goalLabel.setColspan(2); } m_goalsTable.addCell(goalLabel); // define the value cell final double min = goal.getMin(); final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min) : String.valueOf(min); final double max = goal.getMax(); final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max) : String.valueOf(max); // If element has child nodes, then we have an enumerated list // of choices. Otherwise it is either yes/no or a numeric field. final PdfPCell goalValue = new PdfPCell(); final Chunk choices = new Chunk("", COURIER_10PT_NORMAL); if (goal.isEnumerated()) { // replace spaces with "no-break" spaces boolean first = true; final List<EnumeratedValue> values = goal.getSortedValues(); for (final EnumeratedValue value : values) { if (!first) { choices.append(" /" + Utilities.NON_BREAKING_SPACE); } else { first = false; } choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE)); } goalValue.addElement(choices); } else { if (goal.isYesNo()) { // order of yes/no needs to match ScoreEntry.generateYesNoButtons final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL); goalValue.addElement(q); } else { final String range = "(" + minStr + " - " + maxStr + ")"; final PdfPTable t = new PdfPTable(2); t.setHorizontalAlignment(Element.ALIGN_LEFT); t.setTotalWidth(1 * POINTS_PER_INCH); t.setLockedWidth(true); final Phrase r = new Phrase("", ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(r)); final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(q)); goalValue.setPaddingTop(9); goalValue.addElement(t); } } if (firstRowInCategory) { goalValue.setBorderWidthTop(1); goalValue.setBorderWidthBottom(0); goalValue.setBorderWidthLeft(0); goalValue.setBorderWidthRight(0); } else { goalValue.setBorder(0); } goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE); m_goalsTable.addCell(goalValue); // setup for next loop prevCategory = category; } // if not computed goal } // foreach goal }
From source file:Functions.pdf_Export.java
public void createHeader(Document doc, Integer soHoaDon) { try {//from w w w.j a va 2 s .c om PdfPTable table = new PdfPTable(new float[] { 80, 20 }); table.setWidthPercentage(100); LinkedHashMap<String, Font> lines = new LinkedHashMap<>(); lines.put("Shop Name: " + shopName, titleFont); lines.put("Address: " + address, smallFont); lines.put("Phone Number: " + phoneNumb, smallFont); lines.put("Website: " + web, smallFont); lines.put("Email: " + email, smallFont); // left cell with shop's infor PdfPCell leftCell = new PdfPCell(); leftCell.setPaddingTop(-7); leftCell.setPaddingRight(35); Set<String> singleLine = lines.keySet(); // this below loop to create a line with text, and set it's font for (String line : singleLine) { leftCell.addElement(new Phrase(line, lines.get(line))); } leftCell.setHorizontalAlignment(Element.ALIGN_LEFT); leftCell.setBorder(PdfPCell.NO_BORDER); table.addCell(leftCell); // right cell with bill's time String time = new HoaDonDAO().getHoaDon(soHoaDon).getNgayLapHoaDon().toString(); PdfPCell rightCell = new PdfPCell(); rightCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); rightCell.addElement(new Phrase("Date: " + time + "\nNo.: " + soHoaDon, smallFont)); rightCell.setBorder(PdfPCell.NO_BORDER); table.addCell(rightCell); doc.add(table); } catch (DocumentException ex) { Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fxml.test.PDFService.java
public PdfPTable createFooter2() { PdfPTable table = new PdfPTable(8); table.setHorizontalAlignment(Element.ALIGN_LEFT); try {/* www .j a va 2 s.c o m*/ table.setTotalWidth(new float[] { 192f, 144f, 5f, 144f, 5f, 144f, 5f, 144f }); table.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell underLine = new PdfPCell(new Paragraph("_____________________")); underLine.setBorder(Rectangle.NO_BORDER); PdfPCell blankColumn = new PdfPCell(new Paragraph(" ")); blankColumn.setBorder(Rectangle.NO_BORDER); PdfPCell blankColumn2 = new PdfPCell(new Paragraph(" ")); blankColumn2.setBorder(Rectangle.BOTTOM); PdfPCell nameColumn = new PdfPCell(new Paragraph("Name :", font9)); nameColumn.setBorder(Rectangle.NO_BORDER); nameColumn.setPaddingLeft(0f); PdfPCell cell3 = new PdfPCell(new Paragraph(inputs.get(7).trim(), font9)); cell3.setPaddingRight(2); cell3.setBorder(Rectangle.TOP); PdfPCell cell4 = new PdfPCell(new Paragraph(inputs.get(8).trim(), font9)); cell4.setBorder(Rectangle.TOP); PdfPCell cell5 = new PdfPCell(new Paragraph(inputs.get(9).trim(), font9)); cell5.setBorder(Rectangle.TOP); PdfPCell cell6 = new PdfPCell(new Paragraph(inputs.get(10).trim(), font9)); cell6.setBorder(Rectangle.TOP); PdfPCell memberSignature = new PdfPCell(new Paragraph("Signature of the Members:", font9)); memberSignature.setPaddingLeft(0f); memberSignature.setBorder(Rectangle.NO_BORDER); table.addCell(memberSignature); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(nameColumn); table.addCell(cell3); table.addCell(blankColumn); table.addCell(cell4); table.addCell(blankColumn); table.addCell(cell5); table.addCell(blankColumn); table.addCell(cell6); PdfPCell tabulatorSignature = new PdfPCell(new Paragraph("Signature of the Tabulators:", font9)); tabulatorSignature.setPaddingLeft(0f); tabulatorSignature.setPaddingTop(13f); tabulatorSignature.setBorder(Rectangle.NO_BORDER); table.addCell(tabulatorSignature); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); return table; }
From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java
License:Open Source License
PdfPCell createHeaderAndValueTableCell(int index, String headerKey, String value, boolean addRightBorder) { PdfPTable table = createTable(ONE_COLUMN); table.addCell(createHeaderCell(index + ". " + getFromResources(headerKey))); table.addCell(createTableCell(value)); PdfPCell cell = createCell(table); if (addRightBorder) { cell.setPaddingRight(PADDING_RIGHT); }//from www .j a v a2 s. c o m return cell; }
From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java
License:Open Source License
private void addAddress(Address address, PdfPTable table, int index) { PdfPTable addressTable = pdfGenerator.createTable(AbstractPdfWriterGenerator.ONE_COLUMN); addressTable.addCell(/*from w w w . j a v a 2s .co m*/ pdfGenerator.createHeaderCell(index + ". " + pdfGenerator.getFromResources(ADDRESS_TITLE_KEY))); Paragraph contents = new Paragraph(); if (getOrganization() != null) { contents.add(pdfGenerator.getValueChunk(getOrganization().getName())); contents.add(Chunk.NEWLINE); } if (address != null) { addAddressContent(contents, address); } PdfPCell addressCell = pdfGenerator.createTableCell(contents); addressCell.setPaddingLeft(VALUE_CELL_INDENTATION); addressTable.addCell(addressCell); PdfPCell addressTableCell = pdfGenerator.createCell(addressTable); addressTableCell.setPaddingRight(PADDING_RIGHT); table.addCell(addressTableCell); }
From source file:net.digitstar.vanadio.helpers.PdfHelper.java
License:Apache License
public static PdfPCell newCell(CellStyle style) { PdfPCell cell = new PdfPCell(); if (style != null) { if (style.getNestedTable() != null) { cell = new PdfPCell(style.getNestedTable()); style.setNestedTable(null);//from w w w . ja v a 2s .c om } else if (style.getImage() != null) { cell = new PdfPCell(style.getImage(), style.isFitImage()); style.setImage(null); } else if (style.getText() != null) { cell = new PdfPCell(style.getText()); style.setText((String) null); } cell.setColspan(style.getColspan()); cell.setRowspan(style.getRowspan()); cell.setMinimumHeight(style.getMinimumHeight()); cell.setFixedHeight(style.getFixedHeight()); cell.setNoWrap(style.isNoWrap()); cell.setRotation(style.getRotation().getValue()); style = Alignment.assign(style); cell.setHorizontalAlignment(style.getHorizAlign().getValue()); cell.setVerticalAlignment(style.getVertAlign().getValue()); cell.setUseVariableBorders(style.isUseVariableBorders()); cell.setUseBorderPadding(style.isUseBorderPadding()); if (!style.getBorderWidth().isAllSideEqual()) { cell.setBorderWidthBottom(style.getBorderWidth().getBottom()); cell.setBorderWidthLeft(style.getBorderWidth().getLeft()); cell.setBorderWidthRight(style.getBorderWidth().getRight()); cell.setBorderWidthTop(style.getBorderWidth().getTop()); } else { cell.setBorderWidth(style.getBorderWidth().getValue()); } cell.setPaddingBottom(style.getPadding().getBottom()); cell.setPaddingLeft(style.getPadding().getLeft()); cell.setPaddingRight(style.getPadding().getRight()); cell.setPaddingTop(style.getPadding().getTop()); cell.setBorderColorBottom(style.getBorderColor().getBottom()); cell.setBorderColorLeft(style.getBorderColor().getLeft()); cell.setBorderColorRight(style.getBorderColor().getRight()); cell.setBorderColorTop(style.getBorderColor().getTop()); cell.setBorder(style.getBorder().getValue()); cell.setBackgroundColor(style.getBackgroundColor()); if (style.getGreyFill() >= 0) { cell.setGrayFill(style.getGreyFill()); } } return cell; }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private PdfPTable createTableHeader(ColumnList tableHeader, ArrayList<Column> orderedColumns) { for (int i = 0; i < tableHeader.getSize(); i++) { Column c = tableHeader.getField(i); if (c.isVisible()) { orderedColumns.add(c);/*from w w w . j ava2 s . com*/ } } Collections.sort(orderedColumns, new Comparator<Column>() { @Override public int compare(Column lhs, Column rhs) { if (lhs == null || rhs == null) { return 0; } return lhs.getOrder() - rhs.getOrder(); } }); float[] widths = new float[orderedColumns.size()]; for (int i = 0; i < orderedColumns.size(); i++) { Column column = orderedColumns.get(i); widths[i] = column.getWidth(); } PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(95); for (Column field : orderedColumns) { if (field.isVisible()) { PdfPCell cell = new PdfPCell(new Paragraph(field.getName(), getSansRegularBold(12f))); cell.setPaddingTop(4); cell.setPaddingBottom(4); cell.setPaddingLeft(5); cell.setPaddingRight(5); cell.setBorderWidth(0); cell.setBorder(PdfPCell.BOTTOM); cell.setBorderWidthBottom(1); cell.setBorderColor(SORTAVALA_GREEN); table.addCell(cell); } } table.setHeaderRows(1); return table; }