List of usage examples for com.lowagie.text FontFactory HELVETICA
String HELVETICA
To view the source code for com.lowagie.text FontFactory HELVETICA.
Click Source Link
From source file:org.unitime.timetable.util.PdfFont.java
License:Open Source License
private static Font createFont(float size, boolean fixed, boolean bold, boolean italic) { String font = null;/*from w w w. j a va 2 s . c om*/ if (fixed) font = ApplicationProperty.PdfFontFixed.value(); else if (bold) { if (italic) font = ApplicationProperty.PdfFontBoldItalic.value(); else font = ApplicationProperty.PdfFontBold.value(); } else if (italic) font = ApplicationProperty.PdfFontItalic.value(); else font = ApplicationProperty.PdfFontNormal.value(); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size); } catch (Throwable t) { } } font = (fixed ? ApplicationProperty.PdfFontFixed.value() : ApplicationProperty.PdfFontNormal.value()); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size, italic && bold ? Font.BOLDITALIC : italic ? Font.ITALIC : bold ? Font.BOLD : Font.NORMAL); } catch (Throwable t) { } } if (fixed) return FontFactory.getFont(bold ? italic ? FontFactory.COURIER_BOLDOBLIQUE : FontFactory.COURIER_BOLD : italic ? FontFactory.COURIER_OBLIQUE : FontFactory.COURIER, size); else return FontFactory .getFont(bold ? italic ? FontFactory.HELVETICA_BOLDOBLIQUE : FontFactory.HELVETICA_BOLD : italic ? FontFactory.HELVETICA_OBLIQUE : FontFactory.HELVETICA, size); }
From source file:oscar.oscarReport.pageUtil.GenerateEnvelopesAction.java
License:Open Source License
Paragraph getEnvelopeLabel(String text) { Paragraph p = new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 18)); p.setLeading(22); return p; }
From source file:questions.tables.TableHeaderAlternateBackground.java
public static void main(String[] args) { // step 1: creation of a document-object Document document = new Document(PageSize.A4.rotate()); try {/*from www.jav a 2 s. c o m*/ // step 2: // we create a writer PdfWriter.getInstance( // that listens to the document document, // and directs a PDF-stream to a file new FileOutputStream(RESULT)); // step 3: we open the document document.open(); // step 4: we add a table to the document PdfPTable datatable = new PdfPTable(10); datatable.setTableEvent(new AlternateBackground()); int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 }; datatable.setWidths(headerwidths); datatable.setWidthPercentage(100); datatable.getDefaultCell().setPadding(5); // The header starts with a cell that spans 10 columns PdfPCell cell = new PdfPCell(new Phrase("Administration - System Users Report", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(2); cell.setColspan(10); cell.setBackgroundColor(Color.YELLOW); cell.setUseDescender(true); datatable.addCell(cell); // We need 4 cells with rowspan 2 datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setBackgroundColor(Color.YELLOW); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell("User Id"); datatable.addCell("Name\nAddress"); datatable.addCell("Company"); datatable.addCell("Department"); datatable.getDefaultCell().setBackgroundColor(null); // we use a nested table to fake this PdfPTable permissions = new PdfPTable(6); permissions.getDefaultCell().setBackgroundColor(Color.YELLOW); permissions.getDefaultCell().setBorderWidth(2); permissions.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); permissions.getDefaultCell().setColspan(6); permissions.addCell("Permissions"); permissions.getDefaultCell().setColspan(1); permissions.addCell("Admin"); permissions.addCell("Data"); permissions.addCell("Expl"); permissions.addCell("Prod"); permissions.addCell("Proj"); permissions.addCell("Online"); PdfPCell permission = new PdfPCell(permissions); permission.setColspan(6); datatable.addCell(permission); // this is the end of the table header // as far as PdfPTable is concerned there are 2 rows in the header datatable.setHeaderRows(2); // we add the data to the table datatable.getDefaultCell().setBorderWidth(1); for (int i = 1; i < 50; i++) { datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("myUserId"); datatable.addCell("Person " + i); datatable.addCell("No Name Company"); datatable.addCell("D" + i); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); for (int j = 0; j < 6; j++) datatable.addCell(Math.random() > .5 ? "Yes" : "No"); } document.add(datatable); } 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:sg.edu.nus.util.ReportWriter.java
public static String writeDataArrayToPdf(String userName, ArrayList<String[]> data, String title) { String rawFileName = userName + "_report.pdf"; String fileName = ServerPeer.getReportFolderPath() + "/" + rawFileName; int ncol = data.get(0).length; Document document = new Document(); try {/* ww w . ja v a 2 s. c o m*/ PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); /* Create the font. The font name must exactly match the font name on the client system. */ Paragraph para = null; // RtfFont embossedFont = new RtfFont("Times New Roman", 12, // RtfFont.STYLE_EMBOSSED); // We add one empty line para = new Paragraph(); addEmptyLine(para, 1); // Lets write a big header para.add(new Paragraph(title, catFont)); addEmptyLine(para, 1); // Will create: Report generated by: _name, _date para.add(new Paragraph("Report generated by: " + userName + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(para, 3); document.add(para); //add header and table content Font font8 = FontFactory.getFont(FontFactory.HELVETICA, 12); PdfPTable table = null; float columnPercentage = (float) (100.0 / ncol); float[] columnDefinitionSize = new float[ncol]; for (int c = 0; c < ncol; c++) { columnDefinitionSize[c] = columnPercentage; } table = new PdfPTable(columnDefinitionSize); // table.getDefaultCell().setBorder(0); table.setHorizontalAlignment(0); float width = document.getPageSize().getWidth(); table.setTotalWidth(width - 72); table.setLockedWidth(true); //write header String[] arr = data.get(0); for (int j = 0; j < ncol; j++) { table.addCell(new Phrase(arr[j], subFont)); } //write data for (int i = 1; i < data.size(); i++) { arr = data.get(i); for (int j = 0; j < ncol; j++) { table.addCell(new Phrase(arr[j], font8)); } } document.add(table); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); return ServerPeer.getWebDownloadAddress() + "/" + rawFileName; }
From source file:sg.edu.nus.util.ReportWriter.java
public static String writeDataArrayToRtf(String userName, ArrayList<String[]> data, String title) { String rawFileName = userName + "_report.rtf"; String fileName = ServerPeer.getReportFolderPath() + "/" + rawFileName; int ncol = data.get(0).length; Document document = new Document(); try {/* w w w . ja v a 2 s . c o m*/ RtfWriter2.getInstance(document, new FileOutputStream(fileName)); document.open(); Paragraph para = null; // We add one empty line para = new Paragraph(); addEmptyLine(para, 1); // Lets write a big header para.add(new Paragraph(title, catFont)); addEmptyLine(para, 1); // Will create: Report generated by: _name, _date para.add(new Paragraph("Report generated by: " + userName + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(para, 3); document.add(para); //add header and table content Font font8 = FontFactory.getFont(FontFactory.HELVETICA, 12); PdfPTable table = null; float columnPercentage = (float) (100.0 / ncol); float[] columnDefinitionSize = new float[ncol]; for (int c = 0; c < ncol; c++) { columnDefinitionSize[c] = columnPercentage; } table = new PdfPTable(columnDefinitionSize); // table.getDefaultCell().setBorder(0); table.setHorizontalAlignment(0); float width = document.getPageSize().getWidth(); table.setTotalWidth(width - 72); table.setLockedWidth(true); //write header String[] arr = data.get(0); for (int j = 0; j < ncol; j++) { table.addCell(new Phrase(arr[j], subFont)); } //write data for (int i = 1; i < data.size(); i++) { arr = data.get(i); for (int j = 0; j < ncol; j++) { table.addCell(new Phrase(arr[j], font8)); } } document.add(table); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); return ServerPeer.getWebDownloadAddress() + "/" + rawFileName; }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildBlankLine</code></h2> * /*from w w w . ja va 2s . c om*/ * <p> * build a 'blank' line * </p> */ private void buildBlankLine() throws DocumentException { if (++rowCount < pageLength) { PdfPCell cell; for (int c = 0; c < reportColumns.length; c++) { cell = new PdfPCell( new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); cell.setBorder(0); cell.setBackgroundColor(totalColor); reportBody.addCell(cell); } } }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildDetilLine</code></h2> * //w ww . jav a2 s . co m * <p> * create and print a detail line on the report * </p> * * * @param String [] record - report record to print * */ private void buildDetilLine(String[] record) throws DocumentException { newpage = isNewPage(++rowCount); PdfPCell cell; if (record != null) { for (int c = 0; c < reportColumns.length; c++) { ReportColumn column = (ReportColumn) reportColumns[c]; String value = " "; if (record != null) { if (column.getLevelBreak() > 0) value = column.getAccumulator().getPrintValue(newpage); else value = record[c]; } cell = new PdfPCell( new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); cell.setBorder(0); cell.setNoWrap(true); cell.setBackgroundColor(detailColor); if (column.getAlignment().equals(ReportColumn.LEFT)) cell.setHorizontalAlignment(Cell.ALIGN_LEFT); else if (column.getAlignment().equals(ReportColumn.RIGHT)) cell.setHorizontalAlignment(Cell.ALIGN_RIGHT); else cell.setHorizontalAlignment(Cell.ALIGN_CENTER); reportBody.addCell(cell); } } }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildReportTitles</code></h2> * //from w ww .jav a 2 s . c o m * <p> * Create the report headings * </p> * * @param DataSet reportTable - the report data object * */ private void buildReportTitles(DataSet reportTable) throws DocumentException, BadElementException, MalformedURLException, IOException { Paragraph title = new Paragraph(); title.add(Image.getInstance(dataAccess.getImagePath() + "reportLogo.gif")); title.add(new Chunk( new SimpleDateFormat(" " + "hh:mm:ss - dd MMM yyyy").format(new Date()), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); title.add(new Chunk(" " + reportTable.getStringField(ReportColumn.REPORT_TITLE), FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD))); HeaderFooter header = new HeaderFooter(title, false); header.setBorder(0); HeaderFooter footer = new HeaderFooter( new Phrase("page:", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL)), true); footer.setAlignment(HeaderFooter.ALIGN_CENTER); document.setHeader(header); document.setFooter(footer); reportColumns = reportTable.getTableVector(ReportColumn.REPORT_DETAILS).toArray(); topA = new ReportAccumulator(this, -1, reportColumns.length); bottomA = topA; reportBody = new PdfPTable(reportColumns.length); reportBody.setTotalWidth(1.100f); reportBody.setHeaderRows(1); float cW[] = new float[reportColumns.length]; for (int c = 0; c < reportColumns.length; c++) { ReportColumn column = (ReportColumn) reportColumns[c]; if (column.getLevelBreak() > 0) { ReportAccumulator r = new ReportAccumulator(this, c, reportColumns.length); bottomA.setChildAccumulator(r); r.setParentAccumulator(bottomA); column.setAccumulator(r); bottomA = r; } PdfPCell hdr = new PdfPCell(new Paragraph(column.getDescription(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))); hdr.setBorder(Rectangle.BOTTOM); if (column.getAlignment().equals(ReportColumn.LEFT)) hdr.setHorizontalAlignment(Cell.ALIGN_LEFT); else if (column.getAlignment().equals(ReportColumn.RIGHT)) hdr.setHorizontalAlignment(Cell.ALIGN_RIGHT); else hdr.setHorizontalAlignment(Cell.ALIGN_CENTER); reportBody.addCell(hdr); cW[c] = (float) column.getLength(); } reportBody.setWidths(cW); }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildTotalLine</code></h2> * //from ww w . jav a2 s. c om * <p> * Create printed total lines * </p> * * @param String[] record - A report total line * */ private void buildTotalLine(String[] record) throws DocumentException { ++rowCount; PdfPCell cell; if (record != null) { for (int c = 0; c < reportColumns.length; c++) { ReportColumn column = (ReportColumn) reportColumns[c]; String value = record[c]; cell = new PdfPCell( new Paragraph(value, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); cell.setBorder(0); cell.setNoWrap(true); cell.setBackgroundColor(totalColor); if (column.getAlignment().equals(ReportColumn.LEFT)) cell.setHorizontalAlignment(Cell.ALIGN_LEFT); else if (column.getAlignment().equals(ReportColumn.RIGHT)) cell.setHorizontalAlignment(Cell.ALIGN_RIGHT); else cell.setHorizontalAlignment(Cell.ALIGN_CENTER); reportBody.addCell(cell); } } }