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


Java Font類代碼示例

本文整理匯總了Java中com.itextpdf.text.Font的典型用法代碼示例。如果您正苦於以下問題:Java Font類的具體用法?Java Font怎麽用?Java Font使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Font類屬於com.itextpdf.text包,在下文中一共展示了Font類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cellRodape

import com.itextpdf.text.Font; //導入依賴的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: buildPdfPCell

import com.itextpdf.text.Font; //導入依賴的package包/類
private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
	PdfPCell cell=new PdfPCell();
	cell.setPadding(0);
	cell.setBorder(Rectangle.NO_BORDER);
	Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
	String fontColor=phf.getForecolor();
	if(StringUtils.isNotEmpty(fontColor)){
		String[] color=fontColor.split(",");
		font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));			
	}
	Paragraph graph=new Paragraph(text,font);
	cell.setPhrase(graph);
	switch(type){
	case 1:
		cell.setHorizontalAlignment(Element.ALIGN_LEFT);
		break;
	case 2:
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		break;
	case 3:
		cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
		break;
	}
	cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
	return cell;
}
 
開發者ID:youseries,項目名稱:ureport,代碼行數:27,代碼來源:PageHeaderFooterEvent.java

示例3: funcaoTitulo

import com.itextpdf.text.Font; //導入依賴的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

示例4: testShowTextAlignedVsSimpleColumnTopAlignment

import com.itextpdf.text.Font; //導入依賴的package包/類
/**
 * <a href="http://stackoverflow.com/questions/32162759/columntext-showtextaligned-vs-columntext-setsimplecolumn-top-alignment">
 * ColumnText.ShowTextAligned vs ColumnText.SetSimpleColumn Top Alignment
 * </a>
 * <p>
 * Indeed, the coordinates do not line up. The y coordinate of 
 * {@link ColumnText#showTextAligned(PdfContentByte, int, Phrase, float, float, float)}
 * denotes the baseline while {@link ColumnText#setSimpleColumn(Rectangle)} surrounds
 * the text to come.
 * </p>
 */
@Test
public void testShowTextAlignedVsSimpleColumnTopAlignment() throws DocumentException, IOException
{
    Document document = new Document(PageSize.A4);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "ColumnTextTopAligned.pdf")));
    document.open();

    Font fontQouteItems = new Font(BaseFont.createFont(), 12);
    PdfContentByte canvas = writer.getDirectContent();

    // Item Number
    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("36222-0", fontQouteItems), 60, 450, 0);

    // Estimated Qty
    ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("47", fontQouteItems), 143, 450, 0);

    // Item Description
    ColumnText ct = new ColumnText(canvas); // Uses a simple column box to provide proper text wrapping
    ct.setSimpleColumn(new Rectangle(193, 070, 390, 450));
    ct.setText(new Phrase("In-Situ : Poly Cable - 100'\nPoly vented rugged black gable 100ft\nThis is an additional description. It can wrap an extra line if it needs to so this text is long.", fontQouteItems));
    ct.go();

    document.close();
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:37,代碼來源:UseColumnText.java

示例5: calculateStyle

import com.itextpdf.text.Font; //導入依賴的package包/類
private int calculateStyle(Style style) {
    int s = Font.NORMAL;
    if (style.isBold()) {
        s |= Font.BOLD;
    }
    if (style.isItalic()) {
        s |= Font.ITALIC;
    }
    if (style.isStrikethrough()) {
        s |= Font.STRIKETHRU;
    }
    if (style.isUnderline()) {
        s |= Font.UNDERLINE;
    }
    return s;
}
 
開發者ID:Arnauld,項目名稱:gutenberg,代碼行數:17,代碼來源:PygmentsAdapter.java

示例6: addBalancedReportTitle

import com.itextpdf.text.Font; //導入依賴的package包/類
/**
 * Adds the report title for balanced report.
 *
 * @param document
 *         the report document.
 * @param reportName
 *         the report name.
 * @param fiscalYear
 *         the fiscal year.
 * @param quarter
 *         the quarter.
 * @param startDate
 *         the start date.
 * @param endDate
 *         the end date.
 * @throws com.itextpdf.text.DocumentException
 *         if any error occurs.
 */
