@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
2,048 lines • 72.5 kB
TypeScript
import { PdfStringFormat } from './pdf-string-format';
import { _PdfFontMetrics } from './pdf-font-metrics';
import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
import { _UnicodeTrueTypeFont } from './unicode-true-type-font';
import { Size } from './../pdf-type';
import { PdfDocument } from '../pdf-document';
/**
* Represents the base class for font objects.`
* ```typescript
* // 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();
* ```
*/
export declare abstract class PdfFont {
/**
* Style flags applied to the font (bold, italic, etc.).
*
* @private
*/
_style: PdfFontStyle;
/**
* Current font size in points.
*
* @private
*/
_size: number;
/**
* Dictionary containing the font object entries.
*
* @private
*/
_dictionary: _PdfDictionary;
/**
* Internal font dictionary used for serialization.
*
* @private
*/
_pdfFontInternals: _PdfDictionary;
/**
* Metrics information describing font ascents, descents, and widths.
*
* @private
*/
_fontMetrics: _PdfFontMetrics;
/**
* Cross-reference to this font object.
*
* @private
*/
_reference: _PdfReference;
/**
* Cache key used for font reuse.
*
* @private
*/
_key: string;
/**
* Ascent value of the font metrics.
*
* @private
*/
_ascent: number;
/**
* Descent value of the font metrics.
*
* @private
*/
_descent: number;
/** Additional spacing between baselines.
*
* @private
*/
_lineGap: number;
/**
* Computed line height for layout.
*
* @private
*/
_height: number;
/**
* Reference to the owning PDF document.
*
* @private
*/
_document: PdfDocument;
/**
* Gets the size of the PDF font.
*
* @returns {number} size.
*
* ```typescript
* // 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, 12, PdfFontStyle.regular);
* // Gets the font size
* let size: number = font.size;
* // Destroy the document
* document.destroy();
* ```
*/
readonly size: number;
/**
* Gets the style of the PDF font.
*
* @returns {PdfFontStyle} size.
*
* ```typescript
* // 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, 12, PdfFontStyle.regular);
* // Gets the font style
* let style: PdfFontStyle = font.style;
* // Destroy the document
* document.destroy();
* ```
*/
/**
* Sets the style of the PDF font.
*
* @param {PdfFontStyle} value to font style.
*
* ```typescript
* // 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, 12, PdfFontStyle.regular);
* // Sets the font style
* font.style = PdfFontStyle.italic;
* // Destroy the document
* document.destroy();
* ```
*/
style: PdfFontStyle;
/**
* Gets the boolean flag indicating whether the font has underline style or not.
*
* @returns {boolean} isUnderline.
*
* ```typescript
* // 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, 12, PdfFontStyle.underline);
* // Gets the boolean flag indicating whether the font has underline style or not.
* let underline: boolean = font.isUnderline;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isUnderline: boolean;
/**
* Gets the boolean flag indicating whether the font has strike out style or not.
*
* @returns {boolean} isStrikeout.
*
* ```typescript
* // 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, 12, PdfFontStyle.strikeout);
* // Gets the boolean flag indicating whether the font has strike out style or not.
* let strikeout: boolean = font.isStrikeout;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isStrikeout: boolean;
/**
* Gets the font metrics used by the font internals.
*
* @private
* @returns {_PdfFontMetrics} fontMetrics.
*/
/**
* Sets the font metrics used by the font internals.
*
* @private
* @param {_PdfFontMetrics} value Font metrics.
* @returns {void} nothing.
*/
_metrics: _PdfFontMetrics;
/**
* Gets the boolean flag indicating whether the font has bold style or not.
*
* @returns {boolean} isBold.
*
* ```typescript
* // 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, 12, PdfFontStyle.bold);
* // Gets the boolean flag indicating whether the font has bold style or not.
* let bold: boolean = font.isBold;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isBold: boolean;
/**
* Gets the boolean flag indicating whether the font has italic style or not.
*
* @returns {boolean} isItalic.
*
* ```typescript
* // 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, 12, PdfFontStyle.italic);
* // Gets the boolean flag indicating whether the font has italic style or not.
* let italic: boolean = font.isItalic;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isItalic: boolean;
/**
* Gets the font height.
*
* @returns {number} height.
*
* ```typescript
* // 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, 12, PdfFontStyle.italic);
* // Gets the font height
* let height: number = font.height;
* // Destroy the document
* document.destroy();
* ```
*/
readonly height: number;
constructor(size: number);
constructor(size: number, style: PdfFontStyle);
/**
* Assigns the internal font dictionary for low level operations.
*
* @private
* @param {_PdfDictionary} internals Internal font dictionary.
* @returns {void} nothing.
*/
_setInternals(internals: _PdfDictionary): void;
/**
* Counts occurrences of specified symbols in the given text.
*
* @private
* @param {string} text Text.
* @param {string[] | string} symbols Symbols to count.
* @returns {number} count.
*/
_getCharacterCount(text: string, symbols: string[] | string): number;
/**
* Resolves the effective font size considering subscript and superscript.
*
* @private
* @param {PdfStringFormat} format String format.
* @returns {number} size.
*/
_getSize(format: PdfStringFormat): number;
/**
* Computes the font height using ascent descent and line gap for the given format.
*
* @private
* @returns {number} returns height of the text.
*/
_getHeight(): number;
_getHeight(format: PdfStringFormat): number;
/**
* Computes the ascent scaled by the effective font size.
*
* @private
* @param {PdfStringFormat} format String format.
* @returns {number} ascent.
*/
_getAscent(format: PdfStringFormat): number;
/**
* Computes the descent scaled by the effective font size.
*
* @private
* @param {PdfStringFormat} format String format.
* @returns {number} descent.
*/
_getDescent(format: PdfStringFormat): number;
/**
* Computes the line gap scaled by the effective font size.
*
* @private
* @param {PdfStringFormat} format String format.
* @returns {number} lineGap.
*/
_getLineGap(format: PdfStringFormat): number;
/**
* Measures the size of a given text string when rendered using this PDF font.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @returns {Size} actualSize.
*/
measureString(text: string): Size;
/**
* Measures the size of a given text string when rendered using this PDF font with respect to the string format.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {PdfStringFormat} format String format.
* @returns {Size} actualSize.
*/
measureString(text: string, format: PdfStringFormat): Size;
/**
* Measures the size of a given text string when rendered using this PDF font.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {PdfStringFormat} format String format.
* @param {number} charactersFitted Characters fitted.
* @param {number} linesFilled Lines filled.
* @returns {size} actualSize.
*/
measureString(text: string, format: PdfStringFormat, charactersFitted: number, linesFilled: number): Size;
/**
* Measures the size of a given text string when rendered using this PDF font with respect to the maximum line width.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {number} width width.
* @returns {Size} actualSize.
*/
measureString(text: string, width: number): Size;
/**
* Measures the size of a given text string when rendered using this PDF font with respect to the string format and maximum line width.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {number} width width.
* @param {PdfStringFormat} format String format.
* @returns {Size} actualSize.
*/
measureString(text: string, width: number, format: PdfStringFormat): Size;
/**
* Measures the size of a given text string when rendered using this PDF font.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {number} width width.
* @param {PdfStringFormat} format String format.
* @param {number} charactersFitted Characters fitted.
* @param {number} linesFilled Lines filled.
* @returns {Size} actualSize.
*/
measureString(text: string, width: number, format: PdfStringFormat, charactersFitted: number, linesFilled: number): Size;
/**
* Measures the size of a given text string when rendered using this PDF font with respect to the layout area.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {Size} layoutArea Layout area.
* @returns {Size} actualSize.
*/
measureString(text: string, layoutArea: Size): Size;
/**
* Measures the size of a given text string when rendered using this PDF font with respect to the layout area and string format.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {PdfStringFormat} format String format.
* @param {Size} layoutArea Layout area.
* @returns {Size} actualSize.
*/
measureString(text: string, layoutArea: Size, format: PdfStringFormat): Size;
/**
* Measures the size of a given text string when rendered using this PDF font.
*
* ```typescript
* // 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();
* ```
*
* @param {string} text Text.
* @param {PdfStringFormat} format String format.
* @param {Size} layoutArea Layout area.
* @param {number} charactersFitted Characters fitted.
* @param {number} linesFilled Lines filled.
* @returns {Size} actualSize.`
*/
measureString(text: string, layoutArea: Size, format: PdfStringFormat, charactersFitted: number, linesFilled: number): Size;
_applyFormatSettings(line: string, format: PdfStringFormat, width: number): number;
/**
* Applies character and word spacing adjustments to the measured width.
*/
abstract getLineWidth(line: string, format: PdfStringFormat): number;
/**
* Creates and assigns the internal font structures and resources.
*/
abstract _initializeInternals(): void;
}
/**
* Represents one of the 14 standard fonts.
* ```typescript
* // 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();
* ```
*/
export declare class PdfStandardFont extends PdfFont {
/**
* Standard font family used by this font instance.
*
* @private
*/
_fontFamily: PdfFontFamily;
/**
* Initializes a new instance of the `PdfStandardFont` class.
*
* @param {PdfFontFamily} fontFamily PdfFontFamily.
* @param {number} size Size.
* ```typescript
* // 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, {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();
* ```
*/
constructor(fontFamily: PdfFontFamily, size: number);
/**
* Initializes a new instance of the `PdfStandardFont` class.
*
* @param {PdfFontFamily} fontFamily PdfFontFamily.
* @param {PdfFontStyle} style PdfFontStyle.
* @param {number} size Size.
* ```typescript
* // 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, 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();
* ```
*/
constructor(fontFamily: PdfFontFamily, size: number, style: PdfFontStyle);
/**
* Initializes a new instance of the `PdfStandardFont` class.
*
* @private
* @param {PdfFontFamily} fontFamily The Font data as byte array.
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @param {_PdfFontPrimitive} primitive The Font primitive.
*/
constructor(fontFamily: PdfFontFamily, size: number, style: PdfFontStyle, primitive: _PdfFontPrimitive);
/**
* Gets the font family of the PDF standard font.
*
* @returns {PdfFontFamily} fontFamily.
*
* ```typescript
* // 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 the font family
* let fontFamily: PdfFontFamily = font.fontFamily;
* // Destroy the document
* document.destroy();
* ```
*/
readonly fontFamily: PdfFontFamily;
/**
* Gets the line width.
*
* ```typescript
* // 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();
* ```
*
* @param {string} line Line.
* @param {PdfStringFormat} format String format.
* @returns {number} width.
*/
getLineWidth(line: string, format: PdfStringFormat): number;
/**
* Gets a variant of the current font with the specified size and style.
*
* ```typescript
* // 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();
* ```
*
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @returns {PdfStandardFont} The Font object.
*/
getFont(size: number, style: PdfFontStyle): PdfStandardFont;
/**
* Normalizes the style to disable unsupported combinations for the selected family.
*
* @private
* @returns {void} nothing.
*/
_checkStyle(): void;
/**
* Initializes metrics and the font dictionary either from the given primitive
* or by creating new internal structures.
*
* @private
* @param {_PdfFontPrimitive} primitive Font primitive.
* @returns {void} nothing.
*/
_initializeInternals(primitive?: _PdfFontPrimitive): void;
/**
* Initializes metrics and the font dictionary either from the given primitive
* or by creating new internal structures.
*
* @private
* @returns {void} nothing.
*/
_handleMetrics(): void;
/**
* Assigns metrics specific to the Helvetica family based on the current style.
*
* @private
* @returns {void} nothing.
*/
_handleHelveticaMetrics(): void;
/**
* Assigns metrics specific to the Courier family based on the current style.
*
* @private
* @returns {void} nothing.
*/
_handleCourierMetrics(): void;
/**
* Assigns metrics specific to the Times family based on the current style.
*
* @private
* @returns {void} nothing.
*/
_handleTimesMetrics(): void;
/**
* Assigns metrics specific to the Symbol font family.
*
* @private
* @returns {void} nothing.
*/
_handleSymbolMetrics(): void;
/**
* Assigns metrics specific to the ZapfDingbats font family.
*
* @private
* @returns {void} nothing.
*/
_handleZapfDingbatsMetrics(): void;
/**
* Creates the standard font dictionary entries including subtype and encoding.
*
* @private
* @returns {_PdfDictionary} dictionary.
*/
_createInternals(): _PdfDictionary;
/**
* Looks up the character width for a code point using the metrics width table.
*
* @private
* @param {string} charCode Character whose width should be retrieved.
* @returns {number} width.
*/
_getCharacterWidthInternal(charCode: string): number;
}
/**
* Represents one of the 7 CJK standard fonts.
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.regular, true);
* // Create a new PDF string format
* let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
* // Draw the text
* page.graphics.drawString('こんにちは世界', 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();
* ```
*/
export declare class PdfCjkStandardFont extends PdfFont {
/**
* CJK font family used by this font instance.
*
* @private
*/
_fontFamily: PdfCjkFontFamily;
/**
* Gets the font family of the PDF CJK font.
*
* @returns {PdfCjkFontFamily} fontFamily.
*
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.regular, true);
* // Gets the font family
* let fontFamily: PdfCjkFontFamily = font.fontFamily;
* // Destroy the document
* document.destroy();
* ```
*/
readonly fontFamily: PdfCjkFontFamily;
/**
* Initializes a new instance of the `PdfCjkStandardFont` class.
*
* @param {PdfCjkFontFamily} fontFamily PdfFontFamily.
* @param {number} size Size.
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = new PdfCjkStandardFont(PdfCjkFontFamily.heiseiMinchoW3, 20);
* // Create a new PDF string format
* let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
* // Draw the text
* page.graphics.drawString('こんにちは世界', 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();
* ```
*/
constructor(fontFamily: PdfCjkFontFamily, size: number);
/**
* Initializes a new instance of the `PdfCjkStandardFont` class.
*
* @param {PdfCjkFontFamily} fontFamily PdfFontFamily.
* @param {PdfFontStyle} style PdfFontStyle.
* @param {number} size Size.
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = new PdfCjkStandardFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.bold);
* // Create a new PDF string format
* let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
* // Draw the text
* page.graphics.drawString('こんにちは世界', 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();
* ```
*/
constructor(fontFamily: PdfCjkFontFamily, size: number, style: PdfFontStyle);
/**
* Initializes a new instance of the `PdfCjkStandardFont` class.
*
* @private
* @param {PdfCjkFontFamily} fontFamily The Font data as byte array.
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @param {_PdfFontPrimitive} primitive The Font primitive.
*/
constructor(fontFamily: PdfCjkFontFamily, size: number, style: PdfFontStyle, primitive: _PdfFontPrimitive);
/**
* Gets the line width.
*
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.bold, true);
* // 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();
* ```
*
* @param {string} line Line.
* @param {PdfStringFormat} format String format.
* @returns {number} width.
*/
getLineWidth(line: string, format: PdfStringFormat): number;
/**
* Gets a variant of the current font with the specified size and style.
*
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.bold, true);
* // Gets a font variant from the base font with the given size and style
* const titleFont: PdfCjkStandardFont = 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();
* ```
*
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @returns {PdfCjkStandardFont} The Font object.
*/
getFont(size: number, style: PdfFontStyle): PdfCjkStandardFont;
/**
* Initializes CJK font metrics, font dictionary and descriptor entries from a primitive
* if provided, otherwise creates and assigns new internals.
*
* @private
* @param {_PdfFontPrimitive} [primitive] Font primitive.
* @returns {void} nothing.
*/
_initializeInternals(primitive?: _PdfFontPrimitive): void;
/**
* Assigns ascent, descent and height values for the selected CJK font family.
*
* @private
* @returns {void} nothing.
*/
_handleMetric(): void;
/**
* Creates the composite CJK font dictionary with encoding and descendant fonts.
*
* @private
* @returns {_PdfDictionary} dictionary.
*/
_createInternals(): _PdfDictionary;
/**
* Returns the CJK encoding name suitable for the selected font family.
*
* @private
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @returns {_PdfName} encoding.
*/
_getEncoding(fontFamily: PdfCjkFontFamily): _PdfName;
/**
* Creates the descendant font dictionary including widths, descriptor and system info.
*
* @private
* @returns {_PdfDictionary[]} descendantFonts.
*/
_getDescendantFont(): _PdfDictionary[];
/**
* Creates the CJK system information dictionary describing registry, ordering and supplement.
*
* @private
* @returns {_PdfDictionary} systemInformation.
*/
_getSystemInformation(): _PdfDictionary;
/**
* Looks up the character width for a CJK code point using the width table.
*
* @private
* @param {number} charCode Character code.
* @returns {number} width.
*/
_getCharacterWidthInternal(charCode: number): number;
}
/**
* Represents TrueType font.
* ```typescript
* // 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();
* ```
*/
export declare class PdfTrueTypeFont extends PdfFont {
/**
* Internal Unicode TrueType font handler.
*
* @private
*/
_fontInternal: _UnicodeTrueTypeFont;
/**
* Indicates whether the font should be embedded in the PDF.
*
* @private
*/
_isEmbedFont: boolean;
/**
* Indicates whether the font supports Unicode character mapping.
*
* @private
*/
_isUnicode: boolean;
/**
* Gets the boolean flag indicating whether the font has unicode or not.
*
* @returns {boolean} unicode.
*
* ```typescript
* // 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 });
* // Gets the boolean flag indicating whether the font has or not.
* let isUnicode: boolean = font.isUnicode;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isUnicode: boolean;
/**
* Gets the boolean flag indicating whether the font is embedded or not.
*
* @returns {boolean} isEmbed.
*
* ```typescript
* // 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 });
* // Gets the boolean flag indicating whether the font is embedded or not.
* let isEmbed: boolean = font.isEmbed;
* // Destroy the document
* document.destroy();
* ```
*/
readonly isEmbed: boolean;
/**
* Initializes a new instance of the `PdfTrueTypeFont` class.
*
* @param {Uint8Array} data Font data as byte array.
* @param {number} size Size.
* ```typescript
* // 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 = new PdfTrueTypeFont(data, 10);
* // 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();
* ```
*/
constructor(data: Uint8Array, size: number);
/**
* Initializes a new instance of the `PdfTrueTypeFont` class.
*
* @param {string} base64String Base64String.
* @param {number} size Size.
* ```typescript
* // 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 = new PdfTrueTypeFont(base64String, 10);
* // 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();
* ```
*/
constructor(base64String: string, size: number);
/**
* Initializes a new instance of the `PdfTrueTypeFont` class.
*
* @param {string} base64String Base64String.
* @param {number} size Font size.
* @param {style} style Font style.
* ```typescript
* // 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 = new PdfTrueTypeFont(base64String, 10, PdfFontStyle.regular);
* // 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);
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*/
constructor(base64String: string, size: number, style: PdfFontStyle);
/**
* Initializes a new instance of the `PdfTrueTypeFont` class.
*
* @param {Uint8Array} data Font data as byte array.
* @param {number} size Font size.
* @param {style} style Font style.
* ```typescript
* // 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 = new PdfTrueTypeFont(data, 10, PdfFontStyle.regular);
* // Create a new PDF string format
* let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
* // Draw the text
* page.graphics.drawString('Syncfusion', 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();
* ```
*/
constructor(data: Uint8Array, size: number, style: PdfFontStyle);
/**
* Initializes a new instance of the `PdfTrueTypeFont` class.
*
* @private
* @param {Uint8Array} data The Font data as byte array.
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @param {_PdfFontPrimitive} primitive The Font primitive.
*/
constructor(data: Uint8Array, size: number, style: PdfFontStyle, primitive: _PdfFontPrimitive);
/**
* Gets the line width.
*
* ```typescript
* // 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);
* // Get the text width
* let width: number = font.getLineWidth('Syncfusion', format);
* // Save the document
* document.save('output.pdf');
* // Destroy the document
* document.destroy();
* ```
*
* @param {string} line Line.
* @param {PdfStringFormat} format String format.
* @returns {number} width.
*/
getLineWidth(line: string, format: PdfStringFormat): number;
/**
* Gets a variant of the current font with the specified size and style.
*
* ```typescript
* // 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 });
* // Gets a font variant from the base font with the given size and style
* const titleFont: PdfTrueTypeFont = 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();
* ```
*
* @param {number} size The Font size.
* @param {PdfFontStyle} style The Font style.
* @returns {PdfTrueTypeFont} The Font object.
*/
getFont(size: number, style?: PdfFontStyle): PdfTrueTypeFont;
/**
* Builds the internal TrueType font structures from data or a primitive and sets metrics.
*
* @private
* @param {string | Uint8Array} data Font data or base64 string.
* @param {PdfFontStyle} style Font style.
* @param {_PdfFontPrimitive} [primitive] Font primitive.
* @returns {void} nothing.
*/
_createFontInternal(data: string | Uint8Array, style: PdfFontStyle, primitive?: _PdfFontPrimitive): void;
/**
* Finalizes TrueType font internals and assigns metrics and dictionary.
*
* @private
* @returns {void} nothing.
*/
_initializeInternals(): void;
/**
* Extracts ascent, descent, height, and line gap values from TrueType font metrics.
*
* @private
* @returns {void} nothing.
*/
_handleMetrics(): void;
/**
* Measures a Unicode text run using glyph indices and glyph widths.
*
* @private
* @param {string} line Text to measure.
* @param {number} width Initial width accumulator.
* @returns {number} measuredWidth.
*/
_getUnicodeLineWidth(line: string, width: number): number;
/**
* Measures a single character width scaled by the effective font size.
*
* @private
* @param {string} charCode Character to measure.
* @param {PdfStringFormat} format String format.
* @returns {number} width.
*/
_getCharacterWidth(charCode: string, format: PdfStringFormat): number;
/**
* Registers the given text for glyph collection in the internal Unicode font.
*
* @private
* @param {string} text Text.
* @returns {void} nothing.
*/
_setSymbols(text: string): void;
/**
* Looks up the character width for a code point using the internal width table.
*
* @private
* @param {string} charCode Character code.
* @returns {number} width.
*/
_getCharacterWidthInternal(charCode: string): number;
}
/**
* Provides metrics and width tables for standard fourteen fonts.
*
* @private
*/
export declare class _PdfStandardFontMetricsFactory {
/**
* Scale factor used to compute subscript and superscript sizes.
*
* @private
*/
static readonly _subSuperScriptFactor: number;
/**
* Ascent metric for Helvetica regular.
*
* @private
*/
static readonly _helveticaAscent: number;
/**
* Descent metric for Helvetica regular.
*
* @private
*/
static readonly _helveticaDescent: number;
/**
* PostScript family name for Helvetica regular.
*
* @private
*/
static readonly _helveticaName: string;
/**
* Ascent metric for Helvetica bold.
*
* @private
*/
static readonly _helveticaBoldAscent: number;
/**
* Descent metric for Helvetica bold.
*
* @private
*/
static readonly _helveticaBoldDescent: number;
/**
* PostScript family name for Helvetica bold.
*
* @private
*/
static readonly _helveticaBoldName: string;
/**
* Ascent metric for Helvetica italic (oblique).
*
* @private
*/
static readonly _helveticaItalicAscent: number;
/**
* Descent metric for Helvetica italic (oblique).
*
* @private
*/
static readonly _helveticaItalicDescent: number;
/**
* PostScript family name for Helvetica italic .
*
* @private
*/
static readonly _helveticaItalicName: string;
/**
* Ascent metric for Helvetica bold italic.
*
* @private
*/
static readonly _helveticaBoldItalicAscent: number;
/**
* Descent metric for Helvetica bold italic.
*
* @private
*/
static readonly _helveticaBoldItalicDescent: number;
/**
* PostScript family name for Helvetica bold italic.
*
* @private
*/
static readonly _helveticaBoldItalicName: string;
/**
* Ascent metric for Courier regular.
*
* @private
*/
static readonly _courierAscent: number;
/**
* Descent metric for Courier regular.
*
* @private
*/
static readonly _courierDescent: number;
/**
* PostScript family name for Courier regular.
*
* @private
*/
static readonly _courierName: string;
/**
* Ascent metric for Courier bold.
*
* @private
*/
static readonly _courierBoldAscent: number;
/**
* Descent metric for Courier bold.
*
* @private
*/
static readonly _courierBoldDescent: number;
/**
* PostScript family name for Courier bold.
*
* @private
*/
static readonly _courierBoldName: string;
/**
* Ascent metric for Courier italic (oblique).
*
* @private
*/
static readonly _courierItalicAscent: number;
/**
* Descent metric for Courier italic (oblique).
*
* @private
*/
static readonly _courierItalicDescent: number;
/**
* PostScript family name for Courier italic (oblique).
*
* @private
*/
static readonly _courierItalicName: string;
/**
* Ascent metric for Courier bold italic.
*
* @private
*/
static readonly _courierBoldItalicAscent: number;
/**
* Ascent metric for Courier bold italic.
*
* @private
*/
static readonly _courierBoldItalicDescent: number;
/**
* PostScript family name for Courier bold italic.
*
* @private
*/
static readonly _courierBoldItalicName: string;
/**
* Ascent metric for Times Roman regular.
*
* @private
*/
static readonly _timesAscent: number;
/**
* Descent metric for Times Roman regular.
*
* @private
*/
static readonly _timesDescent: number;
/**
* PostScript family name for Times Roman regular.
*
* @private
*/
static readonly _timesName: string;
/**
* Ascent metric for Times bold.
*
* @private
*/
static readonly _timesBoldAscent: number;
/**
* Descent metric for Times bold.
*
* @private
*/
static readonly _timesBoldDescent: number;
/**
* PostScript family name for Times bold.
*
* @private
*/
static readonly _timesBoldName: string;
/**
* Ascent metric for Times italic.
*
* @private
*/
static readonly _timesItalicAscent: number;
/**
* Descent metric for Times italic.
*
* @private
*/
static readonly _timesItalicDescent: number;
/**
* PostScript family name for Times italic.
*
* @private
*/
static readonly _timesItalicName: string;
/**
* Ascent metric for Times bold italic.
*
* @private
*/
static readonly _timesBoldItalicAscent: number;
/**
* Descent metric for Times bold italic.
*
* @private
*/
static readonly _timesBoldItalicDescent: number;
/**
* PostScript family name for Times bold italic.
*
* @private
*/
static readonly _timesBoldItalicName: string;
/**
* Ascent metric for Symbol.
*
* @private
*/
static readonly _symbolAscent: number;
/**
* Descent metric for Symbol.
*
* @private
*/
static readonly _symbolDescent: number;
/**
* PostScript family name for Symbol.
*
* @private
*/
static readonly _symbolName: string;
/**
* Ascent metric for ZapfDingbats.
*
* @private
*/
static readonly _zapfDingbatsAscent: number;
/**
* Descent metric for ZapfDingbats.
*
* @private
*/
static readonly _zapfDingbatsDescent: number;
/**
* PostScript family name for ZapfDingbats.
*
* @private
*/
static readonly _zapfDingbatsName: string;
/**
* Width table for Arial (used for Helvetica-compatible metrics).
*
* @private
*/
static _arialWidth: number[];
/**
* Width table for Arial bold.
*
* @private
*/
static _arialBoldWidth: number[];
/**
* Fixed-width table used for Courier.
*
* @private
*/
static _fixedWidth: number[];
/**
* Width table for Times Roman regular.
*
* @private
*/
static _timesRomanWidth: number[];
/**
* Width table for Times Roman bold.
*
* @private
*/
static _timesRomanBoldWidth: number[];
/**
* Width table for Times Roman Italic.
*
* @private
*/
static _timesRomanItalicWidth: number[];
/**
* Width table for Times Roman Bold Italic.
*
* @private
*/
static _timesRomanBoldItalicWidths: number[];
/**
* Width table for Symbol font.
*
* @private
*/
static _symbolWidth: number[];
/**
* Width table for ZapfDingbats font.
*
* @private
*/
static _zapfDingbatsWidth: number[];
/**
* Provides metrics and width tables for standard fourteen fonts.
*
* @private
* @param {PdfFontFamily} fontFamily Standard font family.
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getMetrics(fontFamily: PdfFontFamily, fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns Helvetica metrics and width table for the given style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getHelveticaMetrics(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns Courier metrics and width table for the given style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getCourierMetrics(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns Times metrics and width table for the given style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getTimesMetrics(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns Symbol metrics and width table.
*
* @private
* @returns {_PdfFontMetrics} metrics.
*/
static _getSymbolMetrics(): _PdfFontMetrics;
/**
* Returns ZapfDingbats metrics and width table.
*
* @private
* @returns {_PdfFontMetrics} metrics.
*/
static _getZapfDingbatsMetrics(): _PdfFontMetrics;
}
/**
* Provides metrics and width tables for common CJK standard fonts.
*
* @private
*/
export declare class _PdfCjkStandardFontMetricsFactory {
/**
* Scale factor used to compute subscript and superscript sizes for CJK fonts.
*
* @private
*/
static readonly _subSuperScriptFactor: number;
/**
* Returns metrics for the hanyang systems gothic medium family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getHanyangSystemsGothicMedium(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the hanyang systems shin myeong jo medium family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getHanyangSystemsShinMyeongJoMedium(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the heisei kaku gothic w5 family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getHeiseiKakuGothicW5(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the heisei mincho w3 family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getHeiseiMinchoW3(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the monotype hei medium family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getMonotypeHeiMedium(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the monotype sung light family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getMonotypeSungLight(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the sino type song light family and style.
*
* @private
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getSinoTypeSongLight(fontStyle: PdfFontStyle): _PdfFontMetrics;
/**
* Returns metrics for the requested CJK family and style.
*
* @private
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {PdfFontStyle} fontStyle Font style.
* @returns {_PdfFontMetrics} metrics.
*/
static _getMetrics(fontFamily: PdfCjkFontFamily, fontStyle: PdfFontStyle): _PdfFontMetrics;
}
/**
* Builds font descriptor dictionaries for CJK standard fonts.
*
* @private
*/
export declare class _PdfCjkFontDescriptorFactory {
/**
* Populates descriptor entries for the monotype sung light family.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillMonotypeSungLight(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the heisei kaku gothic w5 family using style specific box.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfFontStyle} fontStyle Font style.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillHeiseiKakuGothicW5(fontDescriptor: _PdfDictionary, fontStyle: PdfFontStyle, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the hanyang systems shin myeong jo medium family.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillHanyangSystemsShinMyeongJoMedium(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the heisei mincho w3 family.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillHeiseiMinchoW3(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the sino type song light family.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillSinoTypeSongLight(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the monotype hei medium family.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillMonotypeHeiMedium(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Populates descriptor entries for the hanyang systems gothic medium family and sets common flags.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillHanyangSystemsGothicMedium(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Writes the font bounding box to the descriptor.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {{x: number, y: number, width: number, height: number}} fontBox Font bounding box.
* @param {number} fontBox.x X coordinate.
* @param {number} fontBox.y Y coordinate.
* @param {number} fontBox.width Width.
* @param {number} fontBox.height Height.
* @returns {void} nothing.
*/
static _fillFontBox(fontDescriptor: _PdfDictionary, fontBox: {
x: number;
y: number;
width: number;
height: number;
}): void;
/**
* Writes common descriptor fields including names, flags, ascent, descent, and widths.
*
* @private
* @param {_PdfDictionary} fontDescriptor Font descriptor dictionary.
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {void} nothing.
*/
static _fillKnownInformation(fontDescriptor: _PdfDictionary, fontFamily: PdfCjkFontFamily, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): void;
/**
* Creates and returns a descriptor dictionary for the requested CJK family and style.
*
* @private
* @param {PdfCjkFontFamily} fontFamily CJK font family.
* @param {PdfFontStyle} fontStyle Font style.
* @param {_PdfFontMetrics} fontMetrics Font metrics.
* @param {number} ascent Ascent value.
* @param {number} descent Descent value.
* @returns {_PdfDictionary} fontDescriptor.
*/
static _getFontDescriptor(fontFamily: PdfCjkFontFamily, fontStyle: PdfFontStyle, fontMetrics: _PdfFontMetrics, ascent: number, descent: number): _PdfDictionary;
}
/**
* Public enum to define font style.
* ```typescript
* // 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();
* ```
*/
export declare enum PdfFontStyle {
/**
* Specifies the font style `regular`.
*/
regular = 0,
/**
* Specifies the font style `bold`.
*/
bold = 1,
/**
* Specifies the font style `italic`.
*/
italic = 2,
/**
* Specifies the font style `underline`.
*/
underline = 4,
/**
* Specifies the font style `strikeout`.
*/
strikeout = 8
}
/**
* Public enum to define font family.
* ```typescript
* // 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();
* ```
*/
export declare enum PdfFontFamily {
/**
* Specifies the `helvetica` font family.
*/
helvetica = 0,
/**
* Specifies the `courier` font family.
*/
courier = 1,
/**
* Specifies the `timesRoman` font family.
*/
timesRoman = 2,
/**
* Specifies the `symbol` font family.
*/
symbol = 3,
/**
* Specifies the `zapfDingbats` font family.
*/
zapfDingbats = 4
}
/**
* Public enum to define CJK font family.
* ```typescript
* // 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 CJK standard font
* let font: PdfCjkStandardFont = document.embedFont(PdfCjkFontFamily.heiseiMinchoW3, 20, PdfFontStyle.regular, true);
* // Create a new PDF string format
* let format: PdfStringFormat = new PdfStringFormat(PdfTextAlignment.right, PdfVerticalAlignment.bottom);
* // Draw the text
* page.graphics.drawString('こんにちは世界', 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();
* ```
*/
export declare enum PdfCjkFontFamily {
/**
* Specifies the `heiseiKakuGothicW5` CJK font family.
*/
heiseiKakuGothicW5 = 0,
/**
* Specifies the `heiseiMinchoW3` CJK font family.
*/
heiseiMinchoW3 = 1,
/**
* Specifies the `hanyangSystemsGothicMedium` CJK font family.
*/
hanyangSystemsGothicMedium = 2,
/**
* Specifies the `hanyangSystemsShinMyeongJoMedium` CJK font family.
*/
hanyangSystemsShinMyeongJoMedium = 3,
/**
* Specifies the `monotypeHeiMedium` CJK font family.
*/
monotypeHeiMedium = 4,
/**
* Specifies the `monotypeSungLight` CJK font family.
*/
monotypeSungLight = 5,
/**
* Specifies the `sinoTypeSongLight` CJK font family.
*/
sinoTypeSongLight = 6
}
/**
* Represents unicode shaping result with glyph index collection and status.
*
* @private
*/
export declare class _UnicodeLine {
/**
* Indicates whether the line shaping/measurement operation produced a valid result.
*
* @private
*/
_result: boolean;
/**
* Holds the sequence of glyph indices that compose this line (in logical order).
*
* @private
*/
_glyphIndex: number[];
}
/**
* Describes the internal font data selection for standard CJK or truetype.
*
* @private
*/
export declare type _FontData = {
type: 'standard';
family: PdfFontFamily;
style: PdfFontStyle;
} | {
type: 'cjk';
family: PdfCjkFontFamily;
style: PdfFontStyle;
} | {
type: 'ttf';
data: Uint8Array;
};
/**
* Bundles the internal font dictionary metrics and optional truetype engine for reuse.
*
* @private
*/
export declare type _PdfFontPrimitive = {
dictionary: _PdfDictionary;
metrices: _PdfFontMetrics;
fontInternal?: _UnicodeTrueTypeFont;
};