DsPdfJS API - v9.1.0
    Preparing search index...

    Class DsPdfConfig

    Global configuration for DsPdfJS WebAssembly initialization.

    DsPdfJS supports two configuration mechanisms:

    1. Preload configuration via the global DSPDF_CONFIG object. This is useful when configuration must be applied before the library is imported.

    2. Runtime configuration via static properties of DsPdfConfig after the library has been loaded.

    The preload configuration is read lazily on first access and is not re-evaluated afterwards.

    Example:

    // Pre-load configuration
    globalThis.DSPDF_CONFIG = {
    wasmUrl: "/assets/DsPdf.wasm",
    licenseKey: "YOUR_LICENSE_KEY"
    };

    // Post-load configuration
    import { DsPdfConfig } from "@mescius/ds-pdf";
    DsPdfConfig.verbose = true;
    Index

    Accessors

    • get verbose(): boolean

      Enables detailed console logging during WASM discovery and initialization. Use this to debug loading issues or verify fallback behavior.

      Default: false

      Example:

      DsPdfConfig.verbose = true;
      

      Returns boolean

    • set verbose(v: boolean): void

      Enables detailed console logging during WASM discovery and initialization. Use this to debug loading issues or verify fallback behavior.

      Default: false

      Example:

      DsPdfConfig.verbose = true;
      

      Parameters

      • v: boolean

      Returns void

    • get wasmFactory(): any

      Custom factory for creating and initializing the DsPdf WASM module.

      If defined, this function overrides the default initialization process. Must return a Promise resolving to a fully initialized MainModule.

      Useful for:

      • CDN or remote WASM hosting
      • Custom build or environment setup
      • Mocking during unit tests

      Example:

      DsPdfConfig.wasmFactory = async () => {
      const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer();
      return createDsPdfModule({ wasmBinary });
      };

      Returns any

    • set wasmFactory(v: any): void

      Custom factory for creating and initializing the DsPdf WASM module.

      If defined, this function overrides the default initialization process. Must return a Promise resolving to a fully initialized MainModule.

      Useful for:

      • CDN or remote WASM hosting
      • Custom build or environment setup
      • Mocking during unit tests

      Example:

      DsPdfConfig.wasmFactory = async () => {
      const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer();
      return createDsPdfModule({ wasmBinary });
      };

      Parameters

      • v: any

      Returns void

    • get wasmUrl(): string | undefined

      The URL specifying where to load the DsPdf WebAssembly binary from.

      Example:

      DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm";
      

      Returns string | undefined

    • set wasmUrl(v: string | undefined): void

      The URL specifying where to load the DsPdf WebAssembly binary from.

      Example:

      DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm";
      

      Parameters

      • v: string | undefined

      Returns void

    Methods

    • Sets or validates the license key. The required key depends on the runtime environment.

      Behavior:

      • If key is provided, validates and applies it. Any preloaded key (from DSPDF_CONFIG) is cleared.
      • If key is omitted, validates the preloaded key.
      • If undefined is passed, removes any previously set license key and ignores the preloaded one.

      You can optionally preconfigure the license key before the library loads:

      // Pre-load configuration (before initializing DsPdf)
      globalThis.DSPDF_CONFIG = {
      wasmUrl: "/assets/DsPdf.wasm",
      licenseKey: "YOUR_LICENSE_KEY"
      };

      Examples:

      await setLicenseKey(key);        // validates and applies the provided license key
      await setLicenseKey(undefined); // removes any previously set license key
      await setLicenseKey(); // validates the preloaded license key

      Parameters

      • Optionalkey: string

        License key to validate and apply.

      Returns Promise<void>

      Error if license validation fails.