List of usage examples for com.itextpdf.text.pdf BaseFont HELVETICA_BOLD
String HELVETICA_BOLD
To view the source code for com.itextpdf.text.pdf BaseFont HELVETICA_BOLD.
Click Source Link
From source file:de.aidger.utils.pdf.ActivityReportConverter.java
License:Open Source License
/** * Creates the table of employments.//w ww.j a va 2s . com */ private void createTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 10); String[] tableTitles = { "Zeitraum", "Veranstaltung", "Umfang" }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(new float[] { 0.2f, 0.6f, 0.2f }); /* * Create the titles of the table entries. */ for (int i = 0; i < tableTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(tableTitles[i], tableTitleFont)); titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setPaddingBottom(2.0f); cell.setBorder(0); contentTable.addCell(cell); cell = new PdfPCell(addRows()); cell.setBorder(0); contentTable.addCell(cell); float xPos = 60, yPos = 500, width = reader.getPageSize(1).getWidth() - 120f; if (form.getFieldPositions("TableField") != null) { FieldPosition position = form.getFieldPositions("TableField").get(0); xPos = position.position.getLeft(); yPos = position.position.getTop(); width = position.position.getWidth(); } contentTable.setTotalWidth(width); contentTable.writeSelectedRows(0, -1, xPos, yPos, contentByte); } 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.BalanceReportConverter.java
License:Open Source License
/** * Writes a semester table and adds the groups of that semester to it. * //from www.ja v a2s .c om * @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 new group table with the title of the group. Adds the table and * its title to the group table vector./*from w w w .ja va2 s. co m*/ * * @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
/** * Creates the titles of the table.//from w w w. j a v a 2s .c om * * @return The table with the titles. */ private PdfPTable createTableHeader() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); PdfPTable tableHeader = new PdfPTable(new float[] { 0.3f, 0.15f, 0.15f, 0.15f, 0.15f, 0.10f }); String[] titles = { _("Course"), _("Semester"), _("Lecturer"), _("Booked budgets"), _("Available budgets"), _("Total Budgets") }; /* * Add the title of every column. */ for (int i = 0; i < titles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(titles[i], tableTitleFont)); tableHeader.addCell(cell); } PdfPTable tableHeaderTable = new PdfPTable(1); PdfPCell cell = new PdfPCell(tableHeader); cell.setPaddingBottom(1); cell.setBorder(0); tableHeaderTable.addCell(cell); return tableHeaderTable; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.aidger.utils.pdf.ControllingConverter.java
License:Open Source License
/** * Creates the table of assistants.//from ww w .j a va2 s . co m */ private void createTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); String[] courseTitles = { _("Assistant"), _("Planned costs(pre-tax)"), _("Actual costs(pre-tax)"), _("Remark") }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(4); /* * Create the titles of the table entries. */ for (int i = 0; i < courseTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(courseTitles[i], tableTitleFont)); titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setPaddingBottom(2.0f); cell.setBorder(0); contentTable.addCell(cell); document.add(contentTable); addRows(); } 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
/** * Writes the Table of activities.//from w ww . ja va 2 s . c om */ private void writeTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); String[] courseTitles = { _("Affected assistant"), _("Affected course"), _("Type"), _("Date"), _("Content"), _("Initiator"), _("Processor"), _("Remark") }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(8); /* * Create the titles of the table entries. */ for (int i = 0; i < courseTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(courseTitles[i], tableTitleFont)); if (i != 0) { cell.setBorder(6); } else { cell.setBorder(2); } titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setBorder(0); 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.jost_net.JVerein.gui.control.FormularfeldControl.java
License:Open Source License
public SelectInput getFont() throws RemoteException { if (font != null) { return font; }// w ww . j a va 2 s.co 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:edu.avans.ivh5.shared.util.generateInvoicePDF2.java
private void initializeFonts() { try {/*from w ww . j av a 2s. c om*/ bfBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
private void insertPinnedComment(float xCoord, float yCoord, String id, String comment, int pageNum, int masterHeight, int masterWidth) throws DocumentException, IOException { int standardHeight = 38; int standardWidth = 130; int lineHeight = 7; if (fontSize == 8) { standardHeight = 48;// w w w .j a va 2 s . com standardWidth = 180; lineHeight = 10; } else if (fontSize == 10) { standardHeight = 70; standardWidth = 210; lineHeight = 12; } // comment box position defines lower-left corner xCoord += 41; // x-coordinate of comment text box yCoord -= 7; // lower offset moves box up float f = (float) 0.4; PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(f); PdfContentByte fg = pds.getOverContent(pageNum); fg.setGState(gs1); fg.setLineWidth(.5f * getRatio(masterHeight, masterWidth, pageNum)); // Calculate additional needed height for the comment, based on length of comment. List<String> lines = createComment(cleanupComment(comment)); int numLines = lines.size(); int commentHeight = (numLines - 1) * lineHeight; // Draw the comment box String color = "0xF2F3E4"; Color c = Color.decode(color); color = "0xFAFAF4"; Color c2 = Color.decode(color); fg.setLineWidth(1f); fg.setColorStroke(new BaseColor(c.getRGB())); fg.setColorFill(new BaseColor(c2.getRGB())); float newCoords[] = pinnedCoords(xCoord, yCoord, standardWidth, standardHeight + commentHeight); fg.roundRectangle(xCoord, newCoords[1], standardWidth, standardHeight + commentHeight, 2f); fg.fillStroke(); //BaseFont bf = BaseFont.createFont(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, true); BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, true); fg.setColorFill(BaseColor.RED); gs1.setFillOpacity(0.8f); fg.setGState(gs1); // Adding comment title text Phrase phrase = new Phrase("Comment", new Font(bfb, fontSize)); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 7, 0); // Adding comment number phrase = new Phrase(id, new Font(bf, fontSize)); float offset = xCoord + 35; if (fontSize == 8) offset = xCoord + 45; else if (fontSize == 10) offset = xCoord + 55; ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, offset, yCoord - 7, 0); /* Remove 10/27/2015 Jon Changkachith // Adding 'comment' label text phrase = new Phrase("Comment", new Font(bfb, fontSize)); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 20f, 0); */ // Adding comment text int commentYOffset = 32; for (int i = 0; i < lines.size(); i++) { //phrase = new Phrase(lines.get(i), new Font(bf, fontSize)); phrase = composePhrase(lines.get(i), bf, bfb); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - commentYOffset, 0); commentYOffset += lineHeight; } }
From source file:printInv.GenerateInvoice.java
public void initializeFonts() { try {//from w w w .ja v a 2 s .co m bfBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }