当前位置: 首页>>代码示例>>Java>>正文


Java FontFactory.getFont方法代码示例

本文整理汇总了Java中com.itextpdf.text.FontFactory.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java FontFactory.getFont方法的具体用法?Java FontFactory.getFont怎么用?Java FontFactory.getFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.itextpdf.text.FontFactory的用法示例。


在下文中一共展示了FontFactory.getFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cellRodape

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:19,代码来源:ExporOnlyViagemPdf.java

示例2: funcaoTitulo

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private Phrase funcaoTitulo(int i) {
    String txt;
    Font fontcabecatable =  FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,10f );
    switch (i)
    {
        case 0:txt="Nr. Factura";break;
        case 1:txt="Nome do Segurado"; break;
        case 2:txt="Prémio";break;
        case 3:txt="Imposto 6%";break;
        case 4:txt="Imposto 5%";break;
        case 5:txt="FGA 2.6%";break;
        default:txt="TOTAL";break;
    }
    
    a=com.itextpdf.text.Element.ALIGN_CENTER;
    Phrase rt = new Phrase(txt,fontcabecatable);
    return rt; 
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:19,代码来源:ExportMapaProducao__.java

示例3: writeTotal

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
/**
 * Writes a total line.
 * @param value Total message.
 * @param total Total number.
 */
private void writeTotal(String value, double total)
{
    if (assertRequiredState())
    {
        this.font = FontFactory.getFont(
            this.font.getFamilyname(),
            this.font.getSize(),
            Font.BOLD,
            this.font.getColor());
        table.addCell(this.getCell(""));
        table.addCell(this.getCell(""));
        table.addCell(this.getCell("-------------"));
        table.addCell(this.getCell(""));
        // new row
        table.addCell(this.getCell(""));
        table.addCell(this.getCell(value + " Total:"));
        table.addCell(this.getCell(total + ""));
        table.addCell(this.getCell(""));
    }
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:26,代码来源:ItextTotalWrapper.java

示例4: main

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, DocumentException {
	Document document = new Document();
	PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST));
	document.open();
	Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
	document.add(new Paragraph("hello world,我是rainbowhorse。", font));
	document.close();
	writer.close();
}
 
开发者ID:Sunny0715,项目名称:java_pdf_demo,代码行数:10,代码来源:JavaToPdfCN.java

示例5: onEndPage

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
public void onEndPage(PdfWriter writer, Document document)
{
	Font font = FontFactory.getFont(Fonts.OPEN_SANS, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8, Font.NORMAL, BaseColor.BLACK);

	ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(Localization.getString(Strings.REPORT_FOOTER_LEFT), font), 100, 25, 0);
	ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(Localization.getString(Strings.REPORT_FOOTER_CENTER, document.getPageNumber()), font), 300, 25, 0);
	ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(DateTime.now().toString("dd.MM.YYYY"), font), 500, 25, 0);
}
 
开发者ID:deadlocker8,项目名称:BudgetMaster,代码行数:9,代码来源:HeaderFooterPageEvent.java

示例6: generateHeader

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private Chapter generateHeader()
{	
	Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 16, Font.BOLDITALIC, BaseColor.BLACK);
	Chunk chunk = new Chunk(Localization.getString(Strings.REPORT_HEADLINE, date.toString("MMMM yyyy")), font);
	Chapter chapter = new Chapter(new Paragraph(chunk), 1);
	chapter.setNumberDepth(0);
	chapter.add(Chunk.NEWLINE);
	return chapter;
}
 
开发者ID:deadlocker8,项目名称:BudgetMaster,代码行数:10,代码来源:ReportGenerator.java

示例7: generateCategoryBudgets

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private PdfPTable generateCategoryBudgets()
{
	PdfPTable table = new PdfPTable(2);
	table.setWidthPercentage(100);
	Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8, Font.NORMAL, BaseColor.BLACK);
	
	//header cells
	PdfPCell cellHeaderCategory = new PdfPCell(new Phrase(Localization.getString(Strings.TITLE_CATEGORY), font));
	cellHeaderCategory.setBackgroundColor(GrayColor.LIGHT_GRAY);
	cellHeaderCategory.setHorizontalAlignment(Element.ALIGN_CENTER);
	table.addCell(cellHeaderCategory);
	PdfPCell cellHeaderAmount = new PdfPCell(new Phrase(Localization.getString(Strings.TITLE_AMOUNT), font));
	cellHeaderAmount.setBackgroundColor(GrayColor.LIGHT_GRAY);
	cellHeaderAmount.setHorizontalAlignment(Element.ALIGN_CENTER);
	table.addCell(cellHeaderAmount);		

	for(CategoryBudget budget : categoryBudgets)
	{				
		PdfPCell cellName = new PdfPCell(new Phrase(budget.getCategory().getName(), font));
		cellName.setBackgroundColor(new BaseColor(Color.WHITE));
		cellName.setHorizontalAlignment(Element.ALIGN_CENTER);
		cellName.setVerticalAlignment(Element.ALIGN_MIDDLE);
		table.addCell(cellName);
		
		PdfPCell cellAmount = new PdfPCell(new Phrase(Helpers.getCurrencyString(budget.getBudget() / 100.0, currency), font));
		cellAmount.setBackgroundColor(new BaseColor(Color.WHITE));
		cellAmount.setHorizontalAlignment(Element.ALIGN_CENTER);
		cellAmount.setVerticalAlignment(Element.ALIGN_MIDDLE);
		table.addCell(cellAmount);
	}
	
	return table;
}
 