static void addBalancedReportTitle(com.itextpdf.text.Document document, String reportName, Integer fiscalYear,
                                   Integer quarter, Date startDate, Date endDate)
        throws com.itextpdf.text.DocumentException {
    com.itextpdf.text.Paragraph title = new com.itextpdf.text.Paragraph(reportName,
            new Font(FontFamily.HELVETICA, 16, Font.BOLD));
    title.setAlignment(PDF_ALIGN_CENTER);
    document.add(title);
    if (fiscalYear != null && quarter != null) {
        com.itextpdf.text.Paragraph subTitle1 = new com.itextpdf.text.Paragraph("Fiscal Year " + fiscalYear +
                " - Quarter" + quarter, new Font(FontFamily.HELVETICA, 14, Font.BOLD));
        subTitle1.setAlignment(PDF_ALIGN_CENTER);
        document.add(subTitle1);
    }
    if (startDate != null && endDate != null) {
        com.itextpdf.text.Paragraph subTitle2 = new com.itextpdf.text.Paragraph("Processed between " +
                "" + REPORT_DATE_FORMAT.format(startDate) + " and " +
                "" + REPORT_DATE_FORMAT.format(endDate),
                new Font(FontFamily.HELVETICA, 12, Font.BOLD));
        subTitle2.setAlignment(PDF_ALIGN_CENTER);
        document.add(subTitle2);
    }
}
 
開發者ID:NASA-Tournament-Lab,項目名稱:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代碼行數:41,代碼來源:ReportServiceHelper.java

示例7: getFont

import com.itextpdf.text.Font; //導入依賴的package包/類
public Font getFont(int _style, final float size) {
	final int style;
	if(!allowUnderline) {
		style = _style & (~(Font.UNDERLINE));
	} else {
		style = _style;
	}
	String key = style + "," + size;
	return getFont(key, new FontBuilder() {
		@Override
		public Font createFont() {
	    	int baseStyle = style & Font.BOLDITALIC;
			BaseFont bf = baseFontMap.get(baseStyle);
	        return new Font(bf, size, style);
		}
	});    	
}
 
開發者ID:lexml,項目名稱:lexml-renderer-pdf,代碼行數:18,代碼來源:LexmlFontFactory.java

示例8: refresh

