Java Code Examples for com.itextpdf.text.Font#BOLD

The following examples show how to use com.itextpdf.text.Font#BOLD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicFooter.java    From testarea-itext5 with GNU Affero General Public License v3.0 11 votes vote down vote up
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;
}
 
Example 2
Source File: Database.java    From GetIntoClub with GNU General Public License v3.0 5 votes vote down vote up
private void createPdf() throws FileNotFoundException, DocumentException {

        File docsFolder = new File(Environment.getExternalStorageDirectory() + "/Documents");
        if (!docsFolder.exists()) {
            docsFolder.mkdir();
            Log.i(TAG, "Created a new directory for PDF");
        }

        pdfFile = new File(docsFolder.getAbsolutePath(), "MyCV.pdf");
        OutputStream output = new FileOutputStream(pdfFile);
        Document document = new Document();
        PdfWriter.getInstance(document, output);
        document.open();
        Font bold = new Font(Font.FontFamily.HELVETICA, 20, Font.BOLD);
        Font bold1 = new Font(Font.FontFamily.TIMES_ROMAN, 28, Font.BOLDITALIC);
        Font regular = new Font(Font.FontFamily.HELVETICA, 18, Font.ITALIC);

        document.add(new Paragraph("CURRICULUM VITAE" + "\n\n", bold1));
        for (int i = 0; i < 12; i++) {
            document.add(new Paragraph(head[i], bold));
            document.add(new Paragraph(val[i] + "\n", regular));

        }
        document.close();
        Toast.makeText(Database.this, "MyCV.pdf created in Documents.", Toast.LENGTH_SHORT).show();
        finish();
        ContactDetail.name = "";
        ContactDetail.branch = "";
        ContactDetail.email = "";
        ContactDetail.mobile = "";
        SkillDetail.skill = "";
        SkillDetail.interset = "";
        SkillDetail.achievments = "";
        QuestionDetail.q1 = "";
        QuestionDetail.q2 = "";
        QuestionDetail.q3 = "";
        QuestionDetail.q4 = "";
        //        previewPdf();

    }
 
Example 3
Source File: RootTitle.java    From xiaoyaoji with GNU General Public License v3.0 5 votes vote down vote up
public RootTitle(Document doc, String title) {
	Paragraph placeHolder = new Paragraph("\n");
	placeHolder.setSpacingAfter(doc.getPageSize().getHeight() * 0.1f);
	add(placeHolder);
	Paragraph p = new Paragraph(title, new Font(BaseInfo.cjkFont, 24f, Font.BOLD, BaseColor.BLACK));
	p.setAlignment(ALIGN_CENTER);
	p.setSpacingAfter(100);
	add(p);
}
 
Example 4
Source File: PDFView.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
protected void buildPdfDocument(        
		Map<String, Object> model,        
		Document document,        
		PdfWriter writer,        
		HttpServletRequest req,        
		HttpServletResponse resp)        
				throws Exception {
	
	
	// Get data "articles" from model
	@SuppressWarnings("unchecked")
	List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers");
	
	// Fonts
	Font fontTitle = new Font(FontFamily.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK);
	Font fontTag = new Font(FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.WHITE);

	for(HrmsLogin user: users){

		// 1.Title
		document.add(new Chunk("Employee ID: "));
		Chunk title = new Chunk(user.getHrmsEmployeeDetails().getEmpId()+"", fontTitle);
		document.add(title);
		document.add(new Chunk(" "));

		// -- newline
		document.add(Chunk.NEWLINE);

		// 2.URL
		document.add(new Chunk("Username: "));
		Chunk title2 = new Chunk(user.getUsername(), fontTitle);
		document.add(title2);
		document.add(new Chunk(" "));
		
		// -- newline
		document.add(Chunk.NEWLINE);

		// 3.Categories
		document.add(new Chunk("Password: "));
		Chunk title3 = new Chunk(user.getPassword(), fontTitle);
		document.add(title3);
		document.add(new Chunk(" "));
		
		// -- newline
		document.add(Chunk.NEWLINE);
		
		// 4.Tags
		document.add(new Chunk("Employee ID: "));
		Chunk title4 = new Chunk(user.getRole(), fontTitle);
		document.add(title4);
		document.add(new Chunk(" "));
		
		// -- newline
		document.add(Chunk.NEWLINE);
		document.add(Chunk.NEWLINE);

	}
	

}
 
Example 5
Source File: FindFreeSpace.java    From testarea-itext5 with GNU Affero General Public License v3.0 4 votes vote down vote up
public static PdfPTable getFooterTable(int x, int y)
{
    java.util.Date date = new java.util.Date();

    SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");

    String month = sdf.format(date);
    System.out.println("Month : " + month);

    PdfPTable table = new PdfPTable(1);

    table.setTotalWidth(120);
    table.setLockedWidth(true);

    table.getDefaultCell().setFixedHeight(20);
    table.getDefaultCell().setBorder(Rectangle.TOP);
    table.getDefaultCell().setBorder(Rectangle.LEFT);
    table.getDefaultCell().setBorder(Rectangle.RIGHT);
    table.getDefaultCell().setBorderColorTop(BaseColor.BLUE);
    table.getDefaultCell().setBorderColorLeft(BaseColor.BLUE);
    table.getDefaultCell().setBorderColorRight(BaseColor.BLUE);
    table.getDefaultCell().setBorderWidthTop(1f);
    table.getDefaultCell().setBorderWidthLeft(1f);
    table.getDefaultCell().setBorderWidthRight(1f);

    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    Font font1 = new Font(FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLUE);

    table.addCell(new Phrase("CONTROLLED COPY", font1));

    table.getDefaultCell().setFixedHeight(20);
    table.getDefaultCell().setBorder(Rectangle.LEFT);
    table.getDefaultCell().setBorder(Rectangle.RIGHT);
    table.getDefaultCell().setBorderColorLeft(BaseColor.BLUE);
    table.getDefaultCell().setBorderColorRight(BaseColor.BLUE);
    table.getDefaultCell().setBorderWidthLeft(1f);
    table.getDefaultCell().setBorderWidthRight(1f);

    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    Font font = new Font(FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.RED);

    table.addCell(new Phrase(month, font));

    table.getDefaultCell().setFixedHeight(20);
    table.getDefaultCell().setBorder(Rectangle.LEFT);
    table.getDefaultCell().setBorder(Rectangle.RIGHT);
    table.getDefaultCell().setBorder(Rectangle.BOTTOM);
    table.getDefaultCell().setBorderColorLeft(BaseColor.BLUE);
    table.getDefaultCell().setBorderColorRight(BaseColor.BLUE);
    table.getDefaultCell().setBorderColorBottom(BaseColor.BLUE);
    table.getDefaultCell().setBorderWidthLeft(1f);
    table.getDefaultCell().setBorderWidthRight(1f);
    table.getDefaultCell().setBorderWidthBottom(1f);

    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    table.addCell(new Phrase("BLR DESIGN DEPT.", font1));

    return table;
}