本文整理了Java中com.itextpdf.text.pdf.BaseFont.createFont()
方法的一些代码示例,展示了BaseFont.createFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BaseFont.createFont()
方法的具体详情如下:
包路径:com.itextpdf.text.pdf.BaseFont
类名称:BaseFont
方法名:createFont
[英]Creates a new font. This will always be the default Helvetica font (not embedded). This method is introduced because Helvetica is used in many examples.
[中]创建新字体。这将始终是默认的Helvetica字体(未嵌入)。介绍这种方法是因为Helvetica在许多例子中使用。
代码示例来源:origin: youseries/ureport
private BaseFont getIdentityFont(String fontFamily,String fontPath,ApplicationContext applicationContext) throws DocumentException,IOException {
if(!fontPath.startsWith(ApplicationContext.CLASSPATH_URL_PREFIX)){
fontPath=ApplicationContext.CLASSPATH_URL_PREFIX+fontPath;
}
String fontName = fontPath;
int lastSlashPos=fontPath.lastIndexOf("/");
if(lastSlashPos!=-1){
fontName = fontPath.substring(lastSlashPos+1,fontPath.length());
}
if (fontName.toLowerCase().endsWith(".ttc")) {
fontName = fontName + ",0";
}
InputStream inputStream=null;
try{
fontPathMap.put(fontFamily, fontPath);
inputStream=applicationContext.getResource(fontPath).getInputStream();
byte[] bytes = IOUtils.toByteArray(inputStream);
BaseFont baseFont = BaseFont.createFont(fontName, BaseFont.IDENTITY_H,BaseFont.EMBEDDED,true,bytes,null);
baseFont.setSubset(true);
return baseFont;
}finally{
if(inputStream!=null)inputStream.close();
}
}
}
代码示例来源:origin: com.itextpdf/itextpdf
protected BaseFont getRealFont() throws IOException, DocumentException {
if (font == null)
return BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
else
return font;
}
代码示例来源:origin: com.itextpdf/itextpdf
/**
* Creates a new font. This will always be the default Helvetica font (not embedded).
* This method is introduced because Helvetica is used in many examples.
* @return a BaseFont object (Helvetica, Winansi, not embedded)
* @throws IOException This shouldn't occur ever
* @throws DocumentException This shouldn't occur ever
* @since 2.1.1
*/
public static BaseFont createFont() throws DocumentException, IOException {
return createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
代码示例来源:origin: com.itextpdf/itextg
protected BaseFont getRealFont() throws IOException, DocumentException {
if (font == null)
return BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
else
return font;
}
代码示例来源:origin: com.itextpdf/itextg
/**
* Creates a new font. This will always be the default Helvetica font (not embedded).
* This method is introduced because Helvetica is used in many examples.
* @return a BaseFont object (Helvetica, Winansi, not embedded)
* @throws IOException This shouldn't occur ever
* @throws DocumentException This shouldn't occur ever
* @since 2.1.1
*/
public static BaseFont createFont() throws DocumentException, IOException {
return createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
代码示例来源:origin: org.technbolts/gutenberg
public static BaseFont createEmbeddedFont(String fontName, String encoding) throws IOException, DocumentException {
return BaseFont.createFont(fontName, encoding, BaseFont.EMBEDDED);
}
代码示例来源:origin: org.xhtmlrenderer/flying-saucer-pdf-itext5
private static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException {
return BaseFont.createFont(name, encoding, embedded);
}
代码示例来源:origin: com.itextpdf/itextpdf
protected BaseFont getBaseFont(String fontname, final String encoding, final boolean embedded, final boolean cached) throws IOException, DocumentException {
BaseFont basefont = null;
try {
// the font is a type 1 font or CJK font
basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null, true);
} catch (DocumentException de) {
}
if (basefont == null) {
// the font is a true type font or an unknown font
fontname = trueTypeFonts.get(fontname.toLowerCase());
// the font is not registered as truetype font
if (fontname != null)
basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null);
}
return basefont;
}
代码示例来源:origin: org.technbolts/gutenberg
public FontAwesomeAdapter() throws IOException, DocumentException {
fontAwesome = FontAwesome.getInstance();
baseFont = BaseFont.createFont(FONT_AWESOME_RESOURCE, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
代码示例来源:origin: com.itextpdf/itextpdf
/** Creates new Barcode128 */
public Barcode128() {
try {
x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
codeType = CODE128;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextpdf
public BaseFont awtToPdf(Font font) {
try {
BaseFontParameters p = getBaseFontParameters(font.getFontName());
if (p != null){
return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb);
}else{
return BaseFont.createFont(defaultFont, encoding, true);
}
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: com.itextpdf/itextg
/** Creates new Barcode128 */
public Barcode128() {
try {
x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
codeType = CODE128;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextpdf
/** Creates new BarcodeInter25 */
public BarcodeInter25() {
try {
x = 0.8f;
n = 2;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
generateChecksum = false;
checksumText = false;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextpdf
/** Creates new BarcodeEAN */
public BarcodeEAN() {
try {
x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
guardBars = true;
codeType = EAN13;
code = "";
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextg
/** Creates new BarcodeEAN */
public BarcodeEAN() {
try {
x = 0.8f;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
guardBars = true;
codeType = EAN13;
code = "";
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextg
/** Creates new BarcodeInter25 */
public BarcodeInter25() {
try {
x = 0.8f;
n = 2;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
generateChecksum = false;
checksumText = false;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
代码示例来源:origin: com.itextpdf/itextpdf
static PdfFont getDefaultFont() {
try {
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
return new PdfFont(bf, 12);
}
catch (Exception ee) {
throw new ExceptionConverter(ee);
}
}
void setHorizontalScaling(float hScale) {
代码示例来源:origin: com.itextpdf/itextg
static PdfFont getDefaultFont() {
try {
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false);
return new PdfFont(bf, 12);
}
catch (Exception ee) {
throw new ExceptionConverter(ee);
}
}
void setHorizontalScaling(float hScale) {
代码示例来源:origin: org.jeecg/easypoi-base
@Override
public Font getFont(ExcelExportEntity entity, String text) {
try {
//用以支持中文
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",
BaseFont.NOT_EMBEDDED);
Font font = new Font(bfChinese);
return font;
} catch (DocumentException e) {
LOGGER.error(e.getMessage(), e);
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
Font font = new Font(FontFamily.UNDEFINED);
return font;
}
代码示例来源:origin: com.itextpdf/itextpdf
/** Gets all the names from the font. Only the required tables are read.
* @param name the name of the font
* @param encoding the encoding of the font
* @param ttfAfm the true type font or the afm in a byte array
* @throws DocumentException on error
* @throws IOException on error
* @return an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()}
*/
public static Object[] getAllFontNames(String name, String encoding, byte ttfAfm[]) throws DocumentException, IOException {
String nameBase = getBaseName(name);
BaseFont fontBuilt = null;
if (nameBase.toLowerCase().endsWith(".ttf") || nameBase.toLowerCase().endsWith(".otf") || nameBase.toLowerCase().indexOf(".ttc,") > 0)
fontBuilt = new TrueTypeFont(name, CP1252, false, ttfAfm, true, false);
else
fontBuilt = createFont(name, encoding, false, false, ttfAfm, null);
return new Object[]{fontBuilt.getPostscriptFontName(), fontBuilt.getFamilyFontName(), fontBuilt.getFullFontName()};
}
内容来源于网络,如有侵权,请联系作者删除!