[]
DsPdfJS API / DsPdfConfig
Global configuration for DsPdfJS WebAssembly initialization.
DsPdfJS supports two configuration mechanisms:
Preload configuration via the global DSPDF_CONFIG object.
This is useful when configuration must be applied before the
library is imported.
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;
get
staticverbose():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;
boolean
set
staticverbose(v):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;
boolean
void
get
staticwasmFactory():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:
Example:
DsPdfConfig.wasmFactory = async () => {
const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer();
return createDsPdfModule({ wasmBinary });
};
any
set
staticwasmFactory(v):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:
Example:
DsPdfConfig.wasmFactory = async () => {
const wasmBinary = await (await fetch("https://cdn.example.com/DsPdf.wasm")).arrayBuffer();
return createDsPdfModule({ wasmBinary });
};
any
void
get
staticwasmUrl():string|undefined
The URL specifying where to load the DsPdf WebAssembly binary from.
Example:
DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm";
string | undefined
set
staticwasmUrl(v):void
The URL specifying where to load the DsPdf WebAssembly binary from.
Example:
DsPdfConfig.wasmUrl = "https://cdn.example.com/v2.0/DsPdf.wasm";
string | undefined
void
staticsetLicenseKey(key?):Promise<void>
Sets or validates the license key. The required key depends on the runtime environment.
Behavior:
key is provided, validates and applies it. Any preloaded key (from DSPDF_CONFIG) is cleared.key is omitted, validates the preloaded key.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
string
License key to validate and apply.
Promise<void>
Error if license validation fails.