Syncfusion AI Assistant

How can I help you?

PdfStandardFont

21 Apr 202617 minutes to read

Represents one of the 14 standard fonts.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Draw the text
page.graphics.drawString('Helvetica', 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 fontFamily PdfFontFamily

Gets the font family of the PDF standard font.

Get height number

Gets the font height.

Get isBold boolean

Gets the boolean flag indicating whether the font has bold style 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 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

getFont

Gets a variant of the current font with the specified size and style.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Gets a font variant from the base font with the given size and style
const titleFont: PdfStandardFont = font.getFont(14, PdfFontStyle.bold);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Draw the text
page.graphics.drawString('Helvetica', titleFont, {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();
Parameter Type Description
size number The Font size.
style PdfFontStyle The Font style.

Returns PdfStandardFont

getLineWidth

Gets the line width.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Get the text width
let width: number = font.getLineWidth('Syncfusion', format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion');
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', format, 10, 10);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', 50);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', 50, format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', 50, format, 10, 10);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', {width: 100, height: 100});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', {width: 100, height: 100}, format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
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.

// 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 standard font
let font: PdfStandardFont = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Measure the size of the text
let size: Size = font.measureString('Syncfusion', format, {width: 0, height: 0}, 0, 0);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
text string Text.
layoutArea Size Layout area.
format PdfStringFormat String format.
charactersFitted number Characters fitted.
linesFilled number Lines filled.

Returns Size