PDF Web Viewer
    Preparing search index...

    Interface IDeviceConfig

    "This device" as a save target — the user's own machine.

    This config is what makes the machine a target at all: implement the two methods below and the device behaves like any other source — the same pair customProviders entries implement, minus the folder, because the destination is the operating system's to choose. A desktop shell can do that; a browser page cannot, so there the source simply does not exist and "Save as" falls back to the export (ISetupOptions.onExportFile), which is a download and not a place.

    interface IDeviceConfig {
        isSaveAllowed?: AllowSaveGuard;
        readPath(path: string): Promise<File>;
        saveInto(name: string, file: File): Promise<IFileItem>;
        saveOver(item: IFileItem, file: File): Promise<IFileItem>;
    }
    Index

    Properties

    isSaveAllowed?: AllowSaveGuard

    Optional veto in front of either one — and in front of the export, when neither is implemented. target is the item that would be overwritten, or null for a "save as".

    Methods

    • Read a file back off the machine by the path you handed over when it was opened or saved — how a desktop shell lets the viewer reopen it. Return null when the file is gone or unreadable.

      Only this makes the machine part of the recent-documents history: an open is recorded as a recent only if it can be loaded again, and a browser page cannot read a path, so there device files never appear there.

      Parameters

      • path: string

      Returns Promise<File>

    • Write the document somewhere new — the Save as action. There is no folder to pass: show your own save dialog. Return the item you wrote, path included, so the document adopts it and the next Save overwrites it; null cancels silently. Throw (or reject) on a failed write: the viewer then reports the failure.

      Parameters

      • name: string
      • file: File

      Returns Promise<IFileItem>

    • Overwrite the file the document was opened from — the Save action. item.path is the location you handed over when you opened it. Return the item as it now stands (its path is what the next Save overwrites); null cancels silently — the user's "no", not an error. Throw (or reject) on a failed write: the viewer then reports the failure.

      Parameters

      Returns Promise<IFileItem>