use of com.itextpdf.kernel.font.PdfFont in project ComponentManagement by Bac3Phi.
the class InventoriesReportController method addTitlePage.
private void addTitlePage(Document document) throws IOException {
Paragraph title = new Paragraph("BÁO CÁO HÀNG TỒN");
// Setting font of the text
PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);
title.setFont(font);
title.setFontSize(22);
title.setTextAlignment(TextAlignment.CENTER);
document.add(title);
}
use of com.itextpdf.kernel.font.PdfFont in project ComponentManagement by Bac3Phi.
the class InventoriesReportController method addHeader.
private void addHeader(String strheader, Document document) throws IOException {
Paragraph header = new Paragraph(strheader);
// Setting font of the text
PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);
header.setFont(font);
header.setFontSize(14);
header.setTextAlignment(TextAlignment.LEFT);
document.add(header);
}
use of com.itextpdf.kernel.font.PdfFont in project spring-learning by moon-zhou.
the class Demo002 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF writer
PdfWriter writer = new PdfWriter(dest);
// Initialize PDF document
PdfDocument pdf = new PdfDocument(writer);
// Initialize document
Document document = new Document(pdf);
// Create a PdfFont
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
// Add a Paragraph
document.add(new Paragraph("iText is:").setFont(font));
// Create a List
List list = new List().setSymbolIndent(12).setListSymbol("\u2022").setFont(font);
// Add ListItem objects
list.add(new ListItem("Never gonna give you up")).add(new ListItem("Never gonna let you down")).add(new ListItem("Never gonna run around and desert you")).add(new ListItem("Never gonna make you cry")).add(new ListItem("Never gonna say goodbye")).add(new ListItem("Never gonna tell a lie and hurt you"));
// Add the list
document.add(list);
// Close document
document.close();
}
use of com.itextpdf.kernel.font.PdfFont in project i7js-highlevel by itext.
the class C02E07_JekyllHydeV3 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
document.setTextAlignment(TextAlignment.JUSTIFIED).setHyphenation(new HyphenationConfig("en", null, 3, 3)).setFont(font).setFontSize(11);
BufferedReader br = new BufferedReader(new FileReader(SRC));
String line;
Paragraph p;
boolean title = true;
while ((line = br.readLine()) != null) {
p = new Paragraph(line);
p.setKeepTogether(true);
if (title) {
p.setFont(bold).setFontSize(12);
title = false;
} else {
p.setFirstLineIndent(36);
}
if (line.isEmpty()) {
p.setMarginBottom(12);
title = true;
} else {
p.setMarginBottom(0);
}
document.add(p);
}
br.close();
// Close document
document.close();
}
use of com.itextpdf.kernel.font.PdfFont in project i7js-highlevel by itext.
the class C02E09_JekyllHydeV5 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
// Set column parameters
float offSet = 36;
float gutter = 23;
float columnWidth = (PageSize.A4.getWidth() - offSet * 2) / 2 - gutter;
float columnHeight = PageSize.A4.getHeight() - offSet * 2;
// Define column areas
Rectangle[] columns = { new Rectangle(offSet, offSet, columnWidth, columnHeight), new Rectangle(offSet + columnWidth + gutter, offSet, columnWidth, columnHeight) };
document.setRenderer(new ColumnDocumentRenderer(document, columns));
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
document.setTextAlignment(TextAlignment.JUSTIFIED).setFont(font).setHyphenation(new HyphenationConfig("en", null, 3, 3));
BufferedReader br = new BufferedReader(new FileReader(SRC));
String line;
Paragraph p;
boolean title = true;
AreaBreak nextPage = new AreaBreak(AreaBreakType.NEXT_PAGE);
while ((line = br.readLine()) != null) {
p = new Paragraph(line);
if (title) {
p.setFont(bold).setFontSize(12);
title = false;
} else {
p.setFirstLineIndent(36);
}
if (line.isEmpty()) {
document.add(nextPage);
title = true;
}
document.add(p);
}
br.close();
// Close document
document.close();
}
Aggregations