本文整理汇总了Java中com.lowagie.text.FontFactory类的典型用法代码示例。如果您正苦于以下问题:Java FontFactory类的具体用法?Java FontFactory怎么用?Java FontFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontFactory类属于com.lowagie.text包,在下文中一共展示了FontFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createfont
import com.lowagie.text.FontFactory; //导入依赖的package包/类
/**
* Create a font via the <code>FontFactory</code>
*
* @param fontName The font name to create
* @return The created <code>Font</code> object
*
* @since 2.0.8
*/
private Font createfont(String fontName) {
Font f1 = null;
int pos=-1;
do {
f1 = FontFactory.getFont(fontName);
if(f1.getBaseFont() != null) break; // found a font, exit the do/while
pos = fontName.lastIndexOf(' '); // find the last space
if(pos>0) {
fontName = fontName.substring(0, pos ); // truncate it to the last space
}
} while(pos>0);
return f1;
}
示例2: getPhrase
import com.lowagie.text.FontFactory; //导入依赖的package包/类
/**
* Creates a Phrase object based on a list of properties.
* @param attributes
* @return a Phrase
*/
public static Phrase getPhrase(Properties attributes) {
Phrase phrase = new Phrase();
phrase.setFont(FontFactory.getFont(attributes));
String value;
value = attributes.getProperty(ElementTags.LEADING);
if (value != null) {
phrase.setLeading(Float.parseFloat(value + "f"));
}
value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT);
if (value != null) {
phrase.setLeading(Markup.parseLength(value,
Markup.DEFAULT_FONT_SIZE));
}
value = attributes.getProperty(ElementTags.ITEXT);
if (value != null) {
Chunk chunk = new Chunk(value);
if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
chunk.setGenericTag(value);
}
phrase.add(chunk);
}
return phrase;
}
示例3: insertDirectory
import com.lowagie.text.FontFactory; //导入依赖的package包/类
private static int insertDirectory(String requestedDirectory,
DefaultFontMapper defaultFontMapper)
{
int ffCount = FontFactory.registerDirectory(requestedDirectory);
int fmCount = 0;
if (defaultFontMapper!=null)
{
fmCount = defaultFontMapper.insertDirectory(requestedDirectory);
}
if (ffCount>fmCount)
return ffCount;
else
return fmCount;
}
示例4: EvalPDFReportBuilder
import com.lowagie.text.FontFactory; //导入依赖的package包/类
public EvalPDFReportBuilder(OutputStream outputStream) {
document = new Document();
try {
pdfWriter = PdfWriter.getInstance(document, outputStream);
pdfWriter.setStrictImageSequence(true);
document.open();
// attempting to handle i18n chars better
// BaseFont evalBF = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.IDENTITY_H,
// BaseFont.EMBEDDED);
// paragraphFont = new Font(evalBF, 9, Font.NORMAL);
// paragraphFont = new Font(Font.TIMES_ROMAN, 9, Font.NORMAL);
titleTextFont = new Font(Font.TIMES_ROMAN, 22, Font.BOLD);
boldTextFont = new Font(Font.TIMES_ROMAN, 10, Font.BOLD);
questionTextFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLD);
paragraphFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL);
paragraphFontBold = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD);
frontTitleFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, frontTitleSize, Font.NORMAL);
frontAuthorFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.NORMAL);
frontInfoFont = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.NORMAL);
} catch (Exception e) {
throw UniversalRuntimeException.accumulate(e, "Unable to start PDF Report");
}
}
示例5: FontProvider
import com.lowagie.text.FontFactory; //导入依赖的package包/类
public FontProvider(String fontDirectories)
{
if (!StringUtils.isBlank(fontDirectories))
{
try
{
for (String directory : fontDirectories.split(";"))
{
FontFactory.registerDirectory(directory);
}
log.info("Font directories registered");
}
catch (Exception e)
{
log.error("Error loading font directories", e);
}
}
}
示例6: initFont
import com.lowagie.text.FontFactory; //导入依赖的package包/类
private static void initFont() {
String fontName = ServerConfigurationService.getString("pdf.default.font");
if (StringUtils.isNotBlank(fontName)) {
FontFactory.registerDirectories();
if (FontFactory.isRegistered(fontName)) {
font = FontFactory.getFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
boldFont = FontFactory.getFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10, Font.BOLD);
} else {
log.warn("Can not find font: " + fontName);
}
}
if (font == null) {
font = new Font();
boldFont = new Font(Font.COURIER, 10, Font.BOLD);
}
}
示例7: initTable
import com.lowagie.text.FontFactory; //导入依赖的package包/类
/**
* Initialize the main info holder table.
*
* @throws BadElementException
* for errors during table initialization
*/
protected void initTable() throws BadElementException {
tablePDF = new Table(this.model.getNumberOfColumns());
tablePDF.setDefaultVerticalAlignment(Element.ALIGN_TOP);
tablePDF.setCellsFitPage(true);
tablePDF.setWidth(100);
tablePDF.setPadding(2);
tablePDF.setSpacing(0);
// smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7,
// Font.NORMAL, new Color(0, 0, 0));
smallFont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", Font.DEFAULTSIZE);
}
示例8: getFontInternal
import com.lowagie.text.FontFactory; //导入依赖的package包/类
@Override
IFontPeer getFontInternal(String fontname) {
boolean embedded = false;
String encoding = "CP1252";
if (loadedFonts.containsKey(fontname)) {
Alias alias = loadedFonts.get(fontname);
fontname = alias.getName();
encoding = alias.getEncoding();
embedded = alias.isEmbed();
}
Font font;
try {
font = FontFactory.getFont(fontname,encoding,embedded,Font.UNDEFINED, Font.UNDEFINED, null);
} catch (Exception e) {
throw new RuntimeException("Unable to load Font: " + fontname + " with encoding: " + encoding,e);
}
if (font==null) {
throw new RuntimeException("Font: " + fontname + " not found.");
}
return new FontPeer(font.getBaseFont());
}
示例9: writeBatchGroupSectionTitle
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeBatchGroupSectionTitle(com.lowagie.text.Document pdfDoc, String batchSeqNbr, java.sql.Date procInvDt, String cashControlDocNumber) {
Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);
String lineText = "CASHCTL " + rightPad(cashControlDocNumber, 12) + " " +
"BATCH GROUP: " + rightPad(batchSeqNbr, 5) + " " +
rightPad((procInvDt == null ? "NONE" : procInvDt.toString()), 35);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
Chunk chunk = new Chunk(lineText, font);
chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
paragraph.add(chunk);
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
示例10: writeDetailLine
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeDetailLine(com.lowagie.text.Document pdfDoc, String detailLineText) {
if (ObjectUtils.isNotNull(detailLineText)) {
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
paragraph.add(new Chunk(detailLineText, font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
}
示例11: writeInvoiceSectionTitle
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) {
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
paragraph.add(new Chunk(customerNameLine, font));
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
示例12: writeInvoiceSectionMessage
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeInvoiceSectionMessage(com.lowagie.text.Document pdfDoc, String resultLine) {
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
paragraph.add(new Chunk(resultLine, font));
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
示例13: writeFileNameSectionTitle
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeFileNameSectionTitle(Document pdfDoc, String filenameLine) {
Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(Element.ALIGN_LEFT);
Chunk chunk = new Chunk(filenameLine, font);
chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
paragraph.add(chunk);
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
示例14: writeCustomerSectionTitle
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeCustomerSectionTitle(Document pdfDoc, String customerNameLine) {
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(Element.ALIGN_LEFT);
paragraph.add(new Chunk(customerNameLine, font));
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}
示例15: writeCustomerSectionResult
import com.lowagie.text.FontFactory; //导入依赖的package包/类
protected void writeCustomerSectionResult(Document pdfDoc, String resultLine) {
Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD);
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(Element.ALIGN_LEFT);
paragraph.add(new Chunk(resultLine, font));
// blank line
paragraph.add(new Chunk("", font));
try {
pdfDoc.add(paragraph);
}
catch (DocumentException e) {
LOG.error("iText DocumentException thrown when trying to write content.", e);
throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
}
}