List of usage examples for com.lowagie.text.pdf BaseFont ZAPFDINGBATS
String ZAPFDINGBATS
To view the source code for com.lowagie.text.pdf BaseFont ZAPFDINGBATS.
Click Source Link
From source file:org.oscarehr.phr.web.PHRUserManagementAction.java
License:Open Source License
public ByteArrayOutputStream generateUserRegistrationLetter(String demographicNo, String username, String password) throws Exception { log.debug("Demographic " + demographicNo + " username " + username + " password " + password); DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao"); Demographic demographic = demographicDao.getDemographic(demographicNo); final String PAGESIZE = "printPageSize"; Document document = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter writer = null;/* w ww .ja va2 s .c o m*/ try { writer = PdfWriter.getInstance(document, baosPDF); String title = "TITLE"; String template = "MyOscarLetterHead.pdf"; Properties printCfg = getCfgProp(); String[] cfgVal = null; StringBuilder tempName = null; // get the print prop values Properties props = new Properties(); props.setProperty("letterDate", UtilDateUtilities.getToday("yyyy-MM-dd")); props.setProperty("name", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("dearname", demographic.getFirstName() + " " + demographic.getLastName()); props.setProperty("address", demographic.getAddress()); props.setProperty("city", demographic.getCity() + ", " + demographic.getProvince()); props.setProperty("postalCode", demographic.getPostal()); props.setProperty("credHeading", "MyOscar User Account Details"); props.setProperty("username", "Username: " + username); props.setProperty("password", "Password: " + password); //Temporary - the intro will change to be dynamic props.setProperty("intro", "We are pleased to provide you with a log in and password for your new MyOSCAR Personal Health Record. This account will allow you to connect electronically with our clinic. Please take a few minutes to review the accompanying literature for further information.We look forward to you benefiting from this service."); document.addTitle(title); document.addSubject(""); document.addKeywords("pdf, itext"); document.addCreator("OSCAR"); document.addAuthor(""); document.addHeader("Expires", "0"); Rectangle pageSize = PageSize.LETTER; document.setPageSize(pageSize); document.open(); // create a reader for a certain document String propFilename = oscar.OscarProperties.getInstance().getProperty("pdfFORMDIR", "") + "/" + template; PdfReader reader = null; try { reader = new PdfReader(propFilename); log.debug("Found template at " + propFilename); } catch (Exception dex) { log.debug("change path to inside oscar from :" + propFilename); reader = new PdfReader("/oscar/form/prop/" + template); log.debug("Found template at /oscar/form/prop/" + template); } // retrieve the total number of pages int n = reader.getNumberOfPages(); // retrieve the size of the first page Rectangle pSize = reader.getPageSize(1); float width = pSize.getWidth(); float height = pSize.getHeight(); log.debug("Width :" + width + " Height: " + height); PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); int fontFlags = 0; document.newPage(); PdfImportedPage page1 = writer.getImportedPage(reader, 1); cb.addTemplate(page1, 1, 0, 0, 1, 0, 0); BaseFont bf; // = normFont; String encoding; cb.setRGBColorStroke(0, 0, 255); String[] fontType; for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) { tempName = new StringBuilder(e.nextElement().toString()); cfgVal = printCfg.getProperty(tempName.toString()).split(" *, *"); if (cfgVal[4].indexOf(";") > -1) { fontType = cfgVal[4].split(";"); if (fontType[1].trim().equals("italic")) fontFlags = Font.ITALIC; else if (fontType[1].trim().equals("bold")) fontFlags = Font.BOLD; else if (fontType[1].trim().equals("bolditalic")) fontFlags = Font.BOLDITALIC; else fontFlags = Font.NORMAL; } else { fontFlags = Font.NORMAL; fontType = new String[] { cfgVal[4].trim() }; } if (fontType[0].trim().equals("BaseFont.HELVETICA")) { fontType[0] = BaseFont.HELVETICA; encoding = BaseFont.CP1252; //latin1 encoding } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) { fontType[0] = BaseFont.HELVETICA_OBLIQUE; encoding = BaseFont.CP1252; } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) { fontType[0] = BaseFont.ZAPFDINGBATS; encoding = BaseFont.ZAPFDINGBATS; } else { fontType[0] = BaseFont.COURIER; encoding = BaseFont.CP1252; } bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED); // write in a rectangle area if (cfgVal.length >= 9) { Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags); ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()), (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()), (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT : Element.ALIGN_CENTER))); ct.setText(new Phrase(12, props.getProperty(tempName.toString(), ""), font)); ct.go(); continue; } // draw line directly if (tempName.toString().startsWith("__$line")) { cb.setRGBColorStrokeF(0f, 0f, 0f); cb.setLineWidth(Float.parseFloat(cfgVal[4].trim())); cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim())); cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim())); // stroke the lines cb.stroke(); // write text directly } else if (tempName.toString().startsWith("__")) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? (cfgVal[6].trim()) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } else if (tempName.toString().equals("forms_promotext")) { if (OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } else { // write prop text cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? ((props.getProperty(tempName.toString(), "").equals("") ? "" : cfgVal[6].trim())) : props.getProperty(tempName.toString(), "")), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } } catch (DocumentException dex) { baosPDF.reset(); throw dex; } finally { if (document != null) document.close(); if (writer != null) writer.close(); } return baosPDF; }
From source file:org.pentaho.reporting.libraries.fonts.itext.ITextBuiltInFontRegistry.java
License:Open Source License
private FontFamily createZapfDingbatsFamily() { final DefaultFontFamily fontFamily = new DefaultFontFamily("ZapfDingbats"); fontFamily/*from www . j a v a 2s .co m*/ .addFontRecord(new ITextBuiltInFontRecord(fontFamily, BaseFont.ZAPFDINGBATS, 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 w w.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 *//* w ww . j av a 2 s . c o m*/ 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 .java 2 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 addZapfDingbats(Map result) throws DocumentException, IOException { FontFamily fontFamily = new FontFamily(); fontFamily.setName("ZapfDingbats"); fontFamily.addFontDescription(new FontDescription(createFont(BaseFont.ZAPFDINGBATS, BaseFont.CP1252, false), IdentValue.NORMAL, 400));/*from w w w . jav a2s . c o m*/ result.put("ZapfDingbats", fontFamily); }
From source file:oscar.eform.util.EFormPDFServlet.java
License:Open Source License
private void writeContent(Properties printCfg, Properties props, Properties measurements, float height, PdfContentByte cb) throws Exception { for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) { StringBuilder temp = new StringBuilder(e.nextElement().toString()); String[] cfgVal = printCfg.getProperty(temp.toString()).split(" *, *"); String[] fontType = null; int fontFlags = 0; if (cfgVal[4].indexOf(";") > -1) { fontType = cfgVal[4].split(";"); if (fontType[1].trim().equals("italic")) fontFlags = Font.ITALIC; else if (fontType[1].trim().equals("bold")) fontFlags = Font.BOLD; else if (fontType[1].trim().equals("bolditalic")) fontFlags = Font.BOLDITALIC; else/*from w w w . ja va 2s . com*/ fontFlags = Font.NORMAL; } else { fontFlags = Font.NORMAL; fontType = new String[] { cfgVal[4].trim() }; } String encoding = null; if (fontType[0].trim().equals("BaseFont.HELVETICA")) { fontType[0] = BaseFont.HELVETICA; encoding = BaseFont.CP1252; //latin1 encoding } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) { fontType[0] = BaseFont.HELVETICA_OBLIQUE; encoding = BaseFont.CP1252; } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) { fontType[0] = BaseFont.ZAPFDINGBATS; encoding = BaseFont.ZAPFDINGBATS; } else { fontType[0] = BaseFont.COURIER; encoding = BaseFont.CP1252; } BaseFont bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED); String propValue = props.getProperty(temp.toString()); //if not in regular config then check measurements if (propValue == null) { propValue = measurements.getProperty(temp.toString(), ""); } ColumnText ct = new ColumnText(cb); // write in a rectangle area if (cfgVal.length >= 9) { Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags); ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()), (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()), (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT : Element.ALIGN_CENTER))); ct.setText(new Phrase(12, propValue, font)); ct.go(); continue; } // draw line directly if (temp.toString().startsWith("__$line")) { cb.setRGBColorStrokeF(0f, 0f, 0f); cb.setLineWidth(Float.parseFloat(cfgVal[4].trim())); cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim())); cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim())); cb.stroke(); } else if (temp.toString().startsWith("__")) { cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? (cfgVal[6].trim()) : propValue), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } else { // write prop text cb.beginText(); cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim())); cb.showTextAligned( (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT : PdfContentByte.ALIGN_CENTER)), (cfgVal.length >= 7 ? ((propValue.equals("") ? "" : cfgVal[6].trim())) : propValue), Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0); cb.endText(); } } }
From source file:papertoolkit.pattern.output.PDFPatternGenerator.java
License:BSD License
/** * @return//w ww . j a v a 2s.c o m */ private static BaseFont createBaseFontZapfDingbats() { try { return BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:questions.separators.PositionedMarks.java
public PositionedMarks(boolean start) throws DocumentException, IOException { this.start = start; bf = BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); }