ngx-print
Version:
Plug n' Play Angular (2++) directive to print your stuff
247 lines (240 loc) • 8 kB
TypeScript
import * as i0 from '@angular/core';
import * as rxjs from 'rxjs';
import { Subject } from 'rxjs';
declare class PrintOptions {
printSectionId: string;
printTitle: string;
useExistingCss: boolean;
bodyClass: string;
printMethod: 'window' | 'tab' | 'iframe';
previewOnly: boolean;
closeWindow: boolean;
printDelay: number;
constructor(options?: Partial<PrintOptions>);
}
declare class PrintBase {
private nonce;
private _iframeElement;
private _printStyle;
private _styleSheetFile;
protected printComplete: Subject<void>;
/**
* Sets the print styles based on the provided values.
*
* @param {Object} values - Key-value pairs representing print styles.
* @protected
*/
protected setPrintStyle(values: {
[key: string]: {
[key: string]: string;
};
}): void;
/**
*
*
* @returns the string that create the stylesheet which will be injected
* later within <style></style> tag.
*
* -join/replace to transform an array objects to css-styled string
*/
returnStyleValues(): string;
/**
* @returns string which contains the link tags containing the css which will
* be injected later within <head></head> tag.
*
*/
private returnStyleSheetLinkTags;
/**
* Sets the style sheet file based on the provided CSS list.
*
* @param {string} cssList - CSS file or list of CSS files.
* @protected
*/
protected setStyleSheetFile(cssList: string): void;
/**
* Updates the default values for input elements.
*
* @param {HTMLCollectionOf<HTMLInputElement>} elements - Collection of input elements.
* @private
*/
private updateInputDefaults;
/**
* Updates the default values for select elements.
*
* @param {HTMLCollectionOf<HTMLSelectElement>} elements - Collection of select elements.
* @private
*/
private updateSelectDefaults;
/**
* Updates the default values for textarea elements.
*
* @param {HTMLCollectionOf<HTMLTextAreaElement>} elements - Collection of textarea elements.
* @private
*/
private updateTextAreaDefaults;
/**
* Converts a canvas element to an image and returns its HTML string.
*
* @param {HTMLCanvasElement} element - The canvas element to convert.
* @returns {string} - HTML string of the image.
* @private
*/
private canvasToImageHtml;
/**
* Includes canvas contents in the print section via img tags.
*
* @param {HTMLCollectionOf<HTMLCanvasElement>} elements - Collection of canvas elements.
* @private
*/
private updateCanvasToImage;
/**
* Retrieves the HTML content of a specified printing section.
*
* @param {string} printSectionId - Id of the printing section.
* @returns {string | null} - HTML content of the printing section, or null if not found.
* @private
*/
private getHtmlContents;
/**
* Retrieves the HTML content of elements with the specified tag.
*
* @param {keyof HTMLElementTagNameMap} tag - HTML tag name.
* @returns {string} - Concatenated outerHTML of elements with the specified tag.
* @private
*/
private getElementTag;
protected notifyPrintComplete(): void;
/**
* Prints the specified content using the provided print options.
*
* @param {PrintOptions} printOptions - Options for printing.
* @public
*/
protected print(printOptions: PrintOptions): void;
protected printWithWindow(printOptions: PrintOptions): void;
private printWithIframe;
private prepareDocumentComponents;
private buildPrintDocument;
static ɵfac: i0.ɵɵFactoryDeclaration<PrintBase, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<PrintBase>;
}
declare class NgxPrintDirective extends PrintBase {
private printOptions;
/**
* Prevents the print dialog from opening on the window
*
* @memberof NgxPrintDirective
*/
set previewOnly(value: boolean);
/**
*
*
* @memberof NgxPrintDirective
*/
set printSectionId(value: string);
/**
*
*
* @memberof NgxPrintDirective
*/
set printTitle(value: string);
/**
*
*
* @memberof NgxPrintDirective
*/
set useExistingCss(value: boolean);
/**
* A delay in milliseconds to force the print dialog to wait before opened. Default: 0
*
* @memberof NgxPrintDirective
*/
set printDelay(value: number);
/**
* Whether to close the window after print() returns.
*
*/
set closeWindow(value: boolean);
/**
* Class attribute to apply to the body element.
*
*/
set bodyClass(value: string);
/**
* Which PrintMethod (iframe/window/tab) to use.
*
*/
set printMethod(value: typeof PrintOptions.prototype.printMethod);
/**
*
*
* @memberof NgxPrintDirective
*/
set printStyle(values: {
[key: string]: {
[key: string]: string;
};
});
/**
* @memberof NgxPrintDirective
* @param cssList
*/
set styleSheetFile(cssList: string);
/**
*
*
* @memberof NgxPrintDirective
*/
print(): void;
readonly printCompleted: i0.OutputEmitterRef<void>;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxPrintDirective, "[ngxPrint]", never, { "previewOnly": { "alias": "previewOnly"; "required": false; }; "printSectionId": { "alias": "printSectionId"; "required": false; }; "printTitle": { "alias": "printTitle"; "required": false; }; "useExistingCss": { "alias": "useExistingCss"; "required": false; }; "printDelay": { "alias": "printDelay"; "required": false; }; "closeWindow": { "alias": "closeWindow"; "required": false; }; "bodyClass": { "alias": "bodyClass"; "required": false; }; "printMethod": { "alias": "printMethod"; "required": false; }; "printStyle": { "alias": "printStyle"; "required": false; }; "styleSheetFile": { "alias": "styleSheetFile"; "required": false; }; }, { "printCompleted": "printCompleted"; }, never, never, true, never>;
}
declare class NgxPrintModule {
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxPrintModule, never, [typeof NgxPrintDirective], [typeof NgxPrintDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<NgxPrintModule>;
}
/**
* Service for handling printing functionality in Angular applications.
* Extends the base printing class (PrintBase).
*
* @export
* @class NgxPrintService
* @extends {PrintBase}
*/
declare class NgxPrintService extends PrintBase {
printComplete$: rxjs.Observable<void>;
/**
* Initiates the printing process using the provided print options.
*
* @param {PrintOptions} printOptions - Options for configuring the printing process.
* @memberof NgxPrintService
* @returns {void}
*/
print(printOptions: PrintOptions): void;
/**
* Sets the print style for the printing process.
*
* @param {{ [key: string]: { [key: string]: string } }} values - A dictionary representing the print styles.
* @memberof NgxPrintService
* @setter
*/
set printStyle(values: {
[key: string]: {
[key: string]: string;
};
});
/**
* Sets the stylesheet file for the printing process.
*
* @param {string} cssList - A string representing the path to the stylesheet file.
* @memberof NgxPrintService
* @setter
*/
set styleSheetFile(cssList: string);
static ɵfac: i0.ɵɵFactoryDeclaration<NgxPrintService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxPrintService>;
}
export { NgxPrintDirective, NgxPrintModule, NgxPrintService, PrintOptions };
//# sourceMappingURL=ngx-print.d.ts.map