IPdfBoxGraphics2DFontTextDrawer, Closeable, AutoCloseablePdfBoxGraphics2DFontTextDrawerDefaultFontspublic class PdfBoxGraphics2DFontTextDrawer extends Object implements IPdfBoxGraphics2DFontTextDrawer, Closeable
PdfBoxGraphics2D.
Just ensure that you call close after you closed the PDDocument to free any
temporary files.IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv| Constructor | Description |
|---|---|
PdfBoxGraphics2DFontTextDrawer() |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
canDrawText(AttributedCharacterIterator iterator,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) |
|
void |
close() |
Close / delete all resources associated with this drawer.
|
void |
drawText(AttributedCharacterIterator iterator,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) |
|
protected boolean |
hasDynamicFontMapping() |
|
protected org.apache.pdfbox.pdmodel.font.PDFont |
mapFont(Font font,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) |
Try to map the java.awt.Font to a PDFont.
|
void |
registerFont(File fontFile) |
Override for registerFont(null,fontFile)
|
void |
registerFont(InputStream fontStream) |
Override for registerFont(null,fontStream)
|
void |
registerFont(String fontName,
File fontFile) |
Register a font.
|
void |
registerFont(String fontName,
InputStream fontStream) |
Register a font.
|
void |
registerFont(String name,
org.apache.pdfbox.pdmodel.font.PDFont font) |
Register a font which is already associated with the PDDocument
|
public void close()
close in interface AutoCloseableclose in interface Closeablepublic void registerFont(String fontName, InputStream fontStream) throws IOException
registerFont(String,File). This method will lead to the creation of
a temporary file which stores the font data.fontName - the name of the font to use. If null, the name is taken from the
font.fontStream - the input stream of the font. This file must be a ttf/otf file!
You have to close the stream outside, this method will not close
the stream.IOExceptionpublic void registerFont(String fontName, File fontFile)
fontName - the name of the font to use. If null, the name is taken from the
font.fontFile - the font file. This file must exist for the live time of this
object, as the font data will be read lazy on demandpublic void registerFont(File fontFile)
fontFile - the font filepublic void registerFont(InputStream fontStream) throws IOException
fontStream - the font fileIOException - when something goes wrong with reading the font or writing the
font to the content stream of the PDF:public void registerFont(String name, org.apache.pdfbox.pdmodel.font.PDFont font)
name - the name of the font as returned by
Font.getFontName(). This name is used for the
mapping the java.awt.Font to this PDFont.font - the PDFont to use. This font must be loaded in the current
document.protected boolean hasDynamicFontMapping()
public boolean canDrawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
canDrawText in interface IPdfBoxGraphics2DFontTextDraweriterator - Has the text and all its propertiesenv - EnvironmentIOException - when a font can not be loaded or a paint can't be applied.FontFormatExceptionpublic void drawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
drawText in interface IPdfBoxGraphics2DFontTextDraweriterator - The text with all propertiesenv - EnvironmentIOExceptionFontFormatExceptionprotected org.apache.pdfbox.pdmodel.font.PDFont mapFont(Font font, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
font - the java.awt.Font for which a mapping should be foundenv - environment of the font mapperIOExceptionFontFormatExceptionCopyright © 2017. All rights reserved.