Re: Load HTML text from delphi
Posted: Fri Apr 20, 2018 2:18 pm
Hi,
TChromium has a LoadString procedure that used to be recommended for these cases. It's been a while since the last time I tested it but you would need to call TChromium.LoadURL('about:blank') first and then call TChromium.LoadString with your html code. Try this after you receive the TChormium.AfterCreated event.
If that didn't work you can also use DATA URIs in the TChoromium.LoadURL call. There are many data uri generators in Internet but I just used this to generate a URI with your HTML code :
https://dopiaza.org/tools/datauri/index.php
I modified the mime-type to text/html but try this in the MiniBrowser demo :
If you want to load local resources, consider using the SchemeRegistrationBrowser demo as a template for your app.
TChromium has a LoadString procedure that used to be recommended for these cases. It's been a while since the last time I tested it but you would need to call TChromium.LoadURL('about:blank') first and then call TChromium.LoadString with your html code. Try this after you receive the TChormium.AfterCreated event.
If that didn't work you can also use DATA URIs in the TChoromium.LoadURL call. There are many data uri generators in Internet but I just used this to generate a URI with your HTML code :
https://dopiaza.org/tools/datauri/index.php
I modified the mime-type to text/html but try this in the MiniBrowser demo :
Code: Select all
data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4gPGhlYWQ+DQogICAgPHRpdGxlPkxvY2FsaXppbmcgdGhlIE1hcDwvdGl0bGU+DQogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9ImluaXRpYWwtc2NhbGU9MS4wLCB1c2VyLXNjYWxhYmxlPW5vIj4NCiAgICA8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+DQogICAgPHN0eWxlPg0KICAgICAgI21hcCB7ICBoZWlnaHQ6IDEwMCU7ICB9DQogICAgICBodG1sLCBib2R5IHsgICBoZWlnaHQ6IDEwMCU7IG1hcmdpbjogMDsgcGFkZGluZzogMDsgIH0NCiAgICA8L3N0eWxlPg0KICA8L2hlYWQ+DQogIDxib2R5PiA8ZGl2IGlkPSJtYXAiPjwvZGl2Pg0KICAgIDxzY3JpcHQ+DQogICAgICAgZnVuY3Rpb24gaW5pdE1hcCgpIHsNCiAgICAgICAgdmFyIG1hcCA9IG5ldyBnb29nbGUubWFwcy5NYXAoZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ21hcCcpLCB7DQogICAgICAgICAgem9vbTogOCwgY2VudGVyOiB7bGF0OiAzNS43MTcsIGxuZzogMTM5LjczMX0NCiAgICAgICAgfSk7DQogICAgICB9DQogICAgPC9zY3JpcHQ+DQogICAgPHNjcmlwdCBzcmM9Imh0dHBzOi8vbWFwcy5nb29nbGVhcGlzLmNvbS9tYXBzL2FwaS9qcz9rZXk9QUl6YVN5QnpCVWd5SGxqZUh2NlZVaWs2b0tLeHRKYXFoS1RhVWV3JmNhbGxiYWNrPWluaXRNYXAmbGFuZ3VhZ2U9ZXMmcmVnaW9uPUVTIg0KICAgIGFzeW5jIGRlZmVyPg0KICAgIDwvc2NyaXB0Pg0KICA8L2JvZHk+DQo8L2h0bWw+