Package de.rototor.pdfbox.graphics2d
Klasse PdfBoxGraphics2DFontTextDrawer
java.lang.Object
de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawer
- Alle implementierten Schnittstellen:
IPdfBoxGraphics2DFontTextDrawer,Closeable,AutoCloseable
- Bekannte direkte Unterklassen:
PdfBoxGraphics2DFontTextDrawerDefaultFonts
public class PdfBoxGraphics2DFontTextDrawer
extends Object
implements IPdfBoxGraphics2DFontTextDrawer, Closeable
Default implementation to draw fonts. You can reuse instances of this class
within a PDDocument for more then one
PdfBoxGraphics2D.
Just ensure that you call close after you closed the PDDocument to free any temporary files.
-
Verschachtelte Klassen - Übersicht
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen de.rototor.pdfbox.graphics2d.IPdfBoxGraphics2DFontTextDrawer
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbooleancanDrawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) voidclose()Close / delete all resources associated with this drawer.voiddrawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) protected booleanprotected org.apache.pdfbox.pdmodel.font.PDFontTry to map the java.awt.Font to a PDFont.voidregisterFont(File fontFile) Override for registerFont(null,fontFile)voidregisterFont(InputStream fontStream) Override for registerFont(null,fontStream)voidregisterFont(String fontName, File fontFile) Register a font.voidregisterFont(String fontName, InputStream fontStream) Register a font.voidregisterFont(String name, org.apache.pdfbox.pdmodel.font.PDFont font) Register a font which is already associated with the PDDocument
-
Konstruktordetails
-
PdfBoxGraphics2DFontTextDrawer
public PdfBoxGraphics2DFontTextDrawer()
-
-
Methodendetails
-
close
public void close()Close / delete all resources associated with this drawer. This mainly means deleting all temporary files. You can not use this object after a call to close.Calling close multiple times does nothing.
- Angegeben von:
closein SchnittstelleAutoCloseable- Angegeben von:
closein SchnittstelleCloseable
-
registerFont
Register a font. If possible, try to use a font file, i.e.registerFont(String, File). This method will lead to the creation of a temporary file which stores the font data.- Parameter:
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.- Löst aus:
IOException- when something goes wrong with reading the font or writing the font to the content stream of the PDF:
-
registerFont
Register a font.- Parameter:
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 demand
-
registerFont
Override for registerFont(null,fontFile)- Parameter:
fontFile- the font file
-
registerFont
Override for registerFont(null,fontStream)- Parameter:
fontStream- the font file- Löst aus:
IOException- when something goes wrong with reading the font or writing the font to the content stream of the PDF:
-
registerFont
Register a font which is already associated with the PDDocument- Parameter:
name- the name of the font as returned byFont.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.
-
hasDynamicFontMapping
protected boolean hasDynamicFontMapping()- Gibt zurück:
- true if the font mapping is populated on demand. This is usually only the case if this class has been derived. The default implementation just checks for this.
-
canDrawText
public boolean canDrawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException - Angegeben von:
canDrawTextin SchnittstelleIPdfBoxGraphics2DFontTextDrawer- Parameter:
iterator- Has the text and all its propertiesenv- Environment- Gibt zurück:
- true when the given text can be fully drawn using fonts. return false to have the text drawn as vector shapes
- Löst aus:
IOException- when a font can not be loaded or a paint can't be applied.FontFormatException- when the font file can not be loaded
-
drawText
public void drawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException - Angegeben von:
drawTextin SchnittstelleIPdfBoxGraphics2DFontTextDrawer- Parameter:
iterator- The text with all propertiesenv- Environment- Löst aus:
IOException- when a font can not be loaded or a paint can't be applied.FontFormatException- when the font file can not be loaded
-
getFontMetrics
public FontMetrics getFontMetrics(Font f, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException - Angegeben von:
getFontMetricsin SchnittstelleIPdfBoxGraphics2DFontTextDrawer- Parameter:
f- the Fontenv- the Environment- Gibt zurück:
- the resulting font metrics
- Löst aus:
IOExceptionFontFormatException
-
mapFont
protected org.apache.pdfbox.pdmodel.font.PDFont mapFont(Font font, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException Try to map the java.awt.Font to a PDFont.- Parameter:
font- the java.awt.Font for which a mapping should be foundenv- environment of the font mapper- Gibt zurück:
- the PDFont or null if none can be found.
- Löst aus:
IOException- when the font can not be loadedFontFormatException- when the font file can not be loaded
-