import com.itextpdf.text.Font; //導入依賴的package包/類
@Override
public void refresh() {
    ExploreConfig config = extractConfig();
    String commandLine = config.toCommandLine();
    if (commandLine.isEmpty()) {
        setForeground(Color.GRAY);
        setFont(getFont().deriveFont(Font.ITALIC));
        setText("No parameters");
        setEnabled(false);
    } else {
        setForeground(Color.BLACK);
        setFont(getFont().deriveFont(Font.NORMAL));
        setText(commandLine);
        setEnabled(true);
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:17,代碼來源:ExploreConfigDialog.java

示例9: funcaoTitulo

import com.itextpdf.text.Font; //導入依賴的package包/類
private Phrase funcaoTitulo(int i) {
        String txt;
        Font fontcabecatable = new Font(Font.FontFamily.COURIER, 8, Font.BOLD);
       switch (i) 
       {
           case 0:txt="S/N";break;
           case 1:txt="DATA";break;
           case 2:txt="APOLICE";break;
           case 3:txt="DATA INICIO";break;
           case 4:txt="DATA FIM";break;
           case 5:txt="NO. DIAS";break;
           case 6:txt="NOME";break;
           case 7:txt="RECEIPT NO.";break;
           case 8:txt="EA PREM";break;
           case 9:txt="NICON COMISSÃO";break;
           case 10:txt="5% IMPOSTO";break;
           case 11:txt="0.60% SELO";break;
//           case 12:txt="NET OUT OF TAX";break;
           default:txt="TOTAL"/*"NET OUT OF TAX"*/;break;
       }
        
        Phrase rt = new Phrase(txt,fontcabecatable);
        return rt; 
    }
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:25,代碼來源:ExporOnlyViagemPdf.java

示例10: writeSimplePdf

import com.itextpdf.text.Font; //導入依賴的package包/類
public static void writeSimplePdf() throws Exception{
			//1.新建document對象
			//第一個參數是頁麵大小。接下來的參數分別是左、右、上和下頁邊距。
			Document document = new Document(PageSize.A4, 50, 50, 50, 50);
			//2.建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁盤中。
			//創建 PdfWriter 對象 第一個參數是對文檔對象的引用,第二個參數是文件的實際名稱,在該名稱中還會給出其輸出路徑。
			PdfWriter writer = PdfWriter.getInstance(document, 	new FileOutputStream("D:\\Documents\\ITextTest.pdf"));
			//3.打開文檔
			document.open();		
			//4.向文檔中添加內容
			//通過 com.lowagie.text.Paragraph 來添加文本。可以用文本及其默認的字體、顏色、大小等等設置來創建一個默認段落
			BaseFont bfChinese = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
			Font fontChinese = new Font(bfChinese, 22, Font.BOLD, BaseColor.BLACK);
			
			document.add(new Paragraph("sdfsdfsd全是中文顯示了沒.fsdfsfs",fontChinese));
			document.add(new Paragraph("Some more text on the 	first page with different color and font type.",
					FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new BaseColor(255, 150, 200))));
			Paragraph pragraph=new Paragraph("你這裏有中亠好", fontChinese);
			document.add(pragraph);
			
			//圖像支持格式 GIF, Jpeg, PNG, wmf
			Image gif = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
			gif.setBorder(5);
			gif.scaleAbsolute(30,30);
			gif.setAlignment(Image.RIGHT|Image.TEXTWRAP);
			document.add(gif);
			Paragraph pragraph11=new Paragraph("你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好你這裏有中亠好", fontChinese);
			document.add(pragraph11);
			
			Image gif15 = Image.getInstance("F:/keyworkspace/survey/WebRoot/images/logo/snlogo.png");
//			gif15.setBorder(50);
			gif15.setBorder(Image.BOX);
			gif15.setBorderColor(BaseColor.RED);
//			gif15.setBorderColorBottom(borderColorBottom)
			gif15.setBorderWidth(1);
			gif15.scalePercent(50);
			document.add(gif15);
			//5.關閉文檔
			document.close();
		}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:41,代碼來源:ItextpdfTest.java

示例11: onEndPage

import com.itextpdf.text.Font; //導入依賴的package包/類
/**
 * Adds a header to every page
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
 *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
	PdfPTable table = new PdfPTable(3);
	try {
		table.setWidths(new int[]{40,5,10});
		table.setTotalWidth(100);
		table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
		table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
		Font font=new Font(chineseFont,8);
		font.setColor(new BaseColor(55,55,55));
		Paragraph paragraph=new Paragraph("第   "+writer.getPageNumber()+" 頁   共",font);
		paragraph.setAlignment(Element.ALIGN_RIGHT);
		table.addCell(paragraph);
		Image img=Image.getInstance(total);
		img.scaleAbsolute(28, 28);
		PdfPCell cell = new PdfPCell(img);
		cell.setBorder(Rectangle.NO_BORDER);
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		table.addCell(cell);
		PdfPCell c = new PdfPCell(new Paragraph("頁",font));
		c.setHorizontalAlignment(Element.ALIGN_LEFT);
		c.setBorder(Rectangle.NO_BORDER);
		table.addCell(c);
		float center=(document.getPageSize().getWidth())/2-120/2;
		table.writeSelectedRows(0, -1,center,30, writer.getDirectContent());
	}
	catch(DocumentException de) {
		throw new ExceptionConverter(de);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:35,代碼來源:PdfReportPageNumber.java

示例12: addOfferInstances

import com.itextpdf.text.Font; //導入依賴的package包/類
private void addOfferInstances(List<OfferInstance> offerInstances, Document document, BaseFont bf)
		throws DocumentException {

	if(offerInstances.isEmpty()) {
		return;
	}

	document.add(new Paragraph("Wybrane oferty: ", new Font(bf, 12)));

	PdfPTable offerInstancesTable = new PdfPTable(3);
	offerInstancesTable.setWidthPercentage(100);
	offerInstancesTable.setSpacingBefore(18f);
	offerInstancesTable.setSpacingAfter(18f);
	createofferInstancesTableHeaders(offerInstancesTable);
	createofferInstancesTableContent(offerInstances, offerInstancesTable);
	document.add(offerInstancesTable);
}
 
開發者ID:marcin-pwr,項目名稱:hotel,代碼行數:18,代碼來源:ResidenceService.java

示例13: onStartPage

import com.itextpdf.text.Font; //導入依賴的package包/類
/**
      * Increase the page number.
      * @see com.itextpdf.text.pdf.PdfPageEventHelper#onStartPage(
      *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
      */
     @Override
public void onStartPage(PdfWriter writer, Document document) {
         pagenumber++;
         System.out.println("ON Start Page PDF");
Rectangle rect = writer.getBoxSize("art");
         
         /* header     
         ColumnText.showTextAligned(writer.getDirectContent(),                		
             		com.itextpdf.text.Element.ALIGN_RIGHT, header[0],
                     rect.getRight(), rect.getTop(), 0);
          */  
		  Font font = new Font();
		  font.setSize(8);
         if (G.licensePDF) {
          ColumnText.showTextAligned(writer.getDirectContent(),
          		com.itextpdf.text.Element.ALIGN_CENTER, new Phrase(String.format(TLanguage.getString("EXPORT_PDF_LICENCIA")),font),
                  (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 18, 0);
          ColumnText.showTextAligned(writer.getDirectContent(),
	          		com.itextpdf.text.Element.ALIGN_CENTER, new Phrase(String.format(TLanguage.getString("EXPORT_PDF_LICENCIA2")),font),
	                  (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 9, 0);
         }
         
         
     }
 
開發者ID:ProgettoRadis,項目名稱:ArasuiteIta,代碼行數:30,代碼來源:HeaderFooter.java

示例14: findFont

import com.itextpdf.text.Font; //導入依賴的package包/類
private Font findFont(org.apache.poi.ss.usermodel.Cell cell) {
    if(cell == null) return new Font(Font.FontFamily.HELVETICA, 10);
    if(xSSFWorkbook == null)
        throw new NullPointerException("workbook was null!");
    final org.apache.poi.ss.usermodel.Font f = xSSFWorkbook.getFontAt(cell.getCellStyle().getFontIndex());
    

    final Font.FontFamily family;
    final String fontName = f.getFontName().toLowerCase();
    if(fontName.contains("times")) family = Font.FontFamily.TIMES_ROMAN;
    else if(fontName.contains("courier")) family = Font.FontFamily.COURIER;
    else if(fontName.contains("symbol")) family = Font.FontFamily.SYMBOL;
    else family = Font.FontFamily.HELVETICA;
    
    //final Font result = new Font(family, size);
    // the font height value is 20 * the font size in points
    final Font result = new Font(family, (float) f.getFontHeight() / 20);
    
    if(f.getBold()) result.setStyle(Font.BOLD);
    if(f.getItalic()) result.setStyle(Font.ITALIC);
    return result;
}
 
開發者ID:chiralsoftware,項目名稱:ExcelToBarcode,代碼行數:23,代碼來源:MainController.java

示例15: makePDF

import com.itextpdf.text.Font; //導入依賴的package包/類
private static void makePDF(Bitmap bmp, File file) {
    Document document = new Document();
    try {
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.addAuthor(FullscreenActivity.mAuthor.toString());
        document.addTitle(FullscreenActivity.mTitle.toString());
        document.addCreator("OpenSongApp");
        if (bmp!=null && bmp.getWidth()>bmp.getHeight()) {
            document.setPageSize(PageSize.A4.rotate());
        } else {
            document.setPageSize(PageSize.A4);
        }
        document.addTitle(FullscreenActivity.mTitle.toString());
        document.open();//document.add(new Header("Song title",FullscreenActivity.mTitle.toString()));
        BaseFont urName = BaseFont.createFont("assets/fonts/Lato-Reg.ttf", "UTF-8",BaseFont.EMBEDDED);
        Font TitleFontName  = new Font(urName, 14);
        Font AuthorFontName = new Font(urName, 10);
        document.add(new Paragraph(FullscreenActivity.mTitle.toString(),TitleFontName));
        document.add(new Paragraph(FullscreenActivity.mAuthor.toString(),AuthorFontName));
        addImage(document,bmp);
        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:thebigg73,項目名稱:OpenSongTablet,代碼行數:26,代碼來源:ExportPreparer.java


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