1

There are two files on a local IIS 7 on Windows 7:

  • An SVG file eff.svg
  • A base HTML document of following structure:
<html>
  <head>
    <style type="text/css">
      html, body {width:100%; height:100%; margin:0}
      img.eff {width:100%; height:100%}
    </style>
  </head>
  <body>
    <img src="eff.svg" class="eff" />
  </body>
</html>

When I view this document with Internet Explorer 11, it shows me the embedded SVG.

When I view this document with Delphi's TWebBrowser component on the same machine, in the same user account, IE shows me a standard browser's image placeholder instead of image.

unit WbDemoMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    wb1: TWebBrowser;
    procedure FormShow(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  wb1.Navigate('http://localhost/EFF/eff.html');
end;

end.

When I reference the image directly with

wb1.Navigate('http://localhost/EFF/eff.svg');

it shows the image.

How to view an embedded SVG image with TWebBrowser?

Paul
  • 25,812
  • 38
  • 124
  • 247
  • 2
    `TWebBrowser` is probably running in an older compatibility mode, such as IE7. See here: https://stackoverflow.com/questions/6717055/how-do-i-turn-off-compatibility-view-on-the-ie-webbrowsercontrol-in-a-winforms-a SVG was likely not supported yet in whatever IE version your `TWebBrowser` is defaulting to. – Jerry Dodge Feb 11 '19 at 16:34

0 Answers0