import {ChromeGpuModes} from "./types"; /** * Global installation and setup preferences for IronPDF * * See {@link IronPdfGlobalConfig.setConfig} */ export class IronPdfGlobalConfig { private static _instance: IronPdfGlobalConfig; private static _config: IronPdfConfig = { ironPdfEngineAddress: "127.0.0.1:33350", ironPdfEngineDockerAddress: undefined, debugMode: false, licenseKey: undefined, }; private constructor() { if (IronPdfGlobalConfig._instance) { throw new Error( "Error: Instantiation failed: Use Access.getInstance() instead of new." ); } IronPdfGlobalConfig._instance = this; } public static getInstance() { return IronPdfGlobalConfig._instance || (IronPdfGlobalConfig._instance = new IronPdfGlobalConfig()); } /** * Main IronPdf configuration method * * @param ironPdfConfig configuration see {@link IronPdfConfig} */ public static setConfig(ironPdfConfig: IronPdfConfig) { if (ironPdfConfig.debugMode != undefined) { IronPdfGlobalConfig._config.debugMode = ironPdfConfig.debugMode; } if (ironPdfConfig.licenseKey) { IronPdfGlobalConfig._config.licenseKey = ironPdfConfig.licenseKey; } if (ironPdfConfig.ironPdfEngineAddress) { IronPdfGlobalConfig._config.ironPdfEngineAddress = ironPdfConfig.ironPdfEngineAddress; } if (ironPdfConfig.ironPdfEngineDockerAddress) { IronPdfGlobalConfig._config.ironPdfEngineDockerAddress = ironPdfConfig.ironPdfEngineDockerAddress; } } public static getConfig(): IronPdfConfig { return IronPdfGlobalConfig._config; } public static ironPdfEngineVersion: string = // eslint-disable-next-line @typescript-eslint/no-var-requires require(`../../package.json`).ironPdfEngineVersion; } /** * Main IronPdf configuration interface */ export interface IronPdfConfig { /** * An address of IronPdf subprocess. * @default 127.0.0.1:33350 */ ironPdfEngineAddress?: string | undefined; /** * An address of IronPdfEngine Docker. * * If this config was specified IronPdf will switch to Docker mode * * Docker mode: IronPdf will not spawn subprocess but will connect to Docker instead. * * @default undefined */ ironPdfEngineDockerAddress?: string | undefined; /** * Enable debug mode * * Debug mode: IronPdf will expose more logging messages * * @default false */ debugMode?: boolean | undefined; /** * Removes watermarks. Get licensed at https://ironpdf.com/nodejs/licensing. * * For Node.js applications, a license key can alternatively be set using the environment variable IRONPDF_LICENSE_KEY. * Priority: programmatic licenseKey > IRONPDF_LICENSE_KEY environment variable. * * For .Net framework applications, a license key can alternatively be added to Web.Config or App.Config XML file using * within the appSettings tag. See * https://ironpdf.com/nodejs/docs/license/license-keys/ for more details. * * For .Net Core applications, a license key may be added to appsettings.json where the key name is "IronPdf.LicenseKey" and the value is a valid IronPDF trial or full license key. * * See https://ironpdf.com/nodejs/licensing/ for licensing options. * * @default undefined */ licenseKey?: string | undefined; /** * SingleProcess mode Forces Chrome renderer to perform everything in the current process, rather than using subprocesses (default true for macOS, false for other OS) * @default false */ singleProcess?: boolean | undefined; /** * Set Maximum number of concurrent browsers when using the Chrome renderer * @default 30 */ chromeBrowserLimit?: number | undefined; /** * Disk cache path for Chrome browser instances * @default undefined */ chromeBrowserCachePath?: string | undefined; /** * Chrome renderer GPU compatibility mode. In special environment like Docker or Cloud Service please use ChromeGpuModes "Disabled" * @default {@link ChromeGpuModes.Disabled} */ chromeGpuMode?:ChromeGpuModes | undefined; /** * If true The necessary package dependencies for IronPDF rendering will we automatically installed to * Docker and Debian / Ubuntu Linux deployments. * This will take a few minutes the next time you run IronPDF. * Set this to false if manual Docker / Linux setup is more convenient: * more info * @default true */ autoInstallDependency?: boolean | undefined; }