UNPKG

@ztimson/momentum

Version:

Client library for momentum

68 lines 2.32 kB
import { PathEventEmitter } from './core'; import { Momentum } from './momentum'; import { RenderTemplate } from './templates'; /** Options when creating a PDF */ export type PdfOptions = { /** Use cookies while loading URL */ cookies?: { name: string; value: string; domain?: string; path?: string; }[]; /** Display page header/footer (The URL, page count, etc) */ displayHeaderFooter?: boolean; /** Wait for x'ms of idle network traffic before creating PDF */ idleTime?: number; /** Create the PDF in landscape orientation instead of portrait */ landscape?: boolean; /** PDF Page margins */ margin?: { top?: string; left?: string; right?: string; bottom?: string; }; /** Change the CSS media type */ mediaType?: 'screen' | 'print'; /** Enable background colors */ printBackground?: boolean; /** Max amount of time request will wait before timing out */ timeout?: number; /** Wait for custom dom event before continuing */ waitForEvent?: string; /** Wait for builtin dom events before continuing */ waitUntil?: string[]; /** Download automatically with name */ downloadAs?: string; /** Upload automatically to storage path */ uploadAs?: string; }; export declare class Pdf extends PathEventEmitter { protected momentum: Momentum; constructor(momentum: Momentum); private createPdf; /** * Create a PDF from raw HTML code * @param {string} html HTML code * @param {PdfOptions} options PDF rendering options * @return {Promise<Blob>} */ fromHtml(html: string, options?: PdfOptions): Promise<Blob>; /** * Create a PDF from a server template * @param {RenderTemplate} template Template path * @param {PdfOptions} options PDF rendering options * @return {Promise<Blob>} */ fromTemplate(template: RenderTemplate, options?: PdfOptions): Promise<Blob>; /** * Create PDF from a public URL * @param {string} url HTTP(s) URL * @param {PdfOptions} options PDF rendering option * @return {Promise<Blob>} */ fromUrl(url: string, options?: PdfOptions): Promise<Blob>; toHtml(file?: File | null): Promise<string>; } //# sourceMappingURL=pdf.d.ts.map