[]
        
(Showing Draft Content)

PdfFont

Abstract Class: PdfFont

The base abstract class representing a font in a PDF document.

Extends

Extended by

Accessors

baseFont

Get Signature

get baseFont(): string;

Gets or sets the PostScript name of the font.

Returns

string

Set Signature

set baseFont(value): void;

Gets or sets the PostScript name of the font.

Parameters
value

string

Returns

void


id

Get Signature

get id(): number;

Gets the reference to the object.

Returns

number

Inherited from

ObjectBase.id


isEmbedded

Get Signature

get isEmbedded(): boolean;

Gets a value indicating whether the font is embedded.

Returns

boolean


om

Get Signature

get om(): ObjectManager;

Gets the owner ObjectManager instance.

Returns

ObjectManager

Inherited from

ObjectBase.om

Methods

createNativeFont()

createNativeFont(): Font;

Gets a Font object created from the embedded font data.

Note that this method will return null if the font is not embedded or does not support this operation (e.g. Type3 fonts).

Returns

Font

The Font object.


findNativeFont()

findNativeFont(doc, allowStandardPdfFonts?): Font;

Finds the most suitable native font for rendering text associated with this PDF font.

The PDF specification does not define a precise algorithm for selecting a font when no embedded font data is available. This method uses a combination of heuristics and practical strategies to choose an appropriate native font.

Parameters

doc

PdfDocument

The PdfDocument that owns this font.

allowStandardPdfFonts?

boolean

If true (the default), also searches the 14 standard PDF fonts if a suitable font could not be found among the registered fonts.

Returns

Font

The native font that matches the current PDF font, or null if a match could not be found.


free()

free(): void;

Detaches the object from the ObjectManager and deallocates its memory, if possible.

Returns

void

Inherited from

ObjectBase.free


getEmbeddedData()

getEmbeddedData(): Uint8Array<ArrayBufferLike>;

Returns the embedded font data, returns null if the font is not embedded.

Returns

Uint8Array<ArrayBufferLike>

The embedded font data or null if the font is not embedded.


getFontAttributes()

getFontAttributes(): PdfFontAttributes;

Extracts the attributes of the current font. If a specific attribute cannot be determined, the corresponding value is set to null.

Returns

PdfFontAttributes

The PdfFontAttributes object containing the font attributes.


getFontDescriptor()

getFontDescriptor(): PdfFontDescriptor;

Gets a PdfFontDescriptor object that describes the font.

Returns

PdfFontDescriptor

The PdfFontDescriptor object.


rebind()

rebind(omTo): void;

Rebinds the object from the current ObjectManager to the specified one.

Parameters

omTo

ObjectManager

The new ObjectManager for the object.

Returns

void

Inherited from

ObjectBase.rebind


removeEmbeddedData()

removeEmbeddedData(doc): void;

Removes the embedded font data.

Please note that a PDF may display incorrectly after removing an embedded font's data. Use with caution.

Parameters

doc

PdfDocument

The document that owns the font.

Returns

void


tryGetPdfCode()

tryGetPdfCode(unicode): PdfCodeInfo;

Tries to convert a Unicode value to the character's PDF code.

Note that this method can fail if the font does not contain the necessary info for the conversion or does not contain the specified Unicode value, in this case null is returned.

Note also that this method can be slow as it uses large font tables like /Encoding, /ToUnicode etc., so it is recommended that the returned results are cached by the caller.

Parameters

unicode

string

The character Unicode.

Returns

PdfCodeInfo

The PdfCodeInfo object containing the character PDF code, or null if the conversion failed.


tryGetUnicode()

tryGetUnicode(pdfCode): string;

Converts a character's PDF code to its Unicode value.

Note that this method can fail if the font does not contain the necessary info for the conversion, in this case null is returned.

Note also that this method can be slow as it uses large font tables like /Encoding, /ToUnicode etc., so the returned results better be cached by the caller.

Parameters

pdfCode

number

The character PDF code.

Returns

string

The character Unicode, or null if the conversion failed.