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


Java Font.BOLD属性代码示例

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


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

示例1: calculateStyle

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,代码行数:16,代码来源:PygmentsAdapter.java

示例2: addBalancedReportTitle

/**
 * 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,代码行数:40,代码来源:ReportServiceHelper.java

示例3: funcaoTitulo

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,代码行数:24,代码来源:ExporOnlyViagemPdf.java

示例4: writeSimplePdf

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,代码行数:40,代码来源:ItextpdfTest.java

示例5: generateFooter

public PdfPTable generateFooter() {
    try {
        BaseFont baseFont = BaseFont.createFont(/*"resources/ARIAL.TTF"*/ "c:/Windows/Fonts/arial.ttf", BaseFont.IDENTITY_H, true);
        footerTable = new PdfPTable(1);
        footerTable.setTotalWidth(440);
        footerTable.setLockedWidth(true);

        Font pageNumberFont = new Font(baseFont, 9, Font.BOLD);
        Paragraph pageNumberP = new Paragraph(titleIndex+"-"+ pageNumber, pageNumberFont);
        PdfPCell pageNumberCell = new PdfPCell(pageNumberP);
        pageNumberCell.setBorder(0);
        pageNumberCell.setPaddingTop(20);
        footerTable.addCell(pageNumberCell);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return footerTable;
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:18,代码来源:DynamicFooter.java

示例6: PDFFont

public PDFFont(float size, Style style, RGBColor color) throws HTDocumentException {
    try {
        BaseFont baseFont = (
                BaseFont.createFont("fonts/ttf/dejavu/DejaVuSans.ttf", "cp1251", BaseFont.EMBEDDED)
        );
        int iStyle;
        switch (style) {
            case BOLD:
                iStyle = Font.BOLD;
                break;
            case ITALIC:
                iStyle = Font.ITALIC;
                break;
            case UNDERLINE:
                iStyle = Font.UNDERLINE;
                break;
            default:
                iStyle = Font.NORMAL;
                break;
        }
        m_font = new Font(
                baseFont,
                size,
                iStyle,
                new BaseColor(color.getRed(), color.getGreen(), color.getBlue())
        );
    } catch (DocumentException | IOException e) {
        throw new HTDocumentException("Error while creating PDF font", e);
    }
}
 
开发者ID:Antokolos,项目名称:NLB,代码行数:30,代码来源:PDFFont.java

示例7: processRequest

