當前位置: 首頁>>代碼示例>>Java>>正文


Java FontFactory類代碼示例

本文整理匯總了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;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:24,代碼來源:RtfDestinationFontTable.java

示例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;
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:29,代碼來源:ElementFactory.java

示例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;
}
 
開發者ID:dhorlick,項目名稱:balloonist,代碼行數:18,代碼來源:PdfFriend.java

示例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");
    }
}
 
開發者ID:sakaicontrib,項目名稱:evaluation,代碼行數:26,代碼來源:EvalPDFReportBuilder.java

示例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);
        }
    }
}
 
開發者ID:mtpettyp,項目名稱:openreports,代碼行數:20,代碼來源:FontProvider.java

示例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);
	}
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:17,代碼來源:SpreadsheetDataFileWriterPdf.java

示例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);
}
 
開發者ID:8090boy,項目名稱:gomall.la,代碼行數:20,代碼來源:SimpleChinesePdfView.java

示例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());
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter,代碼行數:22,代碼來源:FontManager.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:25,代碼來源:LockboxServiceImpl.java

示例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);
        }
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:18,代碼來源:LockboxServiceImpl.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:19,代碼來源:CustomerInvoiceWriteoffBatchServiceImpl.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:19,代碼來源:CustomerInvoiceWriteoffBatchServiceImpl.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:21,代碼來源:CustomerLoadServiceImpl.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:19,代碼來源:CustomerLoadServiceImpl.java

示例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);
    }
}
 
開發者ID:kuali,項目名稱:kfs,代碼行數:19,代碼來源:CustomerLoadServiceImpl.java


注:本文中的com.lowagie.text.FontFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。