constructor(options?: any): PdfDocument
Initializes a new instance of the PdfDocument class.
An optional object containing initialization settings.
Gets a value that indicates whether the pages buffering mode is enabled which means that the document's pages can be iterated over using pageIndex and bufferedPageRange.
This property can be assigned using the PdfDocument constructor only. This property can be set to false only if both header and footer are invisible.
The default value is true.
Gets a value that indicates whether the document compression is enabled. This property can be assigned using the PdfDocument constructor only.
The default value is true.
Gets an object that represents the current page settings (read-only).
Gets an object that represents a header, the page area positioned right below the top margin.
Gets or sets the document information, such as author name, document's creation date and so on.
Gets or sets the spacing between each line of text, in points.
The default value is 0.
Gets or sets the index of the current page within the buffered pages range.
Use the bufferedPageRange method to get the range of buffered pages.
Gets an object that represents the default page settings for the pages added automatically and for the addPage method.
Gets or sets the X-coordinate (in points) of the current point in the text flow used to draw a text or an image.
Gets or sets the Y-coordinate (in points) of the current point in the text flow used to draw a text or an image.
addPage(settings?: IPdfPageSettings): PdfDocument
Adds a new page with the given settings.
If the settings parameter is omitted, then pageSettings will be used instead.
Page settings.
bufferedPageRange(): IPdfBufferedPageRange
Gets the range of buffered pages.
dispose(): void
Disposes the document.
drawImage(url: string, x?: number, y?: number, options?: IPdfImageDrawSettings): PdfPageArea
Draws an image in JPG or PNG format with the given options.
If x and y are not defined, then @see:x and @see:y are used instead.
Finally, if the image was drawn in the text flow, the method updates @see:y. Hence, any subsequent text or image starts below this point.
A string containing the URL to get the image from or the data URI containing a base64 encoded image.
The x-coordinate of the point to draw the image at, in points.
The y-coordinate of the point to draw the image at, in points.
Determines the image drawing options.
drawSvg(url: string, x?: number, y?: number, options?: IPdfSvgDrawSettings): PdfPageArea
Draws a SVG image with the given options.
If x and y are not defined, then @see:x and @see:y are used instead.
The method uses the values of the width and height attributes of the outermost svg element to determine the scale factor according to the options.width and options.height properties. If any of these attributes are omitted then scaling is not performed and the image will be rendered in its original size.
Finally, if the image was drawn in the text flow, the method updates @see:y. Hence, any subsequent text or image starts below this point. The increment value is defined by the options.height property or by the outermost svg element's height attribute, which comes first. If none of them is provided then @see:y will stay unchanged.
The method supports a limited set of SVG features and provided primarily for rendering wijmo 5 chart controls.
A string containing the URL to get the SVG image from or the data URI containing a base64 encoded SVG image.
The x-coordinate of the point to draw the image at, in points.
The y-coordinate of the point to draw the image at, in points.
Determines the SVG image drawing options.
drawText(text: string, x?: number, y?: number, options?: IPdfTextDrawSettings): IPdfTextMeasurementInfo
Draws a string with the given options and returns the measurement information.
If options.pen, options.brush or options.font are omitted, the current document's pen, brush or font are used (see setPen, setBrush, and setFont).
The string is drawn within the rectangular area for which top-left corner, width and height are defined by the x, y, options.width and options.height values. If x and y are not provided, the x and y properties are used instead.
The text is wrapped and clipped automatically within the area. If options.height is not provided and the text exceeds the bottom body edge, then a new page will be added to accommodate the text.
Finally, the method updates the value of the x and y properties. Hence, any subsequent text or image starts below this point (depending on the value of options.continued).
The measurement result doesn't reflect the fact that text can be split into multiple pages or columns; the text is treated as a single block.
The text to draw.
The X-coordinate of the point to draw the text at, in points.
The Y-coordinate of the point to draw the text at, in points.
Determines the text drawing options.
end(): void
Finishes the document rendering.
lineHeight(font?: PdfFont): number
Gets the line height with a given font.
If font is not specified, then font used in the current document is used.
Font to get the line height.
measureText(text: string, font?: PdfFont, options?: IPdfTextSettings): IPdfTextMeasurementInfo
Measures a text with the given font and text drawing options without rendering it.
If font is not specified, then the font used in the current document is used.
The method uses the same text rendering engine as drawText, so it is tied up in the same way to @see:x and the right page margin, if options.width is not provided. The measurement result doesn't reflect the fact that text can be split into multiple pages or columns; the text is treated as a single block.
Text to measure.
Font to be applied on the text.
Determines the text drawing options.
moveDown(lines?: number, font?: PdfFont): PdfPageArea
Moves down the @see:y by a given number of lines using the given font or, using the font of current document, if not specified.
Number of lines to move down.
Font to calculate the line height.
moveUp(lines?: number, font?: PdfFont): PdfPageArea
Moves up the @see:y by a given number of lines using the given font or, using the font of current document, if not specified.
Number of lines to move up.
Font to calculate the line height.
onEnded(args: PdfDocumentEndedEventArgs): void
Raises the end event.
A PdfDocumentEndedEventArgs object that contains the event data.
registerFont(font: IPdfFontFile): PdfDocument
Registers a font from a source and associates it with a given font family name and font attributes.
The font to register.
registerFontAsync(font: IPdfFontFile, callback: Function): void
Registers a font from a URL asynchronously and associates it with a given font family name and font attributes.
The callback function takes a IPdfFontFile object as a parameter.
The font to register.
A callback function which will be called, when the font has been registered.
restoreState(): PdfDocument
Restores the state from the stack and applies it to the graphic context.
rotate(angle: number, origin?: Point): PdfPageArea
Rotates the graphic context clockwise by a specified angle.
The rotation angle, in degrees.
The Point of rotation, in points. If it is not provided, then the top left corner is used.
saveState(): PdfDocument
Saves the state of the graphic context (including current pen, brush and transformation state) and pushes it onto stack.
scale(xFactor: number, yFactor?: number, origin?: Point): PdfPageArea
Scales the graphic context by a specified scaling factor.
The scaling factor value within the range [0, 1] indicates that the size will be decreased. The scaling factor value greater than 1 indicates that the size will be increased.
The factor to scale the X dimension.
The factor to scale the Y dimension. If it is not provided, it is assumed to be equal to xFactor.
The Point to scale around, in points. If it is not provided, then the top left corner is used.
setBrush(brushOrColor: any): PdfDocument
Sets the default document brush. This brush will be used by the fill, fillAndStroke and drawText methods, if no specific brush is provided.
The brushOrColor argument can accept the following values:
The brush or color to use.
setFont(font: PdfFont): PdfDocument
Sets the document font. If exact font with given style and weight properties is not found then,
The font object to set.
setPen(penOrColor: any): PdfDocument
Sets the default document pen. This pen will be used by the stroke, fillAndStroke and drawText methods, if no specific pen is provided.
The penOrColor argument can accept the following values:
The pen or color to use.
transform(a: number, b: number, c: number, d: number, e: number, f: number): PdfPageArea
Transforms the graphic context with given six numbers which represents a 3x3 transformation matrix.
A transformation matrix is written as follows:
| a | b | 0 |
| c | d | 0 |
| e | f | 1 |
Value of the first row and first column.
Value of the first row and second column.
Value of the second row and first column.
Value of the second row and second column.
Value of the third row and first column.
Value of the third row and second column.
translate(x: number, y: number): PdfPageArea
Translates the graphic context with a given distance.
The distance to translate along the X-axis, in points.
The distance to translate along the Y-axis, in points.
Represents a PDF document object, based on PDFKit JavaScript library.