Pixen JavaScript API
    Preparing search index...

    Interface Document

    An open Pixen image or animation document.

    interface Document {
        name: string;
        canvas: Canvas;
        animation: Animation | null;
        dataOfType(
            fileExtension: string,
            options?: ExportOptions | null,
        ): Data | null;
        writeToFile(path: string, options?: ExportOptions | null): boolean;
        duplicate(): Document | null;
        activate(): void;
        undo(): boolean;
        redo(): boolean;
    }
    Index
    name: string

    The display name, including the filename extension when available.

    canvas: Canvas

    The document's current canvas.

    animation: Animation | null

    Animation controls, or null for a still image document.

    • Encodes the document in a supported file format.

      Parameters

      • fileExtension: string

        For image documents: pxi, png, jpg, jpeg, gif, heic, tif, tiff, bmp, ico, svg, psd, or pntg. For animation documents: pxa, gif, png, mov, or mp4.

      • Optionaloptions: ExportOptions | null

        Image encoding options.

      Returns Data | null

      Encoded data, or null when export failed.

    • Writes the document using the format selected by the path extension.

      Parameters

      • path: string

        Absolute or tilde-relative destination path. Image documents support pxi, png, jpg, jpeg, gif, heic, tif, tiff, bmp, ico, svg, psd, and pntg; animation documents support pxa, gif, png, mov, and mp4.

      • Optionaloptions: ExportOptions | null

        Image encoding options.

      Returns boolean

      Whether the file was written successfully.

    • Returns Document | null

      A new duplicate document, or null when duplication is unavailable.

    • Brings this document's window to the foreground.

      Returns void

    • Returns boolean

      Whether an edit was undone.

    • Returns boolean

      Whether an edit was redone.