Method CreateFont
- Namespace
- BitMiracle.Docotic.Pdf
- Assembly
- BitMiracle.Docotic.Pdf.dll
CreateFont(string, bool, bool)
Creates a new font with the specified font face name, italic and bold properties.
public PdfFont CreateFont(string fontFace, bool bold, bool italic)
Parameters
fontFace
stringThe name of the font family (e.g., "Arial").
bold
boolThe value indicating whether the font should be bold.
italic
boolThe value indicating whether the font should be italic.
Returns
Remarks
The library tries to embed every created font in the PDF document. However, if the
associated font license (i.e. fsType
field in the corresponding TTF/OTF bytes)
does not allow embedding, then the library won't embed the font. Check the Embedded property of the created font to know if the library will
embed it in the output PDF.
Check out the Using PDF fonts sample code for an example of using the created font.
Exceptions
- FontNotFoundException
A font with the specified parameters not found in the operating system and through the provided font loader.
- ArgumentNullException
fontFace
isnull
or empty.
CreateFont(string)
Creates a new font with the specified font face name.
public PdfFont CreateFont(string fontFace)
Parameters
fontFace
stringThe name of the font family (e.g., "Arial").
Returns
Remarks
The library tries to embed every created font in the PDF document. However, if the
associated font license (i.e. fsType
field in the corresponding TTF/OTF bytes)
does not allow embedding, then the library won't embed the font. Check the Embedded property of the created font to know if the library will
embed it in the output PDF.
Check out the Using PDF fonts sample code for an example of using the created font.
Exceptions
- FontNotFoundException
A font with the specified parameters not found in the operating system and through the provided font loader.
- ArgumentNullException
fontFace
isnull
or empty.
CreateFont(PdfBuiltInFont)
Creates a new instance of the built-in font with the specified name.
public PdfFont CreateFont(PdfBuiltInFont font)
Parameters
font
PdfBuiltInFontThe name of the built-in font.
Returns
Remarks
Built-in fonts support only Latin character set and encoding. You won't be able to use them with Unicode text.
Check out the Using PDF fonts sample code for an example of using the created font.
Exceptions
- ArgumentOutOfRangeException
font
is not one of the PdfBuiltInFont constants.
CreateFont(byte[])
Creates a new font from the provided font data in byte array format.
public PdfFont CreateFont(byte[] fontBytes)
Parameters
fontBytes
byte[]The byte array containing the font file data.
Returns
Remarks
This method accepts OpenType, TrueType, and Type1 font data.
The library tries to embed every created font in the PDF document. However, if the
associated font license (i.e. fsType
field in the corresponding TTF/OTF bytes)
does not allow embedding, then the library won't embed the font. Check the Embedded property of the created font to know if the library will
embed it in the output PDF.
Check out the Using PDF fonts sample code for an example of using the created font.
Exceptions
- UnsupportedFontException
The library can not create a PDF font from the provided data. Please send us the font data for a review.
- ArgumentNullException
fontBytes
isnull
.
CreateFont(Stream)
Creates a new font from the provided stream containing font data.
public PdfFont CreateFont(Stream fontStream)
Parameters
fontStream
StreamThe stream containing the font file data.
Returns
Remarks
This method accepts OpenType, TrueType, and Type1 font data.
The library tries to embed every created font in the PDF document. However, if the
associated font license (i.e. fsType
field in the corresponding TTF/OTF bytes)
does not allow embedding, then the library won't embed the font. Check the Embedded property of the created font to know if the library will
embed it in the output PDF.
Check out the Using PDF fonts sample code for an example of using the created font.
Exceptions
- UnsupportedFontException
The library can not create a PDF font from the provided data. Please send us the font data for a review.
- ArgumentNullException
fontStream
isnull
.