Search code examples
delphisvgprintingchromium

Problem in printing a webpage containing SVG images in Chromium


I have a html file with the following content:

<html>
<body>
<object data="https://upload.wikimedia.org/wikipedia/commons/0/09/America_Online_logo.svg" type="image/svg+xml"></object>
</body>
</html>

As you can check, you can open it with chrome and print it. But if I use Chromium.Print method, it print empty pages.

Note that this is only a sample. All SVG images had the same problem.

I use Delphi 10.3.2 and CEF4Delphi.

Can any one guide me?


Solution

  • This is very likely caused by the CEF issue #3297 and the workaround described in that report works.

    Add this code line before the GlobalCEFApp.StartMainProcess call :

    GlobalCEFApp.DisableSiteIsolationTrials := True;
    

    I tested this workaround with the latest CEF4Delphi version which uses CEF 100.0.14 and the MiniBrowser demo. Your sample HTML is printed correctly with TChromiumCore.Print and TChromiumCore.PrintToPdf.