UNPKG

@coolgk/utils

Version:

javascript, typescript utility and wrapper functions and classes: array, string, base64, ampq, bcrypt, cache, captcha, csv, email, jwt, number, pdf, tmp, token, unit conversion, url params, session, form data, google sign in, facebook sign in

71 lines (69 loc) 1.94 kB
/*! * @package @coolgk/utils * @version 3.1.4 * @link https://github.com/coolgk/node-utils * @license MIT * @author Daniel Gong <daniel.k.gong@gmail.com> * * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved. * Licensed under the MIT License. */ /*! * Copyright (c) 2017 Daniel Gong <daniel.k.gong@gmail.com>. All rights reserved. * Licensed under the MIT License. */ declare module 'phantom' { interface PhantomJS { callback: (data: any) => any; } } import * as phantom from 'phantom'; import * as tmp from '@coolgk/tmp'; export interface IPdfConfig { readonly phantom?: typeof phantom; readonly tmp?: typeof tmp; readonly tmpConfig?: tmp.ITmpConfig; } export declare enum Orientation { Portrait = "portrait", Landscape = "landscape", } export declare enum Format { A3 = "A3", A4 = "A4", A5 = "A5", Legal = "Legal", Letter = "Letter", Tabloid = "Tabloid", } export interface ICreateConfig { readonly pdfFilePath?: string; readonly delay?: number; readonly orientation?: Orientation; readonly format?: Format; readonly margin?: number | string | { top: number | string; left: number | string; bottom: number | string; right: number | string; }; readonly header?: string | { height: string; contents: string; }; readonly footer?: string | { height: string; contents: string; }; readonly dpi?: number; } export declare class Pdf { private _phantom; private _tmp; private _tmpConfig; constructor(options?: IPdfConfig); createFromHtmlFile(htmlFilePath: string, {pdfFilePath, delay, margin, orientation, format, header, footer, dpi}?: ICreateConfig): Promise<string>; createFromHtmlString(htmlString: string, options?: ICreateConfig): Promise<string>; private _getHeaderFooter(html?); } export default Pdf;