Creates a
PdfFont
by already existing font dictionary.
Note, the font won't be added to any document, until you add it to
PdfCanvas
. While adding to
PdfCanvas
, or to
PdfResources
the font will be made indirect implicitly.
PdfDocument.getFont(com.itextpdf.kernel.pdf.PdfDictionary)
method is strongly recommended if you want to get PdfFont by both existing font dictionary, or just created and hasn't flushed yet.
Parameters:
fontDictionary
- the font dictionary to create the font from
Returns:
created
PdfFont
instance
public static
PdfFont
createFont
(
String
fontProgram,
String
encoding,
PdfDocument
cacheTo)
throws
IOException
Creates a
PdfFont
instance by the path of the font program file and given encoding and place it inside the
PdfDocument
. If such
PdfFont
has already been created and placed inside the
PdfDocument
, then retries its instance instead of creating.
PdfFontFactory.EmbeddingStrategy.PREFER_EMBEDDED
will be used as embedding strategy.
Parameters:
fontProgram
- the path of the font program file
encoding
- the font encoding. See
PdfEncodings
cacheTo
- the
PdfDocument
to cache the font
Returns:
created
PdfFont
instance
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
public static
PdfFont
createFont
(
String
fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy,
PdfDocument
cacheTo)
throws
IOException
Creates a
PdfFont
instance by the path of the font program file and given encoding and place it inside the
PdfDocument
. If such
PdfFont
has already been created and placed inside the
PdfDocument
, then retries its instance instead of creating.
Parameters:
fontProgram
- the path of the font program file
encoding
- the font encoding. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
cacheTo
- the
PdfDocument
to cache the font
Returns:
created
PdfFont
instance
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
public static
PdfFont
createFont
(
String
fontProgram,
String
encoding)
throws
IOException
Creates a
PdfFont
instance by the path of the font program file and given encoding.
Parameters:
fontProgram
- the path of the font program file
encoding
- the font encoding. See
PdfEncodings
Returns:
created
PdfFont
instance
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
public static
PdfFont
createFont
(
String
fontProgram,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
throws
IOException
Created a
PdfFont
instance given the path to the font file.
Parameters:
fontProgram
- the font program file
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
Returns:
created
PdfFont
instance
Throws:
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static
PdfFont
createFont
(
String
fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
throws
IOException
Created a
PdfFont
instance given the path to the font file.
Parameters:
fontProgram
- the font program file
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
Returns:
created
PdfFont
instance
Throws:
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static
PdfFont
createFont
(
String
fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, boolean cached)
throws
IOException
Created a
PdfFont
instance given the path to the font file.
Parameters:
fontProgram
- the font program file
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
cached
- indicates whether the font will be cached
Returns:
created
PdfFont
instance
Throws:
IOException
- in case the file is not found or the contents of the font file is mal-formed
public static
PdfFont
createFont
(
FontProgram
fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
Created a
PdfFont
instance given the given underlying
FontProgram
instance.
Parameters:
fontProgram
- the font program of the
PdfFont
instance to be created
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
Returns:
created
PdfFont
instance
public static
PdfFont
createFont
(byte[] fontProgram,
String
encoding)
throws
IOException
Created a
PdfFont
instance by the bytes of the underlying font program.
Parameters:
fontProgram
- the bytes of the underlying font program
encoding
- the encoding of the font to be created. See
PdfEncodings
Returns:
created
PdfFont
instance
Throws:
IOException
- signals that an I/O exception has occurred.
public static
PdfFont
createFont
(byte[] fontProgram,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
throws
IOException
Created a
PdfFont
instance by the bytes of the underlying font program.
Parameters:
fontProgram
- the bytes of the underlying font program
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
Returns:
created
PdfFont
instance
Throws:
IOException
- signals that an I/O exception has occurred.
public static
PdfFont
createFont
(byte[] fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
throws
IOException
Created a
PdfFont
instance by the bytes of the underlying font program.
Parameters:
fontProgram
- the bytes of the underlying font program
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
Returns:
created
PdfFont
instance
Throws:
IOException
- signals that an I/O exception has occurred.
public static
PdfFont
createFont
(byte[] fontProgram,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, boolean cached)
throws
IOException
Created a
PdfFont
instance by the bytes of the underlying font program.
Parameters:
fontProgram
- the bytes of the underlying font program
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
cached
- indicates whether the font will be cached
Returns:
created
PdfFont
instance
Throws:
IOException
- signals that an I/O exception has occurred.
public static
PdfFont
createTtcFont
(byte[] ttc, int ttcIndex,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, boolean cached)
throws
IOException
Creates a
PdfFont
instance from the TrueType Collection represented by its byte contents.
Parameters:
ttc
- the byte contents of the TrueType Collection
ttcIndex
- the index of the font in the collection, zero-based
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
cached
- indicates whether the font will be cached
Returns:
created
PdfFont
instance
Throws:
IOException
- in case the contents of the TrueType Collection is mal-formed or an error occurred during reading the font
public static
PdfFont
createTtcFont
(
String
ttc, int ttcIndex,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, boolean cached)
throws
IOException
Creates a
PdfFont
instance from the TrueType Collection given by the path to the .ttc file.
Parameters:
ttc
- the path of the .ttc file
ttcIndex
- the index of the font in the collection, zero-based
encoding
- the encoding of the font to be created. See
PdfEncodings
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded
cached
- indicates whether the font will be cached
Returns:
created
PdfFont
instance
Throws:
IOException
- in case the file is not found, contents of the TrueType Collection is mal-formed or an error occurred during reading the font
public static
PdfType3Font
createType3Font
(
PdfDocument
document, boolean colorized)
Creates a new instance of
PdfType3Font
Parameters:
document
- the target document of the new font
colorized
- indicates whether the font will be colorized
Returns:
created font
public static
PdfType3Font
createType3Font
(
PdfDocument
document,
String
fontName,
String
fontFamily, boolean colorized)
Creates a new instance of
PdfType3Font
Parameters:
document
- the target document of the new font.
fontName
- the PostScript name of the font, shall not be null or empty.
fontFamily
- a preferred font family name.
colorized
- indicates whether the font will be colorized
Returns:
created font.
public static
PdfFont
createRegisteredFont
(
String
fontName,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, int style, boolean cached)
throws
IOException
Creates
PdfFont
based on registered
FontProgram
's. Required font program is expected to be previously registered by one of the register method from
PdfFontFactory
.
Parameters:
fontName
- Path to font file or Standard font name
encoding
- Font encoding from
PdfEncodings
.
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded. Note, standard font won't be embedded in any case.
style
- Font style from
FontStyles
.
cached
- If true font will be cached for another PdfDocument
Returns:
created font if required
FontProgram
was found among registered, otherwise null.
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
See Also:
register(String)
register(String, String)
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
public static
PdfFont
createRegisteredFont
(
String
fontName,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, boolean cached)
throws
IOException
Creates
PdfFont
based on registered
FontProgram
's. Required font program is expected to be previously registered by one of the register method from
PdfFontFactory
.
Parameters:
fontName
- Path to font file or Standard font name
encoding
- Font encoding from
PdfEncodings
.
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded. Note, standard font won't be embedded in any case.
cached
- If true font will be cached for another PdfDocument
Returns:
created font if required
FontProgram
was found among registered, otherwise null.
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
See Also:
register(String)
register(String, String)
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
public static
PdfFont
createRegisteredFont
(
String
fontName,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy)
throws
IOException
Creates
PdfFont
based on registered
FontProgram
's. Required font program is expected to be previously registered by one of the register method from
PdfFontFactory
.
Parameters:
fontName
- Path to font file or Standard font name
encoding
- Font encoding from
PdfEncodings
.
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded. Note, standard font won't be embedded in any case.
Returns:
created font if required
FontProgram
was found among registered, otherwise null.
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
See Also:
register(String)
register(String, String)
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
public static
PdfFont
createRegisteredFont
(
String
fontName,
String
encoding,
PdfFontFactory.EmbeddingStrategy
embeddingStrategy, int style)
throws
IOException
Creates
PdfFont
based on registered
FontProgram
's. Required font program is expected to be previously registered by one of the register method from
PdfFontFactory
.
Parameters:
fontName
- Path to font file or Standard font name
encoding
- Font encoding from
PdfEncodings
.
embeddingStrategy
- the
PdfFontFactory.EmbeddingStrategy
which will define whether the font will be embedded. Note, standard font won't be embedded in any case.
style
- Font style from
FontStyles
.
Returns:
created font if required
FontProgram
was found among registered, otherwise null.
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
See Also:
register(String)
register(String, String)
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
public static
PdfFont
createRegisteredFont
(
String
fontName,
String
encoding)
throws
IOException
Creates
PdfFont
based on registered
FontProgram
's. Required font program is expected to be previously registered by one of the register method from
PdfFontFactory
.
Parameters:
fontName
- Path to font file or Standard font name
encoding
- Font encoding from
PdfEncodings
.
Returns:
created font if required
FontProgram
was found among registered, otherwise null.
Throws:
IOException
- exception is thrown in case an I/O error occurs when reading the file
See Also:
register(String)
register(String, String)
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
registerFamily(String, String, String)
registerDirectory(String)
registerSystemDirectories()
getRegisteredFamilies()
getRegisteredFonts()
public static
void
registerFamily
(
String
familyName,
String
fullName,
String
path)
Register a font by giving explicitly the font family and name.
Parameters:
familyName
- the font family
fullName
- the font name
path
- the font path