Font font=null; if(baseFont!=null){ font=new Font(baseFont); }else{ font=FontFactory.getFont(fontName);
/** * Constructs a chunk of text with a certain content, without specifying a * <CODE>Font</CODE>. * * @param content * the content */ public Chunk(final String content) { this(content, new Font()); }
/** * Constructs a chunk of text with a char, without specifying a <CODE>Font * </CODE>. * * @param c * the content */ public Chunk(final char c) { this(c, new Font()); }
/** * Constructs a <CODE>Phrase</CODE> with a certain leading. * * @param leading the leading */ public Phrase(final float leading) { this.leading = leading; font = new Font(); }
/** * Constructs a <CODE>Phrase</CODE> with a certain <CODE>String</CODE>. * * @param string a <CODE>String</CODE> */ public Phrase(final String string) { this(Float.NaN, string, new Font()); }
/** * Constructs a <CODE>Phrase</CODE> with a certain leading and a certain <CODE>String</CODE>. * * @param leading the leading * @param string a <CODE>String</CODE> */ public Phrase(final float leading, final String string) { this(leading, string, new Font()); }
public ExtendedChunk( ExtendedDocument ownerDocument, String textContent ) { this( ownerDocument, textContent, new Font() ); }
/** * Constructs a chunk of text with a char, without specifying a <CODE>Font * </CODE>. * * @param c * the content */ public Chunk(final char c) { this(c, new Font()); }
/** * Constructs a <CODE>Phrase</CODE> with a certain leading. * * @param leading the leading */ public Phrase(final float leading) { this.leading = leading; font = new Font(); }
/** * Empty constructor. */ public Chunk() { this.content = new StringBuffer(); this.font = new Font(); this.role = PdfName.SPAN; }
/** * Empty constructor. */ public Chunk() { this.content = new StringBuffer(); this.font = new Font(); this.role = PdfName.SPAN; }
/** * Gets a special kind of Phrase that changes some characters into corresponding symbols. * @param leading * @param string * @return a newly constructed Phrase */ public static final Phrase getInstance(final int leading, final String string) { return getInstance(leading, string, new Font()); }
public Chunk symbol(String name, float size, BaseColor fg) { String s = fontAwesome.get(name); if(s==null) throw new IllegalArgumentException("Unrecognized symbol '" + name + "'"); return new Chunk(s, new Font(baseFont, size, Font.NORMAL, fg)); }
/** * Gets a special kind of Phrase that changes some characters into corresponding symbols. * @param string * @return a newly constructed Phrase */ public static final Phrase getInstance(final String string) { return getInstance(16, string, new Font()); }
/** * Gets a special kind of Phrase that changes some characters into corresponding symbols. * @param string * @return a newly constructed Phrase */ public static final Phrase getInstance(final String string) { return getInstance(16, string, new Font()); }
@Override public Font get() { try { return new Font(ITextUtils.inconsolata(), styles.defaultFontSize()); } catch (Exception e) { log.warn("Fail to retrieve font", e); return FontFactory.getFont(FontFactory.COURIER, styles.defaultFontSize()); } } };
private static PdfPCell createLabelCell(String text){ // font Font font = new Font(FontFamily.HELVETICA, 8, Font.BOLD, BaseColor.DARK_GRAY); // create cell PdfPCell cell = new PdfPCell(new Phrase(text,font)); // set style Style.labelCellStyle(cell); return cell; }
private static PdfPCell createValueCell(String text){ // font Font font = new Font(FontFamily.HELVETICA, 8, Font.NORMAL, BaseColor.BLACK); // create cell PdfPCell cell = new PdfPCell(new Phrase(text,font)); // set style Style.valueCellStyle(cell); return cell; } }
@Override public void onStartPage(PdfWriter writer, Document document) { try { this.template = writer.getDirectContent().createTemplate(100, 100); this.baseFont = new Font(Resource.BASE_FONT_CHINESE, 8, Font.NORMAL).getBaseFont(); } catch (Exception e) { throw new ExceptionConverter(e); } }
private static void createPDF(String path) throws Exception { Document pdfDoc = new Document(PageSize.A4); PdfWriter.getInstance(pdfDoc, new FileOutputStream(path)).setPdfVersion(PdfWriter.VERSION_1_7); pdfDoc.open(); Font myfont = new Font(); myfont.setStyle(Font.NORMAL); myfont.setSize(11); Paragraph para = new Paragraph("test", myfont); para.setAlignment(Element.ALIGN_JUSTIFIED); pdfDoc.add(para); pdfDoc.close(); }