Click or drag to resize

The Chromium Rendering Engine

ExpertPdf Anywhere renders HTML with Chromium, the engine of the Chrome browser (Chromium 154, through the Chromium Embedded Framework). The converter loads the page in a Chromium browser, runs its JavaScript, then builds the PDF from the rendered page, so a page comes out the way Chrome prints it: HTML5, CSS3 with flexbox and grid, web fonts, SVG, canvas and modern JavaScript frameworks are all supported.

Chromium is the only engine, on every platform: Windows x64 and x86, Linux x64 and ARM64, and macOS on Apple Silicon. There is no WebKit, Blink or Internet Explorer engine. RenderingEngine has the single value Chromium, which is also the default, so the RenderingEngine property of the converters and of the HTML elements does not need to be set.

Where the engine comes from

The engine is in the native packages, one per platform (ExpertPdf.Anywhere.Native.win-x64, .win-x86, .linux-x64, .linux-arm64, .osx-arm64), which the platform packages (ExpertPdf.Anywhere.Windows, .Linux, .Linux.Arm64, .MacOS) include. The package copies a Chromium-CEF-154.0.28 folder next to your application when it builds and when it is published, and the converter finds it there. Nothing is installed on the machine, and on Linux no system package is needed. See Installation and Deployment.

To load the engine from another folder, set CefEnginePath to the full path of the Chromium-CEF-154.0.28 folder. CefEngineTemporaryFilesPath sets the folder the engine writes its temporary files to (the system temporary folder by default); the application must be allowed to write there.

Chromium draws the text with the fonts installed on the machine and embeds in the PDF every font a page uses. On Linux and macOS hosts that have no fonts, such as container images, add the ExpertPdf.Anywhere.Fonts package.

Inside the application or in a separate process

The engine can run in two ways, chosen for the whole application with ChromiumEngineHostMode:

  • InProcess - the engine is loaded into your application and kept ready between conversions, which removes the time a new process takes to start. This is the default when the in-process engine host (ExpertPdf.Cef.Host.dll, .so or .dylib, part of the native package) is beside the engine and built for the architecture of your process.

  • OutOfProcess - each conversion runs in a short-lived engine process of its own (ExpertPdf.Cef), outside your application, so a failure inside the engine cannot affect the application. This is the default otherwise, for example in a 32-bit process using the 64-bit engine package.

The engine is initialized once per process, so set the mode at start-up: the value in force at the first conversion is used for the life of the process. In both modes each conversion has a browser of its own, and cookies and site storage are cleared after every conversion, so nothing a page stores reaches the next conversion. What the HTTP cache keeps between in-process conversions is set with HttpCache.

The environment variable EXPERTPDF_CHROMIUM_ENGINE_HOST, set to outofprocess or inprocess, chooses the mode without a code change; a value assigned to the property in code takes precedence over it.

// at application start-up, before the first conversion: run every conversion in a
// separate engine process
ExpertPdf.Anywhere.GlobalSettings.ChromiumEngineHostMode =
    ExpertPdf.Anywhere.ChromiumEngineHostMode.OutOfProcess;

One conversion can be sent to a separate engine process whatever the mode is, with ForceOutOfProcess: to isolate a page you do not trust, or to give one conversion settings that the in-process engine fixes for the whole process at its first conversion (WebGL, the proxy, local file access).

PdfConverter pdfConverter = new PdfConverter();
// this page draws with WebGL, and runs in its own engine process
pdfConverter.ForceOutOfProcess = true;
pdfConverter.WebGlEnabled = true;
pdfConverter.SavePdfFromUrlToFile("https://www.example.com/map", "map.pdf");

The number of conversions that run at the same time is set with PdfConverterConcurrencyLevel, in both modes; see Multithreading Support.

See Also