本文整理汇总了Java中com.lowagie.text.Font.ITALIC属性的典型用法代码示例。如果您正苦于以下问题:Java Font.ITALIC属性的具体用法?Java Font.ITALIC怎么用?Java Font.ITALIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.lowagie.text.Font
的用法示例。
在下文中一共展示了Font.ITALIC属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toPdf
/**
* Returns the PDF representation of this <CODE>PdfOutline</CODE>.
*
* @param writer the encryption information
* @param os
* @throws IOException
*/
public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
if (color != null && !color.equals(Color.black)) {
put(PdfName.C, new PdfArray(new float[]{color.getRed()/255f,color.getGreen()/255f,color.getBlue()/255f}));
}
int flag = 0;
if ((style & Font.BOLD) != 0)
flag |= 2;
if ((style & Font.ITALIC) != 0)
flag |= 1;
if (flag != 0)
put(PdfName.F, new PdfNumber(flag));
if (parent != null) {
put(PdfName.PARENT, parent.indirectReference());
}
if (destination != null && destination.hasPage()) {
put(PdfName.DEST, destination);
}
if (action != null)
put(PdfName.A, action);
if (count != 0) {
put(PdfName.COUNT, new PdfNumber(count));
}
super.toPdf(writer, os);
}
示例2: getFont
public Font getFont(ChainedProperties props) {
String face = props.getProperty(ElementTags.FACE);
if (face != null) {
StringTokenizer tok = new StringTokenizer(face, ",");
while (tok.hasMoreTokens()) {
face = tok.nextToken().trim();
if (face.startsWith("\""))
face = face.substring(1);
if (face.endsWith("\""))
face = face.substring(0, face.length() - 1);
if (fontImp.isRegistered(face))
break;
}
}
int style = 0;
if (props.hasProperty(HtmlTags.I))
style |= Font.ITALIC;
if (props.hasProperty(HtmlTags.B))
style |= Font.BOLD;
if (props.hasProperty(HtmlTags.U))
style |= Font.UNDERLINE;
if (props.hasProperty(HtmlTags.S))
style |= Font.STRIKETHRU;
String value = props.getProperty(ElementTags.SIZE);
float size = 12;
if (value != null)
size = Float.parseFloat(value);
Color color = Markup.decodeColor(props.getProperty("color"));
String encoding = props.getProperty("encoding");
if (encoding == null)
encoding = BaseFont.WINANSI;
return fontImp.getFont(face, encoding, true, size, style, color);
}
示例3: main
/**
* Extended font styles example.
*
*
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("ExtendedFontStyles.rtf"));
document.open();
// Use the RtfFont.STYLE_* instead of the Font styles.
RtfFont doubleStrikethrough = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_DOUBLE_STRIKETHROUGH);
RtfFont shadow = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_SHADOW);
// Or combine them with Font styles.
RtfFont engravedItalic = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_ENGRAVED | Font.ITALIC);
// The hidden style is special since it hides text.
RtfFont hidden = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_HIDDEN);
Paragraph paragraph = new Paragraph("This text is ", new RtfFont("Arial", 12));
// Use the RtfFonts when creating the text.
paragraph.add(new Chunk("deleted,", doubleStrikethrough));
paragraph.add(new Chunk(" shady,", shadow));
paragraph.add(new Chunk(" engraved and italic", engravedItalic));
paragraph.add(" and");
paragraph.add(new Chunk(" you won't see this", hidden));
paragraph.add(" nothing.");
document.add(paragraph);
document.close();
}
示例4: separador
public void separador(float height) throws Exception{
Font font = new Font(Font.HELVETICA, 8, Font.ITALIC, Color.GRAY);
PdfPTable sep = new PdfPTable(1);
PdfPCell cell = new PdfPCell(new Phrase(14, "", font));
cell.setBorder(0);
cell.setMinimumHeight(height);
sep.addCell(cell);
document.add(sep);
}
示例5: beforePropertyChange
public void beforePropertyChange(String propertyName) {
// do we have any text to do anything with?
// if not, then just return without action.
if(this.buffer.length() == 0) return;
if(propertyName.startsWith(RtfProperty.CHARACTER)) {
// this is a character change,
// add a new chunk to the current paragraph using current character settings.
Chunk chunk = new Chunk();
chunk.append(this.buffer.toString());
this.buffer = new StringBuffer(255);
HashMap charProperties = this.rtfParser.getState().properties.getProperties(RtfProperty.CHARACTER);
String defFont = (String)charProperties.get(RtfProperty.CHARACTER_FONT);
if(defFont == null) defFont = "0";
RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.getDestination("fonttbl");
Font currFont = fontTable.getFont(defFont);
int fs = Font.NORMAL;
if(charProperties.containsKey(RtfProperty.CHARACTER_BOLD)) fs |= Font.BOLD;
if(charProperties.containsKey(RtfProperty.CHARACTER_ITALIC)) fs |= Font.ITALIC;
if(charProperties.containsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= Font.UNDERLINE;
Font useFont = FontFactory.getFont(currFont.getFamilyname(), 12, fs, new Color(0,0,0));
chunk.setFont(useFont);
if(iTextParagraph == null) this.iTextParagraph = new Paragraph();
this.iTextParagraph.add(chunk);
} else {
if(propertyName.startsWith(RtfProperty.PARAGRAPH)) {
// this is a paragraph change. what do we do?
} else {
if(propertyName.startsWith(RtfProperty.SECTION)) {
} else {
if(propertyName.startsWith(RtfProperty.DOCUMENT)) {
}
}
}
}
}
示例6: write
/**
* Writes the representation of a <CODE>Font</CODE>.
*
* @param font a <CODE>Font</CODE>
* @param styleAttributes the style of the font
* @throws IOException
*/
protected void write(Font font, Properties styleAttributes) throws IOException {
if (font == null || !isOtherFont(font) /* || styleAttributes == null*/) return;
write(" ");
write(HtmlTags.STYLE);
write("=\"");
if (styleAttributes != null) {
String key;
for (Enumeration e = styleAttributes.propertyNames(); e.hasMoreElements(); ) {
key = (String)e.nextElement();
writeCssProperty(key, styleAttributes.getProperty(key));
}
}
if (isOtherFont(font)) {
writeCssProperty(Markup.CSS_KEY_FONTFAMILY, font.getFamilyname());
if (font.getSize() != Font.UNDEFINED) {
writeCssProperty(Markup.CSS_KEY_FONTSIZE, font.getSize() + "pt");
}
if (font.getColor() != null) {
writeCssProperty(Markup.CSS_KEY_COLOR, HtmlEncoder.encode(font.getColor()));
}
int fontstyle = font.getStyle();
BaseFont bf = font.getBaseFont();
if (bf != null) {
String ps = bf.getPostscriptFontName().toLowerCase();
if (ps.indexOf("bold") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.BOLD;
}
if (ps.indexOf("italic") >= 0 || ps.indexOf("oblique") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.ITALIC;
}
}
if (fontstyle != Font.UNDEFINED && fontstyle != Font.NORMAL) {
switch (fontstyle & Font.BOLDITALIC) {
case Font.BOLD:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
break;
case Font.ITALIC:
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
case Font.BOLDITALIC:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
}
// CSS only supports one decoration tag so if both are specified
// only one of the two will display
if ((fontstyle & Font.UNDERLINE) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_UNDERLINE);
}
if ((fontstyle & Font.STRIKETHRU) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_LINETHROUGH);
}
}
}
write("\"");
}
示例7: main
/**
* Generates a PDF file with the 14 standard Type 1 Fonts
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("StandardType1Fonts.pdf"));
// step 3: we open the document
document.open();
// step 4:
// the 14 standard fonts in PDF: do not use this Font constructor!
// this is for demonstration purposes only, use FontFactory!
Font[] fonts = new Font[14];
fonts[0] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
fonts[1] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC);
fonts[2] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD);
fonts[3] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC);
fonts[4] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL);
fonts[5] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC);
fonts[6] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
fonts[7] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[8] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL);
fonts[9] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC);
fonts[10] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD);
fonts[11] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[12] = new Font(Font.SYMBOL);
fonts[13] = new Font(Font.ZAPFDINGBATS);
// add the content
for (int i = 0; i < 14; i++) {
document.add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
}
// step 5: we close the document
document.close();
}
示例8: onFinPagina2
private void onFinPagina2(PdfWriter writer, Document document) {
Rectangle page = document.getPageSize();
PdfContentByte cb = writer.getDirectContent();
Font font = new Font(Font.HELVETICA, 7, Font.ITALIC, Color.GRAY);
if (cabecera != null){
PdfPTable head = new PdfPTable(1);
head.getDefaultCell().setBorder(Rectangle.NO_BORDER);
head.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
Paragraph bloque = new Paragraph(new Chunk(cabecera,font));
head.addCell(bloque);
head.addCell(new Phrase(new Chunk("",font)));
head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.height() - document.topMargin() + head.getTotalHeight(),writer.getDirectContent());
}
// Texto de pie y c�digo de barras
if (pie == null) pie = "";
/** VRS: cambio para a�adir paginacion */
cb.saveState();
String text = pie + " - P�g. " + writer.getPageNumber() + " de ";
float textBase = document.bottom() - 20;
float textSize = bFont.getWidthPoint(text, 7);
cb.saveState();
cb.beginText();
cb.setFontAndSize(bFont, 7);
float adjust = bFont.getWidthPoint("0", 7);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.setColorFill(Color.GRAY);
cb.showText(text);
cb.endText();
cb.addTemplate(tplTotal, document.right() - adjust, textBase);
cb.restoreState();
}