本文整理汇总了Java中com.itextpdf.text.Font.NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Java Font.NORMAL属性的具体用法?Java Font.NORMAL怎么用?Java Font.NORMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.itextpdf.text.Font
的用法示例。
在下文中一共展示了Font.NORMAL属性的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;
}
示例2: 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);
}
}
示例3: CreatePDF_3DPrinter
public CreatePDF_3DPrinter(File file, ArrayList<String> infos, ArrayList<Image> imagelist) throws DocumentException, MalformedURLException, IOException{
result = file;
MyPDF = new Document(PageSize.A4, 50, 50, 80, 80);
MyWriter = PdfWriter.getInstance(MyPDF,new FileOutputStream(result));
MyWriter.setInitialLeading(160);
MyPDF.open();
Font font = new Font(Font.FontFamily.TIMES_ROMAN, 40, Font.NORMAL);
Paragraph pg = new Paragraph();
pg.setAlignment(Element.ALIGN_CENTER);
pg.setSpacingAfter(150);
pg.setFont(font);
pg.add(infos.get(0));
pg.setLeading(2,1);
MyPDF.add(pg);
Image image = Image.getInstance(loadImage("/logo.png"), null);
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 580f);
if(infos.get(0).length()<25){
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 620f);
}
MyPDF.add(image);
MyPDF.add(createFrontPageTable(infos));
if(imagelist!=null){
tilingImages(imagelist);
}
MyPDF.close();
}
示例4: CreatePDF_LaserCutting
public CreatePDF_LaserCutting(File file, ArrayList<String> infos, ArrayList<Image> imagelist) throws DocumentException, MalformedURLException, IOException{
result = file;
MyPDF = new Document(PageSize.A4, 50, 50, 80, 80);
MyWriter = PdfWriter.getInstance(MyPDF,new FileOutputStream(result));
MyWriter.setInitialLeading(160);
MyPDF.open();
Font font = new Font(Font.FontFamily.TIMES_ROMAN, 40, Font.NORMAL);
Paragraph pg = new Paragraph();
pg.setAlignment(Element.ALIGN_CENTER);
pg.setSpacingAfter(150);
pg.setFont(font);
pg.add(infos.get(0));
pg.setLeading(2,1);
MyPDF.add(pg);
Image image = Image.getInstance(loadImage("/logo.png"), null);
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 580f);
if(infos.get(0).length()<25){
image.setAbsolutePosition((MyPDF.getPageSize().getWidth()/2) - (image.getWidth()/2), 620f);
}
MyPDF.add(image);
MyPDF.add(createFrontPageTable(infos));
if(imagelist!=null){
tilingImages(imagelist);
}
MyPDF.close();
}
示例5: getDefaultAttributes
/**
* Get the default element attributes used when creating document elements
* @return The set of default element attributes
*/
public static ElementAttributes getDefaultAttributes() {
CellAttributes lCellAttributes = new CellAttributes(true, PdfPCell.NO_BORDER, 0f, null);
FontAttributes lFontAttributes = new FontAttributes(11, Font.NORMAL, BaseColor.BLACK, 1.2f);
ParagraphAttributes lParagraphAttributes = new ParagraphAttributes(Element.ALIGN_LEFT);
TableAttributes lTableAttributes = new TableAttributes(Optional.of(100f), Optional.empty(), Element.ALIGN_LEFT, 0f, 0f, false);
return new ElementAttributes(lCellAttributes, lFontAttributes, lParagraphAttributes, lTableAttributes);
}
示例6: createHeaderBlock
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);
}
示例7: createAdress
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);
}
示例8: PdfStreamSource
public PdfStreamSource(FossaApplication app, LebData lebData, LebCreator lebCreator) throws DocumentException, IOException, PdfFormatierungsException {
this.lebData = lebData;
this.lebCreator = lebCreator;
BaseFont fontNormal = BaseFont.createFont(app.getContext().getBaseDirectory() + Config.getRelativeNormalFontPath(), BaseFont.CP1252, BaseFont.EMBEDDED);
BaseFont fontBold = BaseFont.createFont(app.getContext().getBaseDirectory() + Config.getRelativeBoldFontPath(), BaseFont.CP1252, BaseFont.EMBEDDED);
BaseFont fontThin = BaseFont.createFont(app.getContext().getBaseDirectory() + Config.getRelativeThinFontPath(), BaseFont.CP1252, BaseFont.EMBEDDED);
lernentwicklungsberichtUeberschriftFont = new Font(fontThin, 22, Font.NORMAL);
standardTextFont = new Font(fontNormal, KlassenstufenUtils.getLebFontSize(lebData.getKlassenname()), Font.NORMAL);
standardTextBoldFont = new Font(fontBold, KlassenstufenUtils.getLebFontSize(lebData.getKlassenname()), Font.NORMAL);
headerFont = new Font(fontNormal, 12, Font.NORMAL);
footerFont = new Font(fontNormal, 10, Font.NORMAL);
fusszeilenFont = new Font(fontNormal, 8, Font.NORMAL);
zeilenabstandsfaktor = KlassenstufenUtils.getLebZeilenabstandAsFactor(lebData.getKlassenname());
document = null;
try {
document = new Document(PageSize.A4, 100, 90, topMargin, bottomMargin);
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
LebPageHelper event = new LebPageHelper(lebData, Image.getInstance(app.getContext().getBaseDirectory() + Config.getRelativeLogoPath()), fusszeilenFont);
writer.setPageEvent(event);
document.open();
addContent(writer);
addFooter(lebData, writer);
} finally {
if (document != null) {
document.close();
}
}
}
示例9: parseURL2PDFFile
/**
* 直接把网页内容转为PDF文件
*
* @param fileName
* @throws Exception
*/
public static void parseURL2PDFFile(String pdfFile, String blogURL)
throws Exception {
BaseFont bfCN = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H",
false);
// 中文字体定义
Font chFont = new Font(bfCN, 14, Font.NORMAL, BaseColor.BLUE);
Font secFont = new Font(bfCN, 12, Font.NORMAL, new BaseColor(0, 204,
255));
Font textFont = new Font(bfCN, 12, Font.NORMAL, BaseColor.BLACK);
Document document = new Document();
PdfWriter pdfwriter = PdfWriter.getInstance(document,
new FileOutputStream(pdfFile));
pdfwriter.setViewerPreferences(PdfWriter.HideToolbar);
document.open();
String[] blogInfo = extractBlogInfo(blogURL);
int chNum = 1;
Chapter chapter = new Chapter(new Paragraph("URL转PDF测试", chFont),
chNum++);
Section section = chapter
.addSection(new Paragraph(blogInfo[0], secFont));
section.setIndentation(10);
section.setIndentationLeft(10);
section.setBookmarkOpen(false);
section.setNumberStyle(Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT);
section.add(new Chunk("分类:" + blogInfo[1] + " 日期:" + blogInfo[2],
textFont));
LineSeparator line = new LineSeparator(1, 100, new BaseColor(204, 204,
204), Element.ALIGN_CENTER, -2);
Paragraph p_line = new Paragraph(" ");
p_line.add(line);
section.add(p_line);
section.add(Chunk.NEWLINE);
document.add(chapter);
// html文件
XMLWorkerHelper.getInstance().parseXHtml(pdfwriter, document,
parse2Stream(blogInfo[3]));
document.close();
}
示例10: testSandeepSinghHeaderTable
/**
* <a href="http://stackoverflow.com/questions/29977927/table-header-in-pdf-getting-displayed-using-itextpdf5-1-1-but-not-in-itextpdf5-5">
* table header in pdf getting displayed using itextpdf5.1.1 but not in itextpdf5.5.3
* </a>
* <p>
* Indeed, the code as presented by the OP does not show the header table. This makes sense, though:
* </p>
* <p>
* The OP has cells with default padding (i.e. 2) and height 10, and he tries to insert text at height 7.
* But 2 (top margin) + 7 (text height) + 2 (bottom margin) = 11, i.e. more than fits into the cell height 10.
* Thus, the text does not fit and is not displayed.
* </p>
* <p>
* You can fix this by either
* <ul>
* <li>using a smaller font, e.g. 6, or
* <li>using a higher cell, e.g. 11, or
* <li>using a smaller padding, e.g. 1, see below-
* </p>
*/
@Test
public void testSandeepSinghHeaderTable() throws DocumentException, IOException
{
byte[] strIntermediatePDFFile = createSampleDocument();
String header1 = "Header 1";
String header2 = "Header 2";
String header3 = "Header 3";
String header5 = "Header 5";
Document document = new Document(PageSize.A4.rotate(), 20, 20, 75, 20);
PdfCopy copy = new PdfCopy(document, new FileOutputStream(new File(RESULT_FOLDER, "stampTableHeader.pdf")));
document.open();
PdfReader pdfReaderIntermediate = new PdfReader(strIntermediatePDFFile);
int numberOfPages = pdfReaderIntermediate.getNumberOfPages();
Font ffont = new Font(Font.FontFamily.UNDEFINED, 7, Font.NORMAL);
System.out.println("###### No. of Pages: " + numberOfPages);
for (int j = 0; j < numberOfPages; )
{
PdfImportedPage page = copy.getImportedPage(pdfReaderIntermediate, ++j);
PageStamp stamp = copy.createPageStamp(page);
Phrase footer = new Phrase(String.format("%d of %d", j, numberOfPages), ffont);
ColumnText.showTextAligned(stamp.getUnderContent(),
Element.ALIGN_CENTER, footer,
(document.right() - document.left()) /
2 + document.leftMargin(),
document.bottom() - 10, 0);
if (j != 1)
{
PdfPTable headerTable = new PdfPTable(2);
headerTable.setTotalWidth(700);
headerTable.getDefaultCell().setFixedHeight(10);
headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
headerTable.getDefaultCell().setPadding(1); // Added!
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
headerTable.addCell(new Phrase(String.format(header1), ffont));
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
headerTable.addCell(new Phrase(String.format(header2), ffont));
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
headerTable.addCell(new Phrase(String.format(header3), ffont));
headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
headerTable.addCell(new Phrase(String.format(header5, j), ffont));
headerTable.completeRow();
headerTable.writeSelectedRows(0, 5, 60.5f, 550, stamp.getUnderContent());
}
stamp.alterContents();
copy.addPage(page);
}
document.close();
}
示例11: createTreeCountAndCustomTextBlock
private void createTreeCountAndCustomTextBlock(PdfContentByte cb, String customText, int treeCount) throws DocumentException {
Font textFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.ITALIC, BaseColor.BLACK);
Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
Font customTextFont = new Font(FontFamily.HELVETICA, 12, Font.NORMAL, BaseColor.BLACK);
cb.saveState();
cb.setRGBColorFill(0xE0, 0xDE, 0xDF);
cb.rectangle(0.0f, 325.0f, 595.0f, 205.0f);
cb.fill();
cb.stroke();
cb.restoreState();
Integer treeCountAsObj = treeCount;
PdfPTable table = new PdfPTable(1);
float[] rows = { 595f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
table.getDefaultCell().setFixedHeight(35);
table.addCell(new Phrase(new Chunk("über die Pflanzung von", textFont)));
table.addCell(new Phrase(new Chunk(treeCountAsObj.toString(), textFontTreeCount)));
table.addCell(new Phrase(new Chunk("Bäumen", textFont)));
table.writeSelectedRows(0, 3, 0, 520, cb);
cb.saveState();
cb.setRGBColorFill(0xF7, 0xF2, 0xF4);
cb.rectangle(50.0f, 345.0f, 495.0f, 60.0f);
cb.fill();
cb.stroke();
cb.restoreState();
PdfPTable textTable = new PdfPTable(1);
float[] textRows = { 475f };
textTable.setTotalWidth(textRows);
textTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
textTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
textTable.getDefaultCell().setFixedHeight(40);
textTable.addCell(new Phrase(new Chunk(customText, customTextFont)));
textTable.writeSelectedRows(0, 1, 60, 395, cb);
}
示例12: createLawTextDateAndSignatureBlock
private void createLawTextDateAndSignatureBlock(PdfContentByte cb, String number, String date) throws DocumentException, MalformedURLException, IOException {
Font textFont = new Font(FontFamily.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK);
Font textFontBold = new Font(FontFamily.HELVETICA, 10, Font.BOLD, BaseColor.BLACK);
Font textFontSmall = new Font(FontFamily.HELVETICA, 6, Font.NORMAL, BaseColor.BLACK);
PdfPTable table = new PdfPTable(2);
float[] rows = { 247.5f, 247.5f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.BOTTOM);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);
table.getDefaultCell().setFixedHeight(75);
Phrase leftPhrase = new Phrase();
leftPhrase.add(new Chunk(
"Hiermit wird die Pflanzung dieser Bäume bescheinigt. Die Pflanzung erfolgt durch die Wald 1.1 gGmbH und kann im Internet unter www.iplantatree.org über die Zertifikat-Nummer #",
textFont));
leftPhrase.add(new Chunk(number, textFontBold));
leftPhrase.add(new Chunk(" abgerufen bzw. nachvollzogen werden.", textFont));
Phrase rightPhrase = new Phrase(10f);
rightPhrase.add(new Chunk(
"Dieses Zertifikat ist keine Bestätigung über Geldzuwendungen im Sinne des § 10 b des Einkommensteuergesetzes an eine der in § 5 Abs. 1 Nr. 9 des Körperschaftsteuergesetzes bezeichneten Körperschaften, Personenvereinigungen oder Vermögensmassen.",
textFont));
PdfPCell rightCell = new PdfPCell();
rightCell.setPaddingLeft(10.0f);
rightCell.setBorder(Rectangle.BOTTOM);
rightCell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
rightCell.setVerticalAlignment(Element.ALIGN_TOP);
rightCell.addElement(rightPhrase);
PdfPCell dateCell = new PdfPCell();
dateCell.setPaddingTop(10.0f);
dateCell.setBorder(Rectangle.NO_BORDER);
dateCell.addElement(new Phrase(new Chunk("Datum der Ausstellung: " + date, textFont)));
PdfPCell emptyCell = new PdfPCell();
emptyCell.setBorder(Rectangle.NO_BORDER);
final Image signatureImage = Image.getInstance(getClass().getResource(_imagePath + "/Unterschrift150.jpg"));
PdfPCell underSignatureCell = new PdfPCell();
underSignatureCell.setBorder(Rectangle.NO_BORDER);
underSignatureCell.setPadding(0f);
Phrase underSignaturePhrase = new Phrase(10f);
underSignaturePhrase.add(new Chunk("Unterschrift / Stempel des ausstellenden Unternehmens / der ausstellenden Person", textFontSmall));
underSignatureCell.addElement(underSignaturePhrase);
underSignatureCell.setVerticalAlignment(Element.ALIGN_TOP);
table.addCell(leftPhrase);
table.addCell(rightCell);
table.addCell(dateCell);
table.addCell(emptyCell);
table.addCell(signatureImage);
table.addCell(emptyCell);
table.addCell(underSignatureCell);
table.addCell(emptyCell);
table.writeSelectedRows(0, 4, 50, 305, cb);
}
示例13: createTreeCountAndCustomTextBlock
private void createTreeCountAndCustomTextBlock(PdfContentByte cb, String customText, int treeCount) throws DocumentException {
Font textFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.ITALIC, BaseColor.WHITE);
Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
Font customTextFont = new Font(FontFamily.HELVETICA, 12, Font.NORMAL, BaseColor.BLACK);
cb.saveState();
cb.setRGBColorFill(0x64, 0xA7, 0xBD);
cb.rectangle(0.0f, 325.0f, 595.0f, 205.0f);
cb.fill();
cb.stroke();
cb.restoreState();
Integer treeCountAsObj = treeCount;
PdfPTable table = new PdfPTable(1);
float[] rows = { 595f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
table.getDefaultCell().setFixedHeight(35);
table.addCell(new Phrase(new Chunk("über die Pflanzung von", textFont)));
table.addCell(new Phrase(new Chunk(treeCountAsObj.toString(), textFontTreeCount)));
table.addCell(new Phrase(new Chunk("Bäumen", textFont)));
table.writeSelectedRows(0, 3, 0, 520, cb);
cb.saveState();
cb.setRGBColorFill(0xF7, 0xF2, 0xF4);
cb.rectangle(50.0f, 345.0f, 495.0f, 60.0f);
cb.fill();
cb.stroke();
cb.restoreState();
PdfPTable textTable = new PdfPTable(1);
float[] textRows = { 475f };
textTable.setTotalWidth(textRows);
textTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
textTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
textTable.getDefaultCell().setFixedHeight(40);
textTable.addCell(new Phrase(new Chunk(customText, customTextFont)));
textTable.writeSelectedRows(0, 1, 60, 395, cb);
}
示例14: styleOf
private static int styleOf(Font font) {
return ((font.getStyle() != Font.UNDEFINED) ? font.getStyle() : Font.NORMAL);
}
示例15: symbol
public Chunk symbol(String name, float size, BaseColor fg) {
String s = fontAwesome.get(name);
if(s==null)
throw new IllegalArgumentException("Unrecognized symbol '" + name + "'");
return new Chunk(s, new Font(baseFont, size, Font.NORMAL, fg));
}