List of usage examples for com.itextpdf.text.pdf BaseFont HELVETICA
String HELVETICA
To view the source code for com.itextpdf.text.pdf BaseFont HELVETICA.
Click Source Link
From source file:de.aidger.utils.pdf.ActivityReportConverter.java
License:Open Source License
/** * Writes the logos and the address of the institute. *//* w w w. j a v a2 s . c om*/ private void writeLogo() { try { Font generatedByFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 8); Image aidger = Image.getInstance(getClass().getResource("/de/aidger/res/pdf/AidgerLogo.png")); aidger.scaleAbsolute(80.0f, 20.0f); PdfPTable table = new PdfPTable(2); table.setTotalWidth(reader.getPageSize(1).getRight()); PdfPCell cell = new PdfPCell(new Phrase(_("Generated by: "), generatedByFont)); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(cell); cell = new PdfPCell(Image.getInstance(aidger)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); table.addCell(cell); table.writeSelectedRows(0, -1, 0, 25, contentByte); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.aidger.utils.pdf.ActivityReportConverter.java
License:Open Source License
/** * Adds the rows of employments to the table. *//* w ww. j ava 2 s . c o m*/ private PdfPTable addRows() { PdfPTable contentTable = new PdfPTable(new float[] { 0.2f, 0.6f, 0.2f }); try { Font tableContentFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); for (String[] row : tableRows) { for (int i = 0; i < row.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(row[i], tableContentFont)); cell.setPaddingBottom(5); contentTable.addCell(cell); } } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return contentTable; }
From source file:de.aidger.utils.pdf.BalanceReportConverter.java
License:Open Source License
/** * Writes a semester table and adds the groups of that semester to it. * //from w ww .j av a2s . co m * @param semester * The name of the semester to be added. */ @SuppressWarnings("unchecked") private void createSemester(String semester) { balanceReportGroups = new ArrayList<ArrayList>(); try { Font semesterTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 13); Font semesterNameFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 13); PdfPTable finalSemesterTable = new PdfPTable(1); PdfPTable semesterTitleTable = new PdfPTable(new float[] { 0.2f, 0.8f }); PdfPCell semesterCell = new PdfPCell(new Phrase(_("Semester"), semesterTitleFont)); semesterCell.setBorder(0); semesterTitleTable.addCell(semesterCell); semesterCell = new PdfPCell(new Phrase(semester, semesterNameFont)); semesterCell.setBorder(0); semesterTitleTable.addCell(semesterCell); semesterCell = new PdfPCell(semesterTitleTable); semesterCell.setBorder(0); semesterCell.setPaddingTop(7.0f); finalSemesterTable.addCell(semesterCell); PdfPTable contentTable = new PdfPTable(1); /* * As long as there are groups for this Balance report, create new * group tables. */ List<Course> courses = null; if (semester != null) { courses = (new Course()).getCoursesBySemester(semester); } else { courses = new ArrayList<Course>(); List<Course> unsortedCourses = new Course().getAll(); for (Course course : unsortedCourses) { if (course.getSemester() == null) { courses.add(new Course(course)); } } } List<Course> filteredCourses = balanceHelper.filterCourses(courses, filters); for (Course course : filteredCourses) { PdfPTable groupTable = null; if (balanceReportGroups.isEmpty()) { groupTable = createGroup(course); } else { boolean foundGroup = false; for (int i = 0; i <= balanceReportGroups.size() - 1; i++) { if (((ArrayList) balanceReportGroups.get(i)).get(1).equals(course.getGroup())) { foundGroup = true; break; } } if (!foundGroup) { groupTable = createGroup(course); } } } for (int i = 0; i <= balanceReportGroups.size() - 1; i++) { PdfPCell cell = new PdfPCell((PdfPTable) ((ArrayList) balanceReportGroups.get(i)).get(0)); cell.setBorder(0); cell.setPaddingBottom(8.0f); contentTable.addCell(cell); } PdfPCell contentCell = new PdfPCell(contentTable); contentCell.setPaddingLeft(10.0f); contentCell.setBorder(1); finalSemesterTable.addCell(contentCell); finalSemesterTable.setKeepTogether(true); document.add(finalSemesterTable); } catch (Exception e) { Logger.error(e.getMessage()); } }
From source file:de.aidger.utils.pdf.BalanceReportConverter.java
License:Open Source License
/** * Creates a row with the data of one course and returns it. * /*from w w w.j ava 2 s .co m*/ * @param course * The course of which the data shall be written to a row. * @return The row as a PdfPCell */ private PdfPCell addRow(BalanceCourse balanceCourse, float[] columnwidths, ArrayList<Integer> costUnits) { PdfPTable groupContentTable = new PdfPTable(columnwidths); ArrayList<Object> rowObjectVector = new ArrayList<Object>(); Font tableContentFont; try { tableContentFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); for (int i = 0; i < 6; i++) { rowObjectVector.add((balanceCourse).getCourseObject()[i]); } sums.set(4, (Double) sums.get(4) + (Double) rowObjectVector.get(4)); sums.set(5, (Double) sums.get(5) + (Double) rowObjectVector.get(5)); int i = 0; for (Integer costUnit : costUnits) { boolean foundCostUnit = false; for (BudgetCost budgetCost : balanceCourse.getBudgetCosts()) { int budgetCostId = budgetCost.getId(); /* * Set the budget cost of the cost unit to the one * specified. */ if (budgetCostId == costUnit) { rowObjectVector.add(budgetCost.getValue()); foundCostUnit = true; } } if (!foundCostUnit) { rowObjectVector.add(0.0); } if (sums.size() < rowObjectVector.size()) { sums.add(rowObjectVector.get(rowObjectVector.size() - 1)); } else { sums.set(rowObjectVector.size() - 1, (Double) sums.get(rowObjectVector.size() - 1) + (Double) rowObjectVector.get(rowObjectVector.size() - 1)); } } for (Object courseObject : rowObjectVector.toArray()) { PdfPCell cell = null; if (courseObject.getClass().equals(Double.class)) { /* * Round to the configured precision. */ int decimalPlace = Integer.parseInt(Runtime.getInstance().getOption("rounding", "2")); double rounded = new BigDecimal((Double) courseObject) .setScale(decimalPlace, BigDecimal.ROUND_HALF_EVEN).doubleValue(); cell = new PdfPCell( new Phrase(new BigDecimal(rounded).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(), tableContentFont)); } else { cell = new PdfPCell(new Phrase(courseObject.toString(), tableContentFont)); } if (i != 0) { cell.setBorder(4 + Rectangle.BOTTOM); } else { cell.setBorder(0 + Rectangle.BOTTOM); i++; } cell.setPaddingBottom(5); groupContentTable.addCell(cell); } PdfPCell cell = new PdfPCell(groupContentTable); cell.setBorder(0); return cell; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.aidger.utils.pdf.BalanceReportConverter.java
License:Open Source License
/** * Creates a new group table with the title of the group. Adds the table and * its title to the group table vector./*from w w w. java2 s . c om*/ * * @param course * The course for which a group shall be created. * @return The PdfPTable of the group. */ @SuppressWarnings("unchecked") private PdfPTable createGroup(Course course) { balanceReportGroupCreator = new BalanceReportGroupCreator(course, calculationMethod); List<Course> courses = null; sums = new ArrayList<Object>(); try { if (course.getSemester() != null) { courses = (new Course()).getCoursesBySemester(course.getSemester()); } else { courses = new ArrayList<Course>(); List<Course> unsortedCourses = new Course().getAll(); for (Course currentCourse : unsortedCourses) { if (currentCourse.getSemester() == null) { courses.add(new Course(currentCourse)); } } } } catch (SienaException e) { UI.displayError(e.toString()); } List<Course> filteredCourses = balanceHelper.filterCourses(courses, filters); ArrayList<Long> addedCourses = new ArrayList<Long>(); addedCourses.add(course.getId()); for (Course filteredCourse : filteredCourses) { if (!addedCourses.contains(filteredCourse.getId()) && filteredCourse.getGroup().equals(course.getGroup())) { balanceReportGroupCreator.addCourse(filteredCourse); addedCourses.add(filteredCourse.getId()); } } ArrayList<Integer> costUnits = new ArrayList<Integer>(); ArrayList<BalanceCourse> balanceCourses = balanceReportGroupCreator.getBalanceCourses(); ArrayList<String> titles = new ArrayList<String>(); String[] courseTitles = { _("Title"), _("Part"), _("Lecturer"), _("Target Audience"), _("Planned AWS"), _("Basic needed AWS") }; for (int i = 0; i < courseTitles.length; i++) { titles.add(courseTitles[i]); } for (Object balanceCourse : balanceCourses) { for (BudgetCost budgetCost : ((BalanceCourse) balanceCourse).getBudgetCosts()) { int budgetCostId = budgetCost.getId(); String budgetCostName = budgetCost.getName(); if (!costUnits.contains(budgetCostId)) { costUnits.add(budgetCostId); titles.add(_("Budget costs from") + " " + budgetCostName); } } } int columnCount = titles.size(); Font tableTitleFont; Font tableContentFont; try { tableContentFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); Font groupTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 11); Font groupNameFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 11); PdfPTable groupTable = new PdfPTable(1); PdfPTable groupNameTable = new PdfPTable(new float[] { 0.2f, 0.8f }); PdfPCell groupTitle = new PdfPCell(new Phrase(_("Group"), groupTitleFont)); groupTitle.setBorder(2); groupNameTable.addCell(groupTitle); PdfPCell groupName = new PdfPCell(new Phrase(course.getGroup(), groupNameFont)); groupName.setBorder(2); groupNameTable.addCell(groupName); PdfPCell groupContent = new PdfPCell(groupNameTable); groupContent.setBorder(0); groupContent.setPaddingTop(3.0f); groupContent.setPaddingBottom(2.0f); groupTable.addCell(groupContent); float[] columnWidths = new float[columnCount]; columnWidths[0] = (200 / columnCount); columnWidths[1] = (50 / columnCount); columnWidths[2] = (100 / columnCount); columnWidths[3] = (150 / columnCount); columnWidths[4] = (100 / columnCount); for (int i = 5; i < columnCount; i++) { columnWidths[i] = (100 / columnCount); } PdfPTable groupContentTable = new PdfPTable(columnWidths); /* * Create the titles of the table entries. */ for (int i = 0; i < titles.size(); i++) { PdfPCell cell = new PdfPCell(new Phrase(titles.get(i), tableTitleFont)); if (i != 0) { cell.setBorder(6); } else { cell.setBorder(2); } groupContentTable.addCell(cell); } PdfPCell cell = new PdfPCell(groupContentTable); cell.setBorder(0); groupTable.addCell(cell); sums.add(_("Sum")); sums.add(""); sums.add(""); sums.add(""); sums.add(0.0); sums.add(0.0); for (Object balanceCourse : balanceCourses) { groupTable.addCell(addRow((BalanceCourse) balanceCourse, columnWidths, costUnits)); } PdfPTable emptyRow = new PdfPTable(columnWidths); PdfPTable sumRow = new PdfPTable(columnWidths); for (int i = 0; i < sums.size(); i++) { cell = new PdfPCell(new Phrase("")); if (i != 0) { cell.setBorder(Rectangle.TOP + Rectangle.LEFT); } else { cell.setBorder(Rectangle.TOP); } emptyRow.addCell(cell); if (i < 4) { cell = new PdfPCell(new Phrase(new Phrase(sums.get(i).toString(), tableContentFont))); } else { /* * Round to the configured precision. */ int decimalPlace = Integer.parseInt(Runtime.getInstance().getOption("rounding", "2")); double rounded = new BigDecimal((Double) sums.get(i)) .setScale(decimalPlace, BigDecimal.ROUND_HALF_EVEN).doubleValue(); cell = new PdfPCell( new Phrase(new BigDecimal(rounded).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(), tableContentFont)); } if (i != 0) { cell.setBorder(Rectangle.TOP + Rectangle.LEFT); } else { cell.setBorder(Rectangle.TOP); } sumRow.addCell(cell); } cell = new PdfPCell(emptyRow); cell.setBorder(0); groupTable.addCell(cell); cell = new PdfPCell(sumRow); cell.setBorder(0); groupTable.addCell(cell); groupTable.setKeepTogether(true); balanceReportGroups.add(new ArrayList<Object>()); int i = balanceReportGroups.size() - 1; ((ArrayList) balanceReportGroups.get(i)).add(groupTable); ((ArrayList) balanceReportGroups.get(i)).add(course.getGroup()); return groupTable; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.aidger.utils.pdf.BudgetReportConverter.java
License:Open Source License
/** * Adds a row, containing a course budget, to the table. * // w w w . j a va2 s. com * @param objectArray * The course budget. * @return The table containing the row. */ private PdfPTable addRow(Object[] objectArray) { try { Font tableContentFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); PdfPTable tableContent = new PdfPTable(new float[] { 0.3f, 0.15f, 0.15f, 0.15f, 0.15f, 0.10f }); Color cellColor = new Color(255, 255, 255); if (Double.parseDouble(objectArray[4].toString()) == 0) { cellColor = new Color(252, 200, 150); } for (int i = 0; i < objectArray.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(objectArray[i].toString(), tableContentFont)); cell.setBackgroundColor(new BaseColor(cellColor)); cell.setPaddingBottom(5); tableContent.addCell(cell); } return tableContent; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.aidger.utils.pdf.ControllingConverter.java
License:Open Source License
/** * Adds the rows of assistants to the table. *//*from ww w . ja v a 2 s . c om*/ private void addRows() { try { Font tableContentFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); PdfPTable contentTable = new PdfPTable(4); for (String[] row : tableRows) { for (int i = 0; i < row.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(row[i], tableContentFont)); cell.setPaddingBottom(5); contentTable.addCell(cell); } } document.add(contentTable); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.aidger.utils.pdf.ProtocolConverter.java
License:Open Source License
/** * Adds one activity to the activity table. * //from ww w.ja v a2 s.co m * @param activity * The activity to add. * @return The PdfPTable of the row. * @throws DocumentException * @throws IOException */ private PdfPTable addRow(Object[] activity) throws DocumentException, IOException { Font tableContentFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); PdfPTable contentTable = new PdfPTable(8); for (int i = 0; i < 8; i++) { PdfPCell cell = new PdfPCell(new Phrase(activity[i].toString(), tableContentFont)); if (i != 0) { cell.setBorder(4 + Rectangle.TOP); } else { cell.setBorder(0 + Rectangle.TOP); } cell.setPaddingBottom(5); contentTable.addCell(cell); } return contentTable; }
From source file:de.jost_net.JVerein.gui.control.FormularfeldControl.java
License:Open Source License
public SelectInput getFont() throws RemoteException { if (font != null) { return font; }/*from ww w. ja va2 s. c o m*/ ArrayList<String> fonts = new ArrayList<String>(); fonts.add("FreeSans"); fonts.add("FreeSans-Bold"); fonts.add("FreeSans-BoldOblique"); fonts.add("FreeSans-Oblique"); fonts.add(BaseFont.HELVETICA); fonts.add(BaseFont.HELVETICA_BOLD); fonts.add(BaseFont.HELVETICA_BOLDOBLIQUE); fonts.add(BaseFont.HELVETICA_OBLIQUE); fonts.add(BaseFont.TIMES_ROMAN); fonts.add(BaseFont.TIMES_BOLD); fonts.add(BaseFont.TIMES_ITALIC); fonts.add(BaseFont.TIMES_BOLDITALIC); fonts.add(BaseFont.COURIER); fonts.add(BaseFont.COURIER_BOLD); fonts.add(BaseFont.COURIER_OBLIQUE); fonts.add(BaseFont.COURIER_BOLDOBLIQUE); font = new SelectInput(fonts, getFormularfeld().getFont()); return font; }
From source file:de.mat.utils.pdftools.PdfAddPageNum.java
License:Mozilla Public License
/** * <h4>FeatureDomain:</h4>/*from w w w . ja v a 2 s .com*/ * PublishingTools * <h4>FeatureDescription:</h4> * adds pagenum with stamper to pages from reader * <h4>FeatureResult:</h4> * <ul> * <li>updates stamper - updates the stamper * </ul> * <h4>FeatureKeywords:</h4> * PDF Publishing * @param reader - reader with the pages * @param stamper - stamper to add the canvas * @param pageOffset - add to pagenumber * @throws DocumentException * @throws IOException */ public void addPageNumber(PdfReader reader, PdfStamper stamper, int pageOffset) throws DocumentException, IOException { // ierate all pages from reader for (int zaehler = 1; zaehler <= reader.getNumberOfPages(); zaehler++) { // read pagesize Rectangle pageSize = reader.getPageSize(zaehler); float xpos = pageSize.getLeft() + pageSize.getWidth() / 2; float ypos = 20; float fontSize = 7; // Default-Positions for --page-width 150mm --page-height 212mm == 601px if (pageSize.getHeight() > 602 || pageSize.getHeight() < 598) { // correct it relative float factor = pageSize.getHeight() / 601; if (LOGGER.isDebugEnabled()) LOGGER.debug(" PageHeight:" + pageSize.getHeight() + " Factor:" + factor); ypos = ypos * factor; fontSize = fontSize * factor; } // add pagenumber-canvas PdfContentByte canvas = stamper.getOverContent(zaehler); BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false); canvas.setFontAndSize(bf_helv, fontSize); canvas.beginText(); canvas.showTextAligned(PdfContentByte.ALIGN_CENTER, "" + new Integer(zaehler + pageOffset - 1), xpos, ypos, 0); canvas.endText(); } }