import { PdfixSdk, PdfDoc } from 'PDFIX_WASM';
export { PdfixSdk };

interface PdfixRenderPageClipBox {
  left: number;
  top: number;
  right: number;
  bottom: number;
}

/**
 * PDFix SDK module.
 * @module pdfix-sdk
 */
declare module 'pdfix-sdk' {

  /**
   * PDFix SDK module class wrapper.
   * @class
   */
  class Pdfix {
    constructor();

    /**
     * The PDFix Plugin.
     * @member {PdfixSdk} pdfixWasm
     */
    pdfixWasm: PdfixSdk;

    /**
     * Initializes and loads the PDFix SDK.
     * @async
     * @method loadPdfixSdk
     * @param {null | string} binaryPath Optional. Path to the wasm binary file. Useful to handle loading of wasm file in web environment.
     * @returns {Promise<PdfixSdk>}
     */
    loadPdfixSdk(binaryPath?: null | string): Promise<PdfixSdk>;
    
    /**
     * Gets the PDFix SDK.
     * Assuming it was loaded before.
     * @method getPdfixSdk
     * @returns {PdfixSdk}
     */
    getPdfixSdk(): PdfixSdk;
    
    /**
     * Opens a PDF document from path.
     * For the use in NodeJs.
     * @method openDocumentFromPath
     * @param {string} path
     * @returns {PdfDoc}
     */
    openDocumentFromPath(path: string): PdfDoc;

    /**
     * Opens a PDF document from URL.
     * @async
     * @method openDocumentFromUrl
     * @param {string} url
     * @returns {Promise<PdfDoc>}
     */
    openDocumentFromUrl(url: string): Promise<PdfDoc>;

    /**
     * Opens a PDF document from buffer.
     * @method openDocumentFromBuffer
     * @param {Uint8Array} fileBuffer
     * @param {string} password
     * @returns {PdfDoc}
     */
    openDocumentFromBuffer(fileBuffer: Uint8Array, password?: string): PdfDoc;

    /**
     * Renders a page or a region of the page defined by box.
     * @method renderPage
     * @param {PdfDoc} pdfDoc
     * @param {number} pageNumber Pages are zero-based. Default is 0.
     * @param {number} zoom Default is 1.
     * @param {number} rotation Default is 0.
     * @param {PdfixRenderPageClipBox} box Optional clip box.
     * @returns {Blob} The rendered image Blob.
     */
    renderPage(pdfDoc: any, pageNumber?: number, zoom?: number, rotation?: number, box?: PdfixRenderPageClipBox): Blob;
  }

  export = Pdfix;

} // npm-end