/**
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    try (PrintWriter out = response.getWriter()) {

        //special font sizes
        //user for this entire page
        Font titleFont = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
        Font bodyFont = new Font(Font.FontFamily.TIMES_ROMAN, 10);

        //set document response type
        documentResponse(response);

        //generate new document. 
        Document doc = new Document();

        //add properties
        documentProperties(response, doc);

        //open document
        doc.open();

        //create title of report
        Paragraph title = new Paragraph("PDF in Java");

        //get the current date and time form the class
        CurrentDateTime date = new CurrentDateTime();
        
        //add header
        documentHeader(doc, date, title, response);

        //set number of columns and their widths, f is float
        float[] columnWidths = {2f, 3f, 3f, 3f};
        PdfPTable table = new PdfPTable(columnWidths);

        //set width and spacing of table, default width is 100f, f is float
        table.setWidthPercentage(90f);
        table.setSpacingBefore(10f);
        table.setSpacingBefore(10f);

        //set heading of table
        insertCell(table, "User Id", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "UserName", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "Address", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "Email", Element.ALIGN_CENTER, 1, titleFont);

        //add header row to the table, we can set more than one row
        table.setHeaderRows(1);

        //set body part of the table
        insertCell(table, "1", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "budthapa", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "Kathmandu", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "[email protected]", Element.ALIGN_CENTER, 1, bodyFont);
        
        //add document footer
        //this footer adds above table in the paragraph
        documentFooter(doc, table);

        //close the document
        doc.close();
    } catch (Exception e) {
        //exception here
    }
}
 
开发者ID:budthapa,项目名称:Create-PDF-in-Java-,代码行数:73,代码来源:createPDF.java

示例8: GeneratePDF

public GeneratePDF()
 {
try {
	bf  = BaseFont.createFont(BaseFont.TIMES_ROMAN,BaseFont.CP1250, BaseFont.EMBEDDED);
	catFont = new Font(bf, 18,
		      Font.BOLD);
	redFont = new Font(bf, 14,
		      Font.BOLD, BaseColor.RED);
	subFont = new Font(bf, 16,
		      Font.BOLD);
	smallBold = new Font(bf, 12,
		      Font.BOLD);	  
} catch (DocumentException | IOException e) {
	
	e.printStackTrace();
}  
 }
 
开发者ID:apawel,项目名称:Dziennik-Szkolny,代码行数:17,代码来源:GeneratePDF.java

示例9: GeneratePDFZeb

public GeneratePDFZeb()
 {
try {
	bf  = BaseFont.createFont(BaseFont.TIMES_ROMAN,BaseFont.CP1250, BaseFont.EMBEDDED);
	catFont = new Font(bf, 18,
		      Font.BOLD);
	redFont = new Font(bf, 14,
		      Font.BOLD, BaseColor.RED);
	subFont = new Font(bf, 16,
		      Font.BOLD);
	smallBold = new Font(bf, 12,
		      Font.BOLD);	  
} catch (DocumentException | IOException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}  
 }
 
开发者ID:apawel,项目名称:Dziennik-Szkolny,代码行数:17,代码来源:GeneratePDFZeb.java

示例10: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// TODO: 1. get direct content
		PdfContentByte canvas = writer.getDirectContent();

		Font font = new Font(FontFamily.HELVETICA, 18, Font.BOLD, BaseColor.ORANGE);
		Phrase headerText = new Phrase("PSEG DP&C", font);
		int alignLeft = Element.ALIGN_LEFT;
		float right = document.getPageSize().getRight();
		float top = document.getPageSize().getTop();

		// TODO: 2. use ColumnText
		ColumnText.showTextAligned(canvas, alignLeft, headerText, right - 180, top - 36, 0);

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:20,代码来源:T11_ColumnText.java

示例11: funcaoTitulo

private Phrase funcaoTitulo(int i) {
    String txt;
    Font fontcabecatable = new Font(Font.FontFamily.COURIER, 9, Font.BOLD);
    if(i==0){txt="S/N";}
    else if(i==1){txt="DATA";}
    else if(i==2){txt="APOLICE";}
    else if(i==3){txt="NOME CLIENTE";}
    else if(i==4){txt="NUMERO DEBITO";}
    else if(i==5){txt="BANCO";}
    else {txt="QUANTIA";}

    a=com.itextpdf.text.Element.ALIGN_CENTER;
    Phrase rt = new Phrase(txt,fontcabecatable);
    return rt; 
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:15,代码来源:MapaAnual__.java

示例12: apply

@Override
public void apply(ElementAttributes pElementAttributes, String pValue) {
  if (BOLD_PROPERTY_VALUE.equals(pValue)) {
    int lFontStyle = pElementAttributes.getFontAttributes().getStyle() | Font.BOLD;
    pElementAttributes.getFontAttributes().setStyle(lFontStyle);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:7,代码来源:FontWeightPropertyResolver.java

示例13: main

public static void main(String[] args) throws Exception{
	FileOutputStream out = new FileOutputStream("demo.pdf");
	//Rectangle rectangle = new Rectangle(216f, 720f);
	//Document document = new Document(rectangle, 36f, 72f, 108f, 180f);
	Document document = new Document(PageSize.A4);
	
	//document.setPageSize(PageSize.B5);
	//document.setMarginMirroring(true);
	//document.setMarginMirroringTopBottom(true);
	
	//BaseFont msyh = BaseFont.createFont("src/main/resources/com/hg/ecommerce/util/SIMSUNB.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
	BaseFont msyh = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
	
	PdfWriter writer = PdfWriter.getInstance(document, out);
	writer.setCloseStream(false);
	//writer.setUserunit(100f);
	
	document.open();
	
	document.add(new Paragraph("Hello World!"));
	
	document.add(new Chunk("中国",new Font(msyh,12,Font.BOLD)));
	document.add(new Chunk(" "));
	
	Font font = new Font(FontFamily.HELVETICA, 6, Font.BOLD, BaseColor.WHITE);
	Chunk chunk = new Chunk("+86",font);
	chunk.setBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f);
	chunk.setTextRise(6f);
	
	document.add(chunk);
	document.add(Chunk.NEWLINE);
	
	
	document.close();
	out.close();
}
 
开发者ID:doomdagger,项目名称:s_framework,代码行数:36,代码来源:PdfPrinter.java

示例14: process

@Override
public void process(int level, Node node, InvocationContext context) {
    StrongEmphSuperNode emNode = (StrongEmphSuperNode) node;
    Font font = context.peekFont();
    int style = emNode.isStrong() ? Font.BOLD : Font.ITALIC;
    context.pushFont(new Font(font.getBaseFont(), font.getSize(), font.getStyle() | style));
    context.processChildren(level, node);
    context.popFont();
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:9,代码来源:StrongEmphSuperNodeProcessor.java

示例15: addReportTitle

/**
 * Adds a title paragraph to the PDF document.
 *
 * @param document
 *         the document.
 * @param title
 *         the title text.
 * @throws com.itextpdf.text.DocumentException
 *         if any error occurs.
 */
static void addReportTitle(com.itextpdf.text.Document document, String title)
        throws com.itextpdf.text.DocumentException {
    if (Helper.isNullOrEmpty(title)) {
        return;
    }
    com.itextpdf.text.Paragraph p = new com.itextpdf.text.Paragraph(title,
            new Font(FontFamily.HELVETICA, 16, Font.BOLD));
    p.setAlignment(PDF_ALIGN_CENTER);
    document.add(p);
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:20,代码来源:ReportServiceHelper.java


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