本文整理汇总了Java中com.itextpdf.text.Font.FontFamily类的典型用法代码示例。如果您正苦于以下问题:Java FontFamily类的具体用法?Java FontFamily怎么用?Java FontFamily使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontFamily类属于com.itextpdf.text.Font包,在下文中一共展示了FontFamily类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBalancedReportTitle
import com.itextpdf.text.Font.FontFamily; //导入依赖的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
示例2: createSimpleTextPdf
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
/**
* This method creates a PDF with a single styled paragraph.
*/
static byte[] createSimpleTextPdf() throws DocumentException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter.getInstance(document, baos);
document.open();
Paragraph paragraph = new Paragraph();
paragraph.add(new Phrase("Beware: ", new Font(FontFamily.HELVETICA, 12, Font.BOLDITALIC)));
paragraph.add(new Phrase("The implementation of ", new Font(FontFamily.HELVETICA, 12, Font.ITALIC)));
paragraph.add(new Phrase("MarginFinder", new Font(FontFamily.COURIER, 12, Font.ITALIC)));
paragraph.add(new Phrase(" is far from optimal. It is not even correct as it includes all curve control points which is too much. Furthermore it ignores stuff like line width or wedge types. It actually merely is a proof-of-concept.", new Font(FontFamily.HELVETICA, 12, Font.ITALIC)));
document.add(paragraph);
document.close();
return baos.toByteArray();
}
示例3: createPdf
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public void createPdf(String filename) throws DocumentException, IOException {
Document document = new Document(PageSize.LETTER);
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
// step 4 - add content into document
for (int i = 0; i < 5; i++) {
document.add(new Phrase("Hello", new Font(FontFamily.HELVETICA, 32, Font.BOLD)));
document.add(new Phrase("World", new Font(FontFamily.COURIER, 40, Font.ITALIC)));
document.add(new Phrase("!!!", new Font(FontFamily.TIMES_ROMAN, 40)));
document.add(Chunk.NEWLINE);
}
document.close();
}
示例4: createPdf
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
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();
}
示例5: HeaderFooter
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public HeaderFooter(int maximumPageNumber)
{
_maximumPageNumber = maximumPageNumber;
Chunk c = new Chunk("" + (char) 229);
c.setFont(new Font(FontFamily.SYMBOL, 28));
_sumSymbol = new Phrase(c);
}
示例6: pageNumberFooter
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
private void pageNumberFooter(PdfWriter writer, Rectangle rect)
{
Chunk c = new Chunk(String.format(LocaleStrings.getString("page"), writer.getPageNumber(), _maximumPageNumber));
c.setFont(new Font(FontFamily.HELVETICA, 10));
Phrase pagephrase = new Phrase(c);
ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, pagephrase, rect.getRight() - 60,
rect.getBottom() - 30, 0);
}
示例7: testLikeUser3208131
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/34681893/itextsharp-extra-space-between-lines">
* iTextSharp: Extra space between lines
* </a>
* <p>
* Indeed, the OP's {@link Phrase#setLeading(float, float)} calls are ignored.
* The reason is that the op is working in text mode. Thus, he has to use
* {@link ColumnText#setLeading(float, float)} instead, cf.
* {@link #testLikeUser3208131Fixed()}.
* </p>
*/
@Test
public void testLikeUser3208131() throws DocumentException, FileNotFoundException
{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "interline-user3208131.pdf")));
document.open();
Font font = new Font(FontFamily.UNDEFINED, 4, Font.UNDEFINED, null);
PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
float gutter = 15;
float colwidth = (document.getPageSize().getRight() - document.getPageSize().getLeft() - gutter) / 2;
float[] left = { document.getPageSize().getLeft() + 133, document.getPageSize().getTop() - 35,
document.getPageSize().getLeft() + 133, document.getPageSize().getBottom() };
float[] right = { document.getPageSize().getLeft() + colwidth, document.getPageSize().getTop() - 35,
document.getPageSize().getLeft() + colwidth, document.getPageSize().getBottom() };
for (int i = 0; i < 3; i++)
{
Phrase Ps = new Phrase("Test " + i + "\n", font);
Ps.setLeading(0.0f, 0.6f);
ct.addText(Ps);
ct.addText(Chunk.NEWLINE);
}
ct.setColumns(left, right);
ct.go();
document.close();
}
示例8: testLikeUser3208131Fixed
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/34681893/itextsharp-extra-space-between-lines">
* iTextSharp: Extra space between lines
* </a>
* <p>
* Indeed, the OP's {@link Phrase#setLeading(float, float)} calls are ignored,
* cf. {@link #testLikeUser3208131()}. The reason is that the op is working in
* text mode. Thus, he has to use {@link ColumnText#setLeading(float, float)}
* instead.
* </p>
*/
@Test
public void testLikeUser3208131Fixed() throws DocumentException, FileNotFoundException
{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "interline-user3208131-fixed.pdf")));
document.open();
Font font = new Font(FontFamily.UNDEFINED, 4, Font.UNDEFINED, null);
PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
float gutter = 15;
float colwidth = (document.getPageSize().getRight() - document.getPageSize().getLeft() - gutter) / 2;
float[] left = { document.getPageSize().getLeft() + 133, document.getPageSize().getTop() - 35,
document.getPageSize().getLeft() + 133, document.getPageSize().getBottom() };
float[] right = { document.getPageSize().getLeft() + colwidth, document.getPageSize().getTop() - 35,
document.getPageSize().getLeft() + colwidth, document.getPageSize().getBottom() };
ct.setLeading(0.0f, 0.3f);
for (int i = 0; i < 3; i++)
{
Phrase Ps = new Phrase("Test " + i + "\n", font);
ct.addText(Ps);
ct.addText(Chunk.NEWLINE);
}
ct.setColumns(left, right);
ct.go();
document.close();
}
示例9: testImportPages
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/31980979/itext-importing-styled-text-and-informations-from-an-existing-pdf">
* iText: Importing styled Text and informations from an existing PDF
* </a>
* <p>
* This method demonstrates how to import merely the region of a PDF page with
* actual content. The main necessity is to call {@link #cropPdf(PdfReader)}
* for the reader in question which restricts the media boxes of the pages to
* the bounding box of the existing content.
* </p>
*/
@Test
public void testImportPages() throws DocumentException, IOException
{
byte[] docText = createSimpleTextPdf();
Files.write(new File(RESULT_FOLDER, "textOnly.pdf").toPath(), docText);
byte[] docGraphics = createSimpleCircleGraphicsPdf();
Files.write(new File(RESULT_FOLDER, "graphicsOnly.pdf").toPath(), docGraphics);
PdfReader readerText = new PdfReader(docText);
cropPdf(readerText);
PdfReader readerGraphics = new PdfReader(docGraphics);
cropPdf(readerGraphics);
try ( FileOutputStream fos = new FileOutputStream(new File(RESULT_FOLDER, "importPages.pdf")))
{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, fos);
document.open();
document.add(new Paragraph("Let's import 'textOnly.pdf'", new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
document.add(Image.getInstance(writer.getImportedPage(readerText, 1)));
document.add(new Paragraph("and now 'graphicsOnly.pdf'", new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
document.add(Image.getInstance(writer.getImportedPage(readerGraphics, 1)));
document.add(new Paragraph("That's all, folks!", new Font(FontFamily.HELVETICA, 12, Font.BOLD)));
document.close();
}
finally
{
readerText.close();
readerGraphics.close();
}
}
示例10: createHeaderBlock
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public static void createHeaderBlock(PdfContentByte cb, int pageNumber, int pageSize) throws DocumentException, IOException {
cb.saveState();
cb.setColorFill(BaseColor.BLACK);
cb.rectangle(0.0f, 822.0f, 595.0f, 20.0f);
cb.fill();
cb.stroke();
cb.restoreState();
Font textFont = new Font(FontFamily.HELVETICA, 7, Font.NORMAL, BaseColor.WHITE);
PdfPTable table = new PdfPTable(4);
float[] rows = { 100f, 100f, 100f, 295f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
table.getDefaultCell().setFixedHeight(20);
table.addCell(new Phrase(new Chunk("WALD 1.1 gGmbH", textFont)));
table.addCell(new Phrase(new Chunk("[ Spendenkonto 222 888 ]", textFont)));
table.addCell(new Phrase(new Chunk("www.iplantatree.org", textFont)));
PdfPCell pageCell = new PdfPCell(new Phrase(new Chunk("Seite " + pageNumber + " von " + pageSize, textFont)));
pageCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
pageCell.setBorder(PdfPCell.NO_BORDER);
table.addCell(pageCell);
table.writeSelectedRows(0, 1, 0, 842, cb);
}
示例11: createAdress
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public static void createAdress(PdfContentByte cb, float xCoord, float yCoord) throws DocumentException {
Font textFontForAdress = new Font(FontFamily.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK);
PdfPTable table = new PdfPTable(1);
float[] rows = { 200f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setFixedHeight(14f);
table.addCell(new Phrase(new Chunk("Wald 1.1 gemeinnützige GmbH", textFontForAdress)));
table.addCell(new Phrase(new Chunk("Gabelsbergerstraße 4", textFontForAdress)));
table.addCell(new Phrase(new Chunk("D-06114 Halle", textFontForAdress)));
table.writeSelectedRows(0, 3, xCoord, yCoord, cb);
}
示例12: main
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
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();
}
示例13: generate
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public Document generate() {
Document document = new Document();
PdfWriter writer;
try {
writer = PdfWriter.getInstance(document, new FileOutputStream(this.path));
document.open();
PdfContentByte cb = writer.getDirectContent();
// Title
document.add(new Paragraph("NPL Kitchen Barcodes: DateTime ????", new Font(FontFamily.TIMES_ROMAN, 20)));
// Barcode Table
int cols = 3;
PdfPTable framing = new PdfPTable(cols);
framing.setSpacingBefore(50);
framing.setComplete(true);
for(int i = 0; i < this.captions.size(); i++) {
PdfPTable table = this.createBarcodeTable(cb, captions.get(i), details.get(i), codes.get(i));
PdfPCell cell = new PdfPCell(table);
cell.setVerticalAlignment(Element.ALIGN_CENTER);
framing.addCell(cell);
}
for(int i = 0; i < cols - (this.captions.size() % cols); i++) { // fill last row
framing.addCell("");
}
document.add(framing);
document.close();
} catch (FileNotFoundException | DocumentException e) {
e.printStackTrace();
}
return document;
}
示例14: addReportTitle
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
/**
* 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,代码行数:21,代码来源:ReportServiceHelper.java
示例15: createPdf
import com.itextpdf.text.Font.FontFamily; //导入依赖的package包/类
public void createPdf(String filename) throws DocumentException, IOException {
Document document = new Document(PageSize.LETTER);
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
// step 4 - add content into document
for (int i = 0; i < 5; i++) {
document.add(new Paragraph("Hello World !", new Font(FontFamily.HELVETICA, 32, Font.BOLD)));
}
document.close();
}