本文整理汇总了Java中org.apache.pdfbox.pdmodel.font.PDType1Font.COURIER属性的典型用法代码示例。如果您正苦于以下问题:Java PDType1Font.COURIER属性的具体用法?Java PDType1Font.COURIER怎么用?Java PDType1Font.COURIER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.pdfbox.pdmodel.font.PDType1Font
的用法示例。
在下文中一共展示了PDType1Font.COURIER属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTestDocument
byte[] createTestDocument() throws IOException, COSVisitorException
{
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream();
PDDocument doc = new PDDocument() )
{
PDPage page = new PDPage(new PDRectangle(792, 612));
doc.addPage(page);
PDFont font = PDType1Font.COURIER;
PDPageContentStream contents = new PDPageContentStream(doc, page);
contents.beginText();
contents.setFont(font, 9);
contents.moveTextPositionByAmount(100, 500);
contents.drawString(" 2 Netto 5,00 EUR 3,00");
contents.moveTextPositionByAmount(0, 0);
contents.drawString(" 2882892 ENERGIZE LR6 Industrial 2,50 EUR 1");
contents.endText();
contents.close();
doc.save(baos);
return baos.toByteArray();
}
}
示例2: chooseMatchingCourier
/**
* Get a PDType1Font.COURIER-variant, which matches the given font
*
* @param font
* Font to get the styles from
* @return a PDFont Courier variant which matches the style in the given Font
* object.
*/
public static PDFont chooseMatchingCourier(Font font) {
if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
return PDType1Font.COURIER_BOLD_OBLIQUE;
if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
return PDType1Font.COURIER_OBLIQUE;
if ((font.getStyle() & Font.BOLD) == Font.BOLD)
return PDType1Font.COURIER_BOLD;
return PDType1Font.COURIER;
}
示例3: tryBuiltinFallback
private PDFont tryBuiltinFallback(String fontFamily, boolean isItalic, boolean isBold)
{
PDFont font;
fontFamily = fontFamily.toLowerCase();
switch (fontFamily) {
case "courier":
case "courier new":
case "lucida console":
if (isBold && isItalic) { font = PDType1Font.COURIER_BOLD_OBLIQUE;}
else if (isBold) { font = PDType1Font.COURIER_BOLD;}
else if (isItalic) { font = PDType1Font.COURIER_OBLIQUE;}
else { font = PDType1Font.COURIER;}
break;
case "times":
case "garamond":
case "georgia":
case "times new roman":
case "serif":
if (isBold && isItalic) { font = PDType1Font.TIMES_BOLD_ITALIC;}
else if (isBold) { font = PDType1Font.TIMES_BOLD;}
else if (isItalic) { font = PDType1Font.TIMES_ITALIC;}
else { font = PDType1Font.TIMES_ROMAN;}
break;
default:
if (isBold && isItalic) { font = PDType1Font.HELVETICA_BOLD_OBLIQUE;}
else if (isBold) { font = PDType1Font.HELVETICA_BOLD;}
else if (isItalic) { font = PDType1Font.HELVETICA_OBLIQUE;}
else { font = PDType1Font.HELVETICA;}
break;
}
return font;
}