Package com.openhtmltopdf.pdfboxout
Class PdfBoxFontResolver
- java.lang.Object
-
- com.openhtmltopdf.pdfboxout.PdfBoxFontResolver
-
- All Implemented Interfaces:
com.openhtmltopdf.extend.FontResolver
public class PdfBoxFontResolver extends Object implements com.openhtmltopdf.extend.FontResolver
This class handles all font resolving for the PDF generation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPdfBoxFontResolver.FontDescriptionAFontDescriptioncan exist in multiple states.static classPdfBoxFontResolver.FontGroup
-
Constructor Summary
Constructors Constructor Description PdfBoxFontResolver(com.openhtmltopdf.layout.SharedContext sharedContext, org.apache.pdfbox.pdmodel.PDDocument doc, com.openhtmltopdf.extend.FSCacheEx<String,com.openhtmltopdf.extend.FSCacheValue> pdfMetricsCache, PdfRendererBuilder.PdfAConformance pdfAConformance, boolean pdfUaConform)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddFont(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)voidaddFont(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)Adds a font specified by an input stream (truetype) to a specific font group.voidaddFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)voidaddFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)Add a font specified by a PDFontSupplier to a specific font group.voidaddFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)Deprecated.voidaddFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)Add a font file (truetype) to a specific font group.voidaddFontCollection(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)voidaddFontCollection(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)Adds a font collection (.ttc in an input stream) to a specific font group.voidaddFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)voidaddFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)Adds a font collection (.ttc file) to a specific group.voidaddFontDirectory(String dir, boolean embedded)Deprecated.voidaddFontDirectory(String dir, boolean embedded, PdfBoxFontResolver.FontGroup fontGroup)Add all fonts in the given directoryvoidclose()Free all font resources (i.e.voidimportFontFaces(List<com.openhtmltopdf.css.sheet.FontFaceRule> fontFaces)com.openhtmltopdf.render.FSFontresolveFont(com.openhtmltopdf.layout.SharedContext renderingContext, com.openhtmltopdf.css.value.FontSpecification spec)
-
-
-
Constructor Detail
-
PdfBoxFontResolver
public PdfBoxFontResolver(com.openhtmltopdf.layout.SharedContext sharedContext, org.apache.pdfbox.pdmodel.PDDocument doc, com.openhtmltopdf.extend.FSCacheEx<String,com.openhtmltopdf.extend.FSCacheValue> pdfMetricsCache, PdfRendererBuilder.PdfAConformance pdfAConformance, boolean pdfUaConform)
-
-
Method Detail
-
resolveFont
public com.openhtmltopdf.render.FSFont resolveFont(com.openhtmltopdf.layout.SharedContext renderingContext, com.openhtmltopdf.css.value.FontSpecification spec)- Specified by:
resolveFontin interfacecom.openhtmltopdf.extend.FontResolver
-
close
public void close()
Free all font resources (i.e. open files), the document should already be closed.
-
importFontFaces
public void importFontFaces(List<com.openhtmltopdf.css.sheet.FontFaceRule> fontFaces)
-
addFontDirectory
@Deprecated public void addFontDirectory(String dir, boolean embedded) throws IOException
Deprecated.- Throws:
IOException
-
addFontDirectory
public void addFontDirectory(String dir, boolean embedded, PdfBoxFontResolver.FontGroup fontGroup) throws IOException
Add all fonts in the given directory- Throws:
IOException
-
addFontCollection
public void addFontCollection(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException
Adds a font collection (.ttc in an input stream) to a specific font group.- Throws:
IOException
-
addFontCollection
@Deprecated public void addFontCollection(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset) throws IOException
Add fonts using a .ttc TrueTypeCollection- Throws:
IOException
-
addFontCollection
public void addFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException
Adds a font collection (.ttc file) to a specific group.- Throws:
IOException
-
addFontCollection
@Deprecated public void addFontCollection(File file, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset) throws IOException
Add fonts using a .ttc TrueTypeCollection- Throws:
IOException
-
addFont
public void addFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup) throws IOException
Add a font file (truetype) to a specific font group.- Throws:
IOException
-
addFont
@Deprecated public void addFont(File fontFile, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset) throws IOException
Deprecated.Add a font using a existing file. If the file is a TrueTypeCollection, it will be handled as such.- Throws:
IOException
-
addFont
public void addFont(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)
Adds a font specified by an input stream (truetype) to a specific font group.
-
addFont
@Deprecated public void addFont(com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)
Add a font using a InputStream. The given file must be a TrueType Font (.ttf). If you know the underlying stream is a .ttc file you should useaddFontCollection(FSSupplier, String, Integer, IdentValue, boolean)
-
addFont
public void addFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset, PdfBoxFontResolver.FontGroup fontGroup)
Add a font specified by a PDFontSupplier to a specific font group.
-
addFont
@Deprecated public void addFont(PDFontSupplier supplier, String fontFamilyNameOverride, Integer fontWeightOverride, com.openhtmltopdf.css.constants.IdentValue fontStyleOverride, boolean subset)
Add a font using a PDFontSupplier. Use this method if you need special rules for font-loading (like using a font-cache) and subclass thePDFontSupplier.
-
-