HelpBot Assistant

How can I help you?

PdfTrueTypeFont

6 Feb 20268 minutes to read

Represents TrueType font.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Gets the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Create a new PDF truetype font
let font: PdfTrueTypeFont = document.embedFont(fontData, 14, { shouldUnderline: true });
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Draw the text
page.graphics.drawString('Hello world', font, {x: 0, y: 180, width: page.size.width, height: 40},, new PdfBrush({r: 0, g: 0, b: 255}), format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

Get height number

Gets the font height.

Get isBold boolean

Gets the boolean flag indicating whether the font has bold style or not.

Get isEmbed boolean

Gets the boolean flag indicating whether the font is embedded or not.

Get isItalic boolean

Gets the boolean flag indicating whether the font has italic style or not.

Get isStrikeout boolean

Gets the boolean flag indicating whether the font has strike out style or not.

Get isUnderline boolean

Gets the boolean flag indicating whether the font has underline style or not.

Get isUnicode boolean

Gets the boolean flag indicating whether the font has unicode or not.

Get size number

Gets the size of the PDF font.

Get style PdfFontStyle

Gets the style of the PDF font.

Set style void

Sets the style of the PDF font.

Parameter Type Description
value PdfFontStyle To font style.

Methods

getLineWidth

Gets the line width.

Parameter Type Description
line string Line.
format PdfStringFormat String format.

Returns number

measureString

Measures the size of a given text string when rendered using this PDF font.

Parameter Type Description
text string Text.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font with respect to the string format.

Parameter Type Description
text string Text.
format PdfStringFormat String format.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font.

Parameter Type Description
text string Text.
format PdfStringFormat String format.
charactersFitted number Characters fitted.
linesFilled number Lines filled.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font with respect to the maximum line width.

Parameter Type Description
text string Text.
width number width.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font with respect to the string format and maximum line width.

Parameter Type Description
text string Text.
width number width.
format PdfStringFormat String format.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font.

Parameter Type Description
text string Text.
width number width.
format PdfStringFormat String format.
charactersFitted number Characters fitted.
linesFilled number Lines filled.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font with respect to the layout area.

Parameter Type Description
text string Text.
layoutArea Size Layout area.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font with respect to the layout area and string format.

Parameter Type Description
text string Text.
layoutArea Size Layout area.
format PdfStringFormat String format.

Returns Size

measureString

Measures the size of a given text string when rendered using this PDF font.

Parameter Type Description
text string Text.
layoutArea Size Layout area.
format PdfStringFormat String format.
charactersFitted number Characters fitted.
linesFilled number Lines filled.

Returns Size