procedure ConfigurePdfLibrary(const Configuration: TPdfLibraryConfiguration);
| Configuration | TPdfLibraryConfiguration |
ConfigurePdfLibrary 保存原生初始化设置,LoadLibrary 在首次加载 PDFium 模块时会将其传递给 FPDF_InitLibraryWithConfig
该记录涵盖 UserFontPaths、V8Isolate、V8EmbedderSlot、V8Platform、Renderer(prpAgg 或 prpSkia)、FontBackend(pfbpFreeType 或 pfbpFontations)、BrotliEnabled、IsolatePerDocument 和 AllowMachineTime
IsolatePerDocument 对应 FPDF_LIBRARY_CONFIG 版本 7 的 m_IsolatePerDocument 标志:启用 V8 的 pdfium.dll 会为每个文档创建专属的 v8::Isolate,而不是整个进程共享一个 isolate。该选项只在 V8 构建下生效,且必须与 nil 的 V8Isolate 搭配使用
配置会被深拷贝,包括 UserFontPaths 数组,因此之后对调用方记录的修改不会产生任何影响
AllowMachineTime 控制在原生初始化完成后立即应用的 FPDF_SetSandBoxPolicy 机器时间策略,TPdfLibraryConfiguration.Hardened 是禁用该策略的快捷方式
EPdfErrorpfbpDefault 以外的显式 FontBackend 要求 Renderer 为 prpSkia,否则抛出 EPdfErrorprpDefault 仍保持 DLL 的默认渲染器;参见 PdfNativeRendererTypeprpSkia,或在没有 Fontations 的构建上设置 FontBackend pfbpFontations,会让下一次 LoadLibrary 抛出 EPdfError 并保持配置未密封,而不是任由原生初始化终止进程;参见 PdfLibraryConfigurationSupportErrorEPdfErrorEPdfError,因为原生库在初始化时会拒绝这种组合Config := TPdfLibraryConfiguration.Hardened;
Config.Renderer := prpSkia;
ConfigurePdfLibrary(Config);