Represents the base class for font objects.`
// 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 = new PdfStandardFont(PdfFontFamily.Helvetica, 10);
// Create a new PDF string format
let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
// Draw the text
page.graphics.drawString('Helvetica', font, [0, 180, page.size[0], 40], undefined, new PdfBrush([0, 0, 255]), format);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
number
Gets the font height.
boolean
Gets the boolean flag indicating whether the font has bold style or not.
boolean
Gets the boolean flag indicating whether the font has italic style or not.
boolean
Gets the boolean flag indicating whether the font has strike out style or not.
boolean
Gets the boolean flag indicating whether the font has underline style or not.
number
Gets the size of the PDF font.
PdfFontStyle
Gets the style of the PDF font.
Measures the size of a given text string when rendered using this PDF font.
Parameter | Type | Description |
---|---|---|
text | string |
Text. |
Returns number[]
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 number[]
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 number[]
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 number[]
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 number[]
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 number[]
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 | number[] |
Layout area. |
Returns number[]
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 | number[] |
Layout area. |
format | PdfStringFormat |
String format. |
Returns number[]
Measures the size of a given text string when rendered using this PDF font.
Parameter | Type | Description |
---|---|---|
text | string |
Text. |
layoutArea | number[] |
Layout area. |
format | PdfStringFormat |
String format. |
charactersFitted | number |
Characters fitted. |
linesFilled | number |
Lines filled. |
Returns number[]