import { StreamWriter } from '@phamloi/file-utils'; import { PdfDocumentBase } from './pdf-document-base'; import { PdfPageSettings, PdfSectionCollection, PdfDocumentPageCollection } from '../pages'; import { PdfCacheCollection } from '../general'; import { PdfColorSpace, PdfFont } from '../graphics'; import { PdfDocumentTemplate } from './pdf-document-template'; /** * Represents a PDF document and can be used to create a new PDF document from the scratch. * ```typescript * // create a new PDF document * let document : PdfDocument = new PdfDocument(); * // add a new page to the document * let page1 : PdfPage = document.pages.add(); * // set the font * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20); * // create black brush * let blackBrush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0)); * // draw the text * page1.graphics.drawString('Hello World', font, blackBrush, new PointF(0, 0)); * // save the document * document.save('output.pdf'); * // destroy the document * document.destroy(); * ``` */ export declare class PdfDocument extends PdfDocumentBase { /** * `Cache` of the objects. * @private */ private static cacheCollection; /** * Default `margin` value. * @default 40.0 * @private */ readonly defaultMargin: number; /** * Default page `settings`. * @private */ private settings; /** * Internal variable to store document`s collection of `sections`. * @private */ private sectionCollection; /** * Internal variable to store document`s collection of `pages`. * @private */ private documentPageCollection; /** * Internal variable to store instance of `StreamWriter` classes.. * @default null * @private */ streamWriter: StreamWriter; /** * Defines the `color space` of the document * @private */ private pdfColorSpace; /** * Internal variable to store `template` which is applied to each page of the document. * @private */ private pageTemplate; /** * `Font` used in complex objects to draw strings and text when it is not defined explicitly. * @default null * @private */ private static defaultStandardFont; /** * Indicates whether enable cache or not * @default true * @private */ private static isCacheEnabled; /** * Initializes a new instance of the `PdfDocument` class. * @public */ constructor(); /** * Initializes a new instance of the `PdfDocument` class. * @private */ constructor(isMerging: boolean); /** * Gets the `default font`. It is used for complex objects when font is not explicitly defined. * @private */ static get defaultFont(): PdfFont; /** * Gets the collection of the `sections` in the document. * @private */ get sections(): PdfSectionCollection; /** * Gets the document's page setting. * @public */ get pageSettings(): PdfPageSettings; /** * Sets the document's page setting. * ```typescript * // create a new PDF document * let document : PdfDocument = new PdfDocument(); * * // sets the right margin of the page * document.pageSettings.margins.right = 0; * // set the page size. * document.pageSettings.size = new SizeF(500, 500); * // change the page orientation to landscape * document.pageSettings.orientation = PdfPageOrientation.Landscape; * // apply 90 degree rotation on the page * document.pageSettings.rotate = PdfPageRotateAngle.RotateAngle90; * * // add a pages to the document * let page1 : PdfPage = document.pages.add(); * // set font * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20); * // set brush * let blackBrush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0)); * // set the specified Point * let point : PointF = new PointF(page1.getClientSize().width - 200, page1.getClientSize().height - 200); * // draw the text * page1.graphics.drawString('Hello World', font, blackBrush, point); * // save the document * document.save('output.pdf'); * // destroy the document * document.destroy(); * ``` */ set pageSettings(value: PdfPageSettings); /** * Represents the collection of pages in the PDF document. * ```typescript * // create a new PDF document * let document : PdfDocument = new PdfDocument(); * // * // get the collection of pages in the document * let pageCollection : PdfDocumentPageCollection = document.pages; * // * // add pages * let page1 : PdfPage = pageCollection.add(); * // save the document * document.save('output.pdf'); * // destroy the document * document.destroy(); * ``` */ get pages(): PdfDocumentPageCollection; /** * Gets collection of the `cached objects`. * @private */ static get cache(): PdfCacheCollection; /** * Sets collection of the `cached objects`. * @private */ static set cache(value: PdfCacheCollection); /** * Gets the value of enable cache. * @private */ static get enableCache(): boolean; /** * Sets thie value of enable cache. * @private */ static set enableCache(value: boolean); /** * Gets or sets the `color space` of the document. This property can be used to create PDF document in RGB, Gray scale or CMYK color spaces. * @private */ get colorSpace(): PdfColorSpace; set colorSpace(value: PdfColorSpace); /** * Gets or sets a `template` to all pages in the document. * @private */ get template(): PdfDocumentTemplate; set template(value: PdfDocumentTemplate); /** * Saves the document to the specified output stream and return the stream as Blob. * @private */ docSave(stream: StreamWriter, isBase: boolean): Blob; /** * Saves the document to the specified output stream. * @private */ docSave(stream: StreamWriter, filename: string, isBase: boolean): void; /** * Checks the pages `presence`. * @private */ private checkPagesPresence; /** * disposes the current instance of `PdfDocument` class. * ```typescript * // create a new PDF document * let document : PdfDocument = new PdfDocument(); * // add a new page to the document * let page1 : PdfPage = document.pages.add(); * // set the font * let font : PdfStandardFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20); * // create black brush * let blackBrush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(0, 0, 0)); * // draw the text * page1.graphics.drawString('Hello World', font, blackBrush, new PointF(0, 0)); * // save the document * document.save('output.pdf'); * // destroy the document * document.destroy(); * ``` */ destroy(): void; }