Implements

Constructors

  • No longer use 'new' to create, but use create instead.

    Parameters

    • Optionaloptions: Options

      Configuration options containing necessary initialization information.

    Returns Doc

     const doc = await Doc.create();
    

Properties

options: Options

Methods

  • Invalidates all modification.

    Returns Promise<void>

    • TRUE if the operation is successful, otherwise not.
  • Closes the doc object.

    Parameters

    • options: CloseOptions = ...

      Close parameters, default values: {'promptToSave': true, 'showCancel': true}

    Returns Promise<boolean>

    • Result of the close operation
  • Creates a button form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created button form field.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const buttonForm = await doc.createButtonForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MyButton'
    });
    console.log(buttonForm); // Button form field
  • Creates a checkbox form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created checkbox form field.
  • Creates a combobox form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created combobox form field.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const comboboxForm = await doc.createComboxForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MyComboBox'
    });
    console.log(comboboxForm); // Combobox form field
  • Creates a listbox form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created listbox form field.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const listboxForm = await doc.createListboxForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MyListBox'
    });
    console.log(listboxForm); // Listbox form field
  • Creates a radio button form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created radio button form field.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const radioButtonForm = await doc.createRadioButtonForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MyRadioButton'
    });
    console.log(radioButtonForm); // Radio button form field
  • Creates a signature form field.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created signature form field.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const signatureForm = await doc.createSignatureForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MySignature'
    });
    console.log(signatureForm); // Signature form field
  • Creates a text field form.

    Parameters

    • __namedParameters: { name: string; pageIndex: number; rect: Rect; rotate?: number }

    Returns Promise<null | AnnotType>

    • The created text field form.
    const doc = await app.getActiveDoc();
    const pageIndex = await doc.getCurrentPageIndex();
    const rect = {
    left: 200,
    top: 550,
    right: 300,
    bottom: 500
    };
    const textFieldForm = await doc.createTextFieldForm({
    pageIndex,
    rect,
    rotate: 0,
    name: 'MyTextField'
    });
    console.log(textFieldForm); // Text field form
  • Destroys the document object.

    Returns Promise<void>

  • print the current document.

    Returns Promise<void>

  • Performs the print operation, not including user dialog box.

    Returns Promise<void>

  • Saves the document.

    Parameters

    • options: SaveDocOptionType

      The save options object.

      Save document options.

      • OptionaldocPDFOptimizer?: boolean

        Indicates whether to enable the document PDF optimizer.

      • OptionalpromptInfo?: boolean

        Indicates whether to prompt information.

      • OptionalsaveAsTempFile?: boolean

        Indicates whether to save the document as a temporary file.

      • OptionalshowProgressBar?: boolean

        Indicates whether to display the progress bar.

    Returns Promise<boolean>

  • Saves the document as another file by prompting a file dialog box to specify the saving path before saving.

    Returns Promise<void>

  • Extracts pages from the current document.

    Parameters

    • extraPageArr: number[]

      An array of page numbers to extract.

    • savPath: string

      The path to save the extracted pages.

    Returns Promise<boolean>

    A Promise that resolves to true if the extraction operation is successful, otherwise false.

    const doc = await app.getActiveDoc();
    const result = await doc.extractPages([0, 1, 2], 'D:\\test\\extract\\extract.pdf');
    console.log(result); // true
  • Get the current page index

    Returns Promise<number>

  • Gets the filename.

    Returns Promise<string>

    • The filename.
  • Gets the specified Page from specified document.

    Parameters

    • index: number

      The page index, starting from 0.

    Returns Promise<null | PageType>

    • The specified Page.
  • Get the number of pages in the document.

    Returns Promise<number>

    • The number of pages in the document.
  • Insert pages from one document into another at a specified position.

    Parameters

    Returns Promise<boolean>

    A promise that resolves to true if the insertion was successful, otherwise false.

  • Checks whether the document is modified.

    Returns Promise<boolean>

    • TRUE if the document is modified, otherwise not.
  • Print document from specific page range

    Parameters

    • firstPage: number

      Starting page index (0-based)

    • lastPage: number

      Ending page index (0-based)

    Returns Promise<void>

  • Open the print dialog for the current document.

    Returns Promise<void>

  • Reloads the specified page, used to refresh page view.

    Parameters

    • pageIndex: number

      The specified page index.

    • disableGoto: boolean = false

      Whether to prevent going to the specified page view. Sets it FALSE as default.

    Returns Promise<boolean>

    • TRUE if the operation is successful, otherwise not.
  • Remove header and footer without updating document view.

    Parameters

    • specifyHeaderFooterDicValue: string

      Specified watermark DictValue

    Returns Promise<boolean>

    • TRUE if the operation is successful, otherwise not.
  • Remove watermark without updating document view.

    Parameters

    • specifyWatermarkDicValue: string

      Specified watermark Dictionary Value

    Returns Promise<boolean>

  • Asynchronously replaces pages in the current PDF document.

    Parameters

    Returns Promise<boolean>

    A Promise that resolves to true if the replacement operation is successful, otherwise false.

  • Save the data of a PDF document.

    Parameters

    • srcFileName: string

      Output file name (e.g., D:\123.pdf)

    • flag: number = DefineConst.FPD_SAVE_DEFAULT

      Save flag, default is FPD_SAVE_DEFAULT (0)

    • enable: boolean = false

      Whether to enable data compression, default is false

    Returns Promise<boolean>

    • TRUE if the operation is successful, otherwise not.
  • Sets the modify flag. Reader has a built-in flag that indicate whether a document has been modified, if the value of the flag is valid, the Save button on File toolbar is enable, otherwise the Save button is disable.

    Returns Promise<void>

  • Creates a PDF document.

    Parameters

    • Optionaloptions: Options

      Configuration options containing necessary initialization information.

    Returns Promise<DocType>

    • A PDF document object.
     const doc = await Doc.create();