List of usage examples for com.lowagie.text.pdf BaseFont SYMBOL
String SYMBOL
To view the source code for com.lowagie.text.pdf BaseFont SYMBOL.
Click Source Link
From source file:org.pentaho.reporting.libraries.fonts.itext.ITextBuiltInFontRegistry.java
License:Open Source License
private FontFamily createSymbolFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily("Symbol"); fontFamily.addFontRecord(new ITextBuiltInFontRecord(fontFamily, BaseFont.SYMBOL, false, false, false)); return fontFamily; }
From source file:org.pz.platypus.plugin.html.HtmlFont.java
License:Open Source License
/** * Get the name by which iText refers to this font. This routine is mostly occupied * with the special handling of the base14 fonts. For all other fonts, this routine * simply returns its existing name./*from w ww . j a v a 2 s. co m*/ * * @param f PdfFont whose iText name we're getting * @return a string containing the iText usable name for this font. */ String createItextFontName(final HtmlFont f) { String iTextFontName; String typefaceName = f.typeface; // handle the different versions of base14 fonts if (typefaceName.equals("COURIER")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.COURIER_BOLDOBLIQUE; else iTextFontName = BaseFont.COURIER_BOLD; } else if (f.italics) iTextFontName = BaseFont.COURIER_OBLIQUE; else iTextFontName = BaseFont.COURIER; } else if (typefaceName.equals("HELVETICA")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.HELVETICA_BOLDOBLIQUE; else iTextFontName = BaseFont.HELVETICA_BOLD; } else if (f.italics) iTextFontName = BaseFont.HELVETICA_OBLIQUE; else iTextFontName = BaseFont.HELVETICA; } else if (typefaceName.equals("TIMES_ROMAN")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.TIMES_BOLDITALIC; else iTextFontName = BaseFont.TIMES_BOLD; } else if (f.italics) iTextFontName = BaseFont.TIMES_ITALIC; else iTextFontName = BaseFont.TIMES_ROMAN; } else if (typefaceName.equals("SYMBOL")) { iTextFontName = BaseFont.SYMBOL; } else if (typefaceName.equals("DINGBATS")) { iTextFontName = BaseFont.ZAPFDINGBATS; } else // not a base14 font. So make sure we've loaded the font files for Platypus // then look up this font among them. If it's still not there, then return // a TIMES_ROMAN and note the error. { // if( htmlData.getTypefaceMap() == null ) { // TypefaceMap typefaceMap = new TypefaceMap( htmlData.getGdd() ); // typefaceMap.loadFamilies(); // htmlData.setTypefaceMap( typefaceMap ); // } // if the font files for this typeface/font family have not been previously registered, // then get the filenames from the typefaceMap and register them in iText's FontFactory if (!FontFactory.isRegistered(typefaceName)) { String[] fontFiles = pdfData.getTypefaceMap().getFamilyFilenames(typefaceName); for (String fontFile : fontFiles) { FontFactory.register(fontFile); } gdd.log("Registered fonts for " + typefaceName + " in iText"); } if (FontFactory.isRegistered(typefaceName)) { iTextFontName = typefaceName; } else { // the filename does not exist on the system, so substitute TIMES_ROMAN iTextFontName = BaseFont.TIMES_ROMAN; } // } // else { // gdd.logInfo( // gdd.getLit( "FILE#" ) + " " + source.getFileNumber() + " " + // gdd.getLit( "LINE#" ) + " " + source.getLineNumber() + ": " + // gdd.getLit( "ERROR.INVALID_FONT_TYPEFACE" ) + " " + // f.typeface + " " + // gdd.getLit( "IGNORED" )); // iTextFontName = typeface; } return (iTextFontName); }
From source file:org.pz.platypus.plugin.pdf.PdfFontFactory.java
License:Open Source License
/** * Gets the iText font name for any of the Base14 fonts. * * @param font the PdfFont whose name we're looking up. * @return the iText name or null if an error has occured *///from w w w . j a va 2 s . c om String computeBase14ItextFontName(final PdfFont font) { final String typefaceName; String iTextFontName = null; PdfFont f; // in the impossible event this gets passed a null, then // replace it with the default font. It might be better // to just throw an exception. Should revisit this later. if (font == null) { f = new PdfFont(pdfData); } else { f = font; } typefaceName = f.getFace(); if (typefaceName.equals("COURIER")) { if (f.getBold()) { if (f.getItalics()) { iTextFontName = BaseFont.COURIER_BOLDOBLIQUE; } else { iTextFontName = BaseFont.COURIER_BOLD; } } else if (f.getItalics()) { iTextFontName = BaseFont.COURIER_OBLIQUE; } else iTextFontName = BaseFont.COURIER; return (iTextFontName); } if (typefaceName.equals("HELVETICA")) { if (f.getBold()) { if (f.getItalics()) { iTextFontName = BaseFont.HELVETICA_BOLDOBLIQUE; } else { iTextFontName = BaseFont.HELVETICA_BOLD; } } else if (f.getItalics()) { iTextFontName = BaseFont.HELVETICA_OBLIQUE; } else { iTextFontName = BaseFont.HELVETICA; } return (iTextFontName); } if (typefaceName.equals("TIMES_ROMAN")) { if (f.getBold()) { if (f.getItalics()) iTextFontName = BaseFont.TIMES_BOLDITALIC; else iTextFontName = BaseFont.TIMES_BOLD; } else if (f.getItalics()) iTextFontName = BaseFont.TIMES_ITALIC; else iTextFontName = BaseFont.TIMES_ROMAN; return (iTextFontName); } if (typefaceName.equals("SYMBOL")) { iTextFontName = BaseFont.SYMBOL; return (iTextFontName); } if (typefaceName.equals("DINGBATS")) { iTextFontName = BaseFont.ZAPFDINGBATS; return (iTextFontName); } // in theory, impossible, since the font is validated before the function is called. return (iTextFontName); }
From source file:org.pz.platypus.plugin.rtf.RtfFont.java
License:Open Source License
/** * Get the name by which iText refers to this font. This routine is mostly occupied * with the special handling of the base14 fonts. * * For all other fonts, this method makes sure the font is registered with iText and * returns its name as registered by iText (which is the family name for the font). * * @param f PdfFont whose iText name we're getting * @return a string containing the iText usable name for this font. *//* w w w.ja va2 s.c o m*/ String createItextFontName(final RtfFont f) { String iTextFontName; String typefaceName = f.typeface; // handle the different versions of base14 fonts if (typefaceName.equals("COURIER")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.COURIER_BOLDOBLIQUE; else iTextFontName = BaseFont.COURIER_BOLD; } else if (f.italics) iTextFontName = BaseFont.COURIER_OBLIQUE; else iTextFontName = BaseFont.COURIER; } else if (typefaceName.equals("HELVETICA")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.HELVETICA_BOLDOBLIQUE; else iTextFontName = BaseFont.HELVETICA_BOLD; } else if (f.italics) iTextFontName = BaseFont.HELVETICA_OBLIQUE; else iTextFontName = BaseFont.HELVETICA; } else if (typefaceName.equals("TIMES_ROMAN")) { if (f.bold) { if (f.italics) iTextFontName = BaseFont.TIMES_BOLDITALIC; else iTextFontName = BaseFont.TIMES_BOLD; } else if (f.italics) iTextFontName = BaseFont.TIMES_ITALIC; else iTextFontName = BaseFont.TIMES_ROMAN; } else if (typefaceName.equals("SYMBOL")) { iTextFontName = BaseFont.SYMBOL; } else if (typefaceName.equals("DINGBATS")) { iTextFontName = BaseFont.ZAPFDINGBATS; } else // It's not a base14 font. So make sure we've loaded the font files for Platypus // then look up this font among them. If it's still not there, then return // a TIMES_ROMAN and note the error. { if (!FontFactory.isRegistered(typefaceName)) { if (!findAndRegisterFont(typefaceName)) { return (null); } } if (FontFactory.isRegistered(typefaceName)) { iTextFontName = typefaceName; } else { // in theory, cannot get here. gdd.logWarning(gdd.getLit("COULD_NOT_FIND") + " " + typefaceName + " " + gdd.getLit("IN_FONT_REGISTER") + ". " + gdd.getLit("USING_TIMES_ROMAN") + "."); iTextFontName = null; } } return (iTextFontName); }
From source file:org.xhtmlrenderer.pdf.ITextFontResolver.java
License:Open Source License
private static void addSymbol(Map result) throws DocumentException, IOException { FontFamily fontFamily = new FontFamily(); fontFamily.setName("Symbol"); fontFamily.addFontDescription(/*from www.j a v a 2 s . com*/ new FontDescription(createFont(BaseFont.SYMBOL, BaseFont.CP1252, false), IdentValue.NORMAL, 400)); result.put("Symbol", fontFamily); }
From source file:recite18th.controller.Controller.java
License:Open Source License
public void print(String action) { /** thanks to http://www.java2s.com/Code/Java/PDF-RTF/DemonstratesthecreatingPDFinportraitlandscape.htm * QUICK FIX : do landscape/* ww w . j a v a 2 s . c om*/ */ response.setContentType("application/pdf"); // Code 1 if (action.equals("download")) { response.setHeader("Content-Transfer-Encoding", "binary"); response.setHeader("Content-Disposition", "attachment; filename=\"" + "Report " + controllerName + ".pdf\""); } Document document = new Document(PageSize.A1.rotate()); try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // Code 2 document.open(); // various fonts BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false); BaseFont bf_times = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false); BaseFont bf_courier = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false); BaseFont bf_symbol = BaseFont.createFont(BaseFont.SYMBOL, "Cp1252", false); String headerImage = Config.base_path + "images/report-logo.gif"; Image imghead = Image.getInstance(headerImage); imghead.setAbsolutePosition(0, 0); PdfContentByte cbhead = writer.getDirectContent(); PdfTemplate tpLogo = cbhead.createTemplate(600, 300); tpLogo.addImage(imghead); PdfTemplate tpTitle = cbhead.createTemplate(1100, 300); String txtHeader = "BADAN KEPEGAWAIAN DAERAH PEMERINTAH DAERAH";//Config.application_title; tpTitle.beginText(); tpTitle.setFontAndSize(bf_times, 36); tpTitle.showText(txtHeader); tpTitle.endText(); PdfTemplate tpTitle2 = cbhead.createTemplate(900, 300); String txtHeader2 = " KABUPATEN BANTUL YOGYAKARTA"; tpTitle2.beginText(); tpTitle2.setFontAndSize(bf_times, 36); tpTitle2.showText(txtHeader2); tpTitle2.endText(); PdfTemplate tpAlamat = cbhead.createTemplate(1000, 400); tpAlamat.beginText(); tpAlamat.setFontAndSize(bf_times, 24); tpAlamat.showText( "Alamat : Jln. R. W. Monginsidi No. 01 Kompleks Parasamya Bantul, Telp. (0274) 367509"); tpAlamat.endText(); DateFormat df = new SimpleDateFormat("dd MMM yyyy"); java.util.Date dt = new java.util.Date(); PdfTemplate tp3 = cbhead.createTemplate(600, 300); tp3.beginText(); tp3.setFontAndSize(bf_times, 16); tp3.showText("Tanggal : " + df.format(dt)); tp3.endText(); cbhead.addTemplate(tpLogo, 800, 1500);//logo cbhead.addTemplate(tpTitle, 1000, 1580); cbhead.addTemplate(tpTitle2, 1000, 1540); cbhead.addTemplate(tpAlamat, 1000, 1500);//alamat cbhead.addTemplate(tp3, 270, 1500);//tanggal HeaderFooter header = new HeaderFooter(new Phrase(cbhead + "", new Font(bf_helv)), false); header.setAlignment(Element.ALIGN_CENTER); document.setHeader(header); //PdfContentByte cb = writer.getDirectContent(); Paragraph par = new Paragraph( "\n\n\n\n\n\n\nLAPORAN DATA SELURUH " + controllerName.toUpperCase() + "\n"); par.getFont().setStyle(Font.BOLD); par.getFont().setSize(18); par.setAlignment("center"); document.add(par); document.add(new Paragraph("\n\n")); // get data initSqlViewDataPerPage(); if (sqlViewDataPerPageForReport == null) { sqlViewDataPerPageForReport = sqlViewDataPerPage; } PreparedStatement pstmt = Db.getCon().prepareStatement(sqlViewDataPerPageForReport, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = pstmt.executeQuery(); ResultSetMetaData metaColumn = resultSet.getMetaData(); int nColoumn = metaColumn.getColumnCount(); // thanks to set cell width http://www.jexp.ru/index.php/Java/PDF_RTF/Table_Cell_Size#Setting_Cell_Widths if (nColoumn > 0) { Model model = initModel(); String tableName = model.getTableName(); // create table header // float[] widths = {1, 4}; PdfPTable table;// = new PdfPTable(nColoumn); PdfPCell cell = new PdfPCell(new Paragraph("Daftar " + controllerName)); Hashtable hashModel = TableCustomization.getTable(model.getTableName()); int ncolumnHeader = nColoumn + 1; // +1 because of row. number if (hashModel != null) { ncolumnHeader = Integer.parseInt("" + hashModel.get("columnCount")) + 1; } table = new PdfPTable(ncolumnHeader); cell.setColspan(ncolumnHeader); cell.setHorizontalAlignment(Element.ALIGN_CENTER); Paragraph p2 = new Paragraph("No."); p2.getFont().setSize(20); PdfPCell cellColNo = new PdfPCell(p2); cellColNo.setNoWrap(true); cellColNo.setMinimumHeight(50); cellColNo.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellColNo); if (hashModel != null) { Enumeration k = hashModel.keys(); while (k.hasMoreElements()) { String key = (String) k.nextElement(); if (key.equals("columnCount")) { continue; } PdfPCell cellCol = new PdfPCell(new Paragraph(hashModel.get(key) + "")); cellCol.setNoWrap(true); cellCol.setMinimumHeight(50); cellCol.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellCol); } } else { for (int i = 1; i < ncolumnHeader; i++) { System.out.println("DATA = " + metaColumn.getColumnName(i)); Paragraph p1 = new Paragraph(metaColumn.getColumnName(i) + ""); p1.getFont().setSize(20); PdfPCell cellCol = new PdfPCell(p1); cellCol.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellCol); } } //iterate all columns : table data resultSet.beforeFirst(); int row = 1; while (resultSet.next()) { System.out.println(row); Paragraph p3 = new Paragraph(row + ""); p3.getFont().setSize(20); cell = new PdfPCell(p3); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); if (hashModel != null) {//skip dulu u/ kasus ga pny class kustomasi table Enumeration k = hashModel.keys(); while (k.hasMoreElements()) { String key = (String) k.nextElement(); if (key.equals("columnCount")) { continue; } table.addCell(resultSet.getObject(key) + ""); } } else { for (int i = 1; i < ncolumnHeader; i++) { System.out.println("DATA = " + metaColumn.getColumnName(i)); Paragraph p1 = new Paragraph(resultSet.getObject(metaColumn.getColumnName(i)) + ""); p1.getFont().setSize(18); PdfPCell cellCol = new PdfPCell(p1); cellCol.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellCol); } } row++; } document.add(table); document.add(new Paragraph("\n\n")); par = new Paragraph("Mengetahui"); par.setAlignment("center"); document.add(par); par = new Paragraph("Kepada Badan Kepegawaian"); par.setAlignment("center"); document.add(par); par = new Paragraph("\n\n\n"); document.add(par); par = new Paragraph("Drs. Maman Permana"); par.setAlignment("center"); document.add(par); par = new Paragraph("Nip: 197802042006041013"); par.setAlignment("center"); document.add(par); } document.close(); } catch (Exception e) { e.printStackTrace(); } }