开发者ID:deadlocker8,项目名称:BudgetMaster,代码行数:34,代码来源:ReportGenerator.java

示例8: getFont

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private Font getFont(String color, boolean bold) throws Exception {
	Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
	int rgb[] = SimpleUtils.getColorRGB2(color);
	BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]);
	font.setSize(9);
	font.setColor(baseColor);
	return font;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:9,代码来源:PersonalReportPdfCommand.java

示例9: getFont

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private Font getFont(String color, boolean bold) throws Exception {
	Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
	int rgb[] = SimpleUtils.getColorRGB2(color);
	BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]);
	font.setSize(9);
	if (bold) {
		font.setSize(14);
		font.setStyle(Font.BOLD);
	}		
	font.setColor(baseColor);
	return font;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:13,代码来源:KpiReportPdfCommand.java

示例10: addImageToPdf

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
/**
 * The <code>addImageToPdf</code> method is used to add image to pdf and make it searchable by adding image text in invisible mode
 * w.r.t parameter 'isPdfSearchable' passed.
 * 
 * @param pdfWriter {@link PdfWriter} writer of pdf in which image has to be added
 * @param htmlUrl {@link HocrPage} corresponding html file for fetching text and coordinates
 * @param imageUrl {@link String} url of image to be added in pdf
 * @param isPdfSearchable true for searchable pdf else otherwise
 * @param widthOfLine
 */
