Implements

Constructors

  • Create a Page instance. Instead of creating an instance in new mode, use create to create an instance.

    Parameters

    • Optionaloptions: Options

      Create a Page instance with the specified options.

    Returns Page

    const page = await Page.create();
    

Properties

options: Options

Methods

  • Destroy the current object.

    Returns Promise<void>

  • Enumerate the bounding boxes of the objects on the page.

    Parameters

    • filterArr: any[]

      The filter array to specify which objects to include.

    Returns Promise<any[]>

    Returns an array of bounding boxes of the objects on the page.

  • Generate the content of the page.

    Returns Promise<void>

  • Get the bounding box of the page.

    Returns Promise<Rect>

    Return the bounding box of the page.

  • Get the document associated with the page.

    Returns Promise<null | DocType>

    Returns the document associated with the page.

  • Get the object by index.

    Parameters

    • index: number

      The index of the object to get.

    Returns Promise<null | PageObjectType>

    Return the PageObject at the specified index.

  • Get the number of objects on the page.

    Returns Promise<number>

    Return the number of objects on the page.

  • Get the index of the specified object.

    Parameters

    Returns Promise<number>

    Return the index of the specified object.

  • Get the page height.

    Returns Promise<number>

    Returns the height of the page.

  • Get the page rotation.

    Returns Promise<number>

    Returns the rotation of the page.

  • Get the page width.

    Returns Promise<number>

    Returns the width of the page.

  • Insert an object after the specified position.

    Parameters

    Returns Promise<null | POSITIONType>

    Return the position of the inserted object.

    let pos = await page.getLastObjectPosition();
    let newObj = await PageObject.create({type: 1});
    await page.insertObject(pos, newObj);
  • Check if the page has been parsed.

    Returns Promise<boolean>

    Return true if the page has been parsed, otherwise return false.

    let isParsed = await page.isParsed();
    if (!isParsed) {
    await page.parseContent();
    }
  • Construct a page. For saving memory, the page caching feature can be disabled, then images and masks used in page rendering won't be cached. Of course this will affect the speed.

    Parameters

    Returns Promise<void>

    let page = await Page.create();
    if (page === null) {
    throw new Error('Create page failed');
    }
    await page.load({doc: doc, pageDict: pageDict, pageCache: true});
  • Move the object from one position to another.

    Parameters

    • position: POSITIONType

      The position of the object to be moved.

    • newPosAfter: POSITIONType

      The new position after which the object is moved.

    Returns Promise<null | POSITIONType>

    A promise that resolves to the new position of the moved object.

  • Batch update the opacity of the specified objects.

    Parameters

    • objectIdArr: string[]
    • opacity: number

      The opacity value to set (0-100).

    Returns Promise<boolean>

    Returns true if the operation was successful.

  • Remove the object at the specified position.

    Parameters

    • position: POSITIONType

      The position of the object to be removed.

    Returns Promise<void>

    A promise that resolves when the object has been removed.

  • Remove an object by its ID.

    Parameters

    • objId: string

      The ID of the object to remove.

    Returns Promise<boolean>

    Returns true if the object was successfully removed.

  • Create a Page instance.

    Parameters

    • Optionaloptions: Options

      Create a Page instance with the specified options.

    Returns Promise<PageType>

    Return a Page instance.

    const page = await Page.create();