private void addImageToPdf(PdfWriter pdfWriter, HocrPage hocrPage, String imageUrl, boolean isPdfSearchable, final int widthOfLine) {
	if (null != pdfWriter && null != imageUrl && imageUrl.length() > 0) {
		try {
			LOGGER.info("Adding image" + imageUrl + " to pdf using iText");
			Image pageImage = Image.getInstance(imageUrl);
			float dotsPerPointX = pageImage.getDpiX() / PDF_RESOLUTION;
			float dotsPerPointY = pageImage.getDpiY() / PDF_RESOLUTION;
			PdfContentByte pdfContentByte = pdfWriter.getDirectContent();

			pageImage.scaleToFit(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY);

			pageImage.setAbsolutePosition(0, 0);

			// Add image to pdf
			pdfWriter.getDirectContentUnder().addImage(pageImage);
			pdfWriter.getDirectContentUnder().add(pdfContentByte);

			// If pdf is to be made searchable
			if (isPdfSearchable) {
				LOGGER.info("Adding invisible text for image: " + imageUrl);
				float pageImagePixelHeight = pageImage.getHeight();
				Font defaultFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, CMYKColor.BLACK);

				// Fetch text and coordinates for image to be added
				Map<String, int[]> textCoordinatesMap = getTextWithCoordinatesMap(hocrPage, widthOfLine);
				Set<String> ketSet = textCoordinatesMap.keySet();

				// Add text at specific location
				for (String key : ketSet) {
					int[] coordinates = textCoordinatesMap.get(key);
					float bboxWidthPt = (coordinates[2] - coordinates[0]) / dotsPerPointX;
					float bboxHeightPt = (coordinates[3] - coordinates[1]) / dotsPerPointY;
					pdfContentByte.beginText();

					// To make text added as invisible
					pdfContentByte.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE);
					pdfContentByte.setLineWidth(Math.round(bboxWidthPt));

					// Ceil is used so that minimum font of any text is 1
					// For exception of unbalanced beginText() and endText()
					if (bboxHeightPt > 0.0) {
						pdfContentByte.setFontAndSize(defaultFont.getBaseFont(), (float) Math.ceil(bboxHeightPt));
					} else {
						pdfContentByte.setFontAndSize(defaultFont.getBaseFont(), 1);
					}
					float xCoordinate = (float) (coordinates[0] / dotsPerPointX);
					float yCoordinate = (float) ((pageImagePixelHeight - coordinates[3]) / dotsPerPointY);
					pdfContentByte.moveText(xCoordinate, yCoordinate);
					pdfContentByte.showText(key);
					pdfContentByte.endText();
				}
			}
			pdfContentByte.closePath();
		} catch (BadElementException badElementException) {
			LOGGER
					.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: "
							+ badElementException.toString());
		} catch (DocumentException documentException) {
			LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: " + documentException.toString());
		} catch (MalformedURLException malformedURLException) {
			LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: "
					+ malformedURLException.toString());
		} catch (IOException ioException) {
			LOGGER.error("Error occurred while adding image" + imageUrl + " to pdf using Itext: " + ioException.toString());
		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:78,代码来源:MultiPageExecutor.java

示例11: getFont

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
/**
 * Get a font with the provided font family and font attributes applied
 * @param pFontFamily The font family
 * @param pFontAttributes The font attributes to be applied
 * @return A font of the provided font family with font attributes applied
 * @throws ExInternal If the font family provided is not registered
 */
private Font getFont(String pFontFamily, FontAttributes pFontAttributes) throws ExInternal {
  Font lFont = FontFactory.getFont(pFontFamily, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, pFontAttributes.getSize(),
                                   pFontAttributes.getStyle(), pFontAttributes.getColor());

  if (lFont.getBaseFont() == null) {
    throw new ExInternal("Could not create a font using font family '" + pFontFamily + "' as it could not be found in the registered fonts");
  }

  return lFont;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:18,代码来源:FontManager.java

示例12: printExplanation

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private void printExplanation(String txt) throws DocumentException {
   Font f = FontFactory.getFont(FontFactory.COURIER, 10, BaseColor.MAGENTA);
   Paragraph paragraph = new Paragraph(txt, f);
   float padding = ItextHelper.mmToPts(2);
   for (Chunk c : paragraph.getChunks()) {
      c.setBackground(new BaseColor(230, 230, 230), padding, padding, padding, padding);
   }
   getDocument().add(paragraph);
   newLine();
}
 
开发者ID:eduarddrenth,项目名称:iText-GUI,代码行数:11,代码来源:StylesheetTester.java

示例13: createTable

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
/**
 * Creates the table.
 *
 * @param consent the consent
 * @return the pdf p table
 */
private PdfPTable createTable(Consent consent) {
	Font fontbold = FontFactory.getFont("Helvetica", 15, Font.BOLD);
	
	PdfPTable table = new PdfPTable(new float[]{0.2f,0.8f});
	table.setWidthPercentage(100f);
	table.getDefaultCell().setBorder(0);
	
	
	Chunk chunk2=new Chunk("NO EXCEPT",fontbold);
	Chunk chunk3=new Chunk("NO NEVER",fontbold);
	if(consent.getConsentRevokationType().equals("EMERGENCY ONLY")){
		chunk2.append("\n(This is the option you chose.)");
	}
	else if(consent.getConsentRevokationType().equals("NO NEVER")){
		chunk3.append("\n(This is the option you chose.)");
	}
	
	table.addCell(new PdfPCell(new Phrase(chunk2)));
       table.addCell(new PdfPCell(new Phrase("I Deny Consent for all Participants to access " +
       		"my electronic health information through Consent 2 Share for any purpose, EXCEPT " +
       		"in a medical emergency. By checking this box you agree, \"No, none of the Participants" +
       		" may be given access to my medical records through Consent 2 Share unless it is a medical emergency.\"")));
       table.addCell(new PdfPCell(new Phrase(chunk3)));
       table.addCell(new PdfPCell(new Phrase("I Deny Consent for all Participants to access my electronic health information" +
       		" through Consent 2 Share for any purpose, INCLUDING in a medical emergency.")));
       
       return table;
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:35,代码来源:ConsentRevokationPdfGenerator.java

示例14: addInvisibleChapterForHeader

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
public void addInvisibleChapterForHeader(Document document, Section section) {
	try {
		Paragraph paragraph=new Paragraph(section.getSectionName(), FontFactory.getFont(FontFactory.COURIER,1f,BaseColor.WHITE));//hide chapter
		Chapter chapter = new Chapter(paragraph,0);
		document.add(chapter);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:ntenhoeve,项目名称:Introspect-Framework,代码行数:10,代码来源:PdfReportFactory.java

示例15: inlineCodeFont

import com.itextpdf.text.FontFactory; //导入方法依赖的package包/类
private Supplier<? extends Font> inlineCodeFont(final Styles styles) {
    return new Supplier<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());
            }
        }
    };
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:14,代码来源:CodeNodeProcessor.java


注:本文中的com.itextpdf.text.FontFactory.getFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。