[SOLVED] Looking for a cross-platform webbrowser component for Lazarus lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- maurobio · 2023-07-13 13:57 Dear ALL, Out of sheer curiosity, I would like to give a try to some of the existing webbrowser components for Lazarus. I do understand that this can be a spiny question, as shown in this thread: https://forum.lazarus.freepascal.org/index.php/topic,26572.0.html However, I feel like trying it myself! I want a component which is cross-platform (at least supporting Linux and Windows). I would also prefer a component that is not based on Qt. So, I have been left with two choices: GeckoPort and fpCEF3. There are nice tutorials for for the former (https://lazplanet.blogspot.com/2013/10/browser-in-lazarus-with-gecko- pt1.html?m=1) and for the latter (https://lazplanet.blogspot.com/2015/09/create-web-browser- in-3-minutes-using.html?m=1). First, I tried the GeckoPort component (which seems to be the nearest to my requirements). Following the tutorial from here (https://lazplanet.blogspot.com/2013/10/browser-in-lazarus-with-gecko- pt1.html?m=1), I downloaded version 1 of the component, as well as the required XULRunner runtime library. I had no problem in compiling and installing the package in the IDE, however when attempting to run the GBrowser demo, what I got was a sequence of blank screens (see the attached screenshot), instead of the Free Pascal home page as shown in the tutorial. Second, I tried the fpCEF3 component, following the instructions from here: https://lazplanet.blogspot.com/2015/09/create-web-browser- in-3-minutes-using.html?m=1 (the "3-minutes solution"). In that case, the results were worse, because I could not even have the package compiled and installed in the IDE: it returned just a lot of compilation errors! Could any of you wizards give me some hints on that matter? Thanks in advance! With warmest regards, ---------------------------------------------------------------------- Zvoni · 2023-07-13 14:05 ? https://github.com/salvadordf/CEF4Delphi QuoteCEF4Delphi was developed and tested on Delphi 11.3 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3, Delphi 10.4 and Lazarus 2.2.6/FPC 3.2.2. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. CEF4Delphi demos have been tested in Windows 10, Windows 11, Linux Mint 20.3 and Raspberry Pi OS. ---------------------------------------------------------------------- maurobio · 2023-07-13 14:17 Hi, @Zvoni! Quotehttps://github.com/salvadordf/CEF4Delphi Ah, it seems to be an upgraded version of fpCEF3! I will give it a try. Thank you very much! With best regards, ---------------------------------------------------------------------- maurobio · 2023-07-13 14:37 Dear ALL, In facrt, the CEF4Delphi component pointed out by Zvoni seems to be adequate to my needs, but I still have a (perhaps very lame) doubt: is there any way of loading a local file and/or a string list with HTML markup, as provided by the TWebBrowser component which comes with Lazarus? Thanks in advance! With best regards, ---------------------------------------------------------------------- TRon · 2023-07-13 19:01 Quote from: maurobio on July 13, 2023, 04:37:49 pmis there any way of loading a local file and/or a string list with HTML markup, as provided by the TWebBrowser component which comes with Lazarus? I am not familiar with the component and the information I got is based on sysrpl's repository (probably outdated) Any webbrowser should be able to load (html) files using the file protocol so give that a spin. Also in sysrpl's version is a method named LoadHtml, exactly for that purpose. I take it you are able to load a html file into a string... ---------------------------------------------------------------------- Leledumbo · 2023-07-13 19:45 Quote from: maurobio on July 13, 2023, 04:37:49 pmDear ALL, In facrt, the CEF4Delphi component pointed out by Zvoni seems to be adequate to my needs, but I still have a (perhaps very lame) doubt: is there any way of loading a local file and/or a string list with HTML markup, as provided by the TWebBrowser component which comes with Lazarus? Thanks in advance! With best regards, Well, it's Chromium based, and Chromium understands file:// protocol, which is used to point to a local file. String list might not be possible (pure guess, feel free to confirm), you might need to dump it to a temporary file. ---------------------------------------------------------------------- maurobio · 2023-07-13 21:35 Hi, @TRon, @Leledumbo! Yes, the 'file://' protocol do the trick. Naturally, a stringlist including HTML tags can be saved to a file and then loaded in the component using the file protocol. Thank you very much! With warmest regards, ---------------------------------------------------------------------- maurobio · 2023-07-14 00:38 Dear ALL, Unfortunately, I have not been lucky with CEF4Delphi I either; although I could compile the package without problem (after I installed an additional component required by CDF4Delphi), I attempted to compile and run one of the demos, but even if I copied the contents of the 'Release' folder to the same folder of the compiled binary executable, it keep complaining that it cannot find the required files from CDF distribution. Any hints will be much appreciated. With warmest regards, ---------------------------------------------------------------------- loaded · 2023-07-14 04:51 First, make sure you have CEF files compatible with the CEF4Delphi package you are using. I am currently using CEF4Delphi 98.2 and its compatible version CEF 98.0.4758.102 without any problems. The path of the CEF files is in my project, Lpr File ; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Pline_Manager; {$mode objfpc}{$H+} uses  uCEFApplication,  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, Unit_Main, Unit_ExtensionHandler   { you can add units after this }; {$R *.res} begin  CreateGlobalCEFApp; //The library path is defined in this method.    if GlobalCEFApp.StartMainProcess then    begin    RequireDerivedFormResource:=True;    Application.Title:='Pline Manager';    Application.Scaled:=True;    Application.Initialize;    Application.CreateForm(TForm_Main, Form_Main);    Application.Run;    end;  DestroyGlobalCEFApp;end.  Unit_Main file ; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure CreateGlobalCEFApp;begin  GlobalCEFApp                     := TCefApplication.Create;  GlobalCEFApp.cache               := 'cache';  GlobalCEFApp.LogFile             := 'cache\debug.log';  GlobalCEFApp.LogSeverity         := LOGSEVERITY_INFO;  GlobalCEFApp.EnablePrintPreview  := True;   GlobalCEFApp.FrameworkDirPath := UTF8ToCP1254(ExtractFilePath(ParamStr(0))) + 'Libraries\';  GlobalCEFApp.ResourcesDirPath := UTF8ToCP1254(ExtractFilePath(ParamStr(0))) + 'Libraries\';  GlobalCEFApp.LocalesDirPath := UTF8ToCP1254(ExtractFilePath(ParamStr(0)))   + 'Libraries\locales';end; If you want to work with examples of CEF4Delphi without the need for the above process; In the folder with the examples, create a folder called Libraries and copy all the CEF files into it. Or give it a name that suits you or leave it as the original name is. You can make a change in the project settings as follows. ---------------------------------------------------------------------- egsuh · 2023-07-14 09:28 I have tested this as it interested me. I have had several trial & errors, and finally I cound run SimpleBrowser of the examples of CEF4Delphis.  I'd like to share my experience with others. 0. Downloaded CEF4Delphi from github  https://github.com/salvadordf/CEF4Delphi, and tried to install the package file (.lpk), but I guess I failed. So this lpk is not installed yet. 1. First I installed CEF4Delphi from Online package manater. No problem. 2. I downloaded CEF binaries from https://github.com/salvadordf/CEF4Delphi, clicking Windows 64 bit link. 3. Moved CEF binaries (both folders and files) to d:\cef\. 4. Downloaded CEF4Delphi from github  https://github.com/salvadordf/CEF4Delphi, but not installed this lpk yet. 5. I copied demo projects, SimpleBrowser and SimpleBrowser2 to my local folders from CEF4Delphi-master.zip > CEF4Delphi-master > Demos > Lazarus_Windows. 6. I tried to run SimpleBrowser, but     - first, it said there are no 'c:\bin\' directory for outputs. So, I changed the output path to \Outputs.     - after that, it compiled successfully, but messaged out that some files cannot be found.       So I uncommented the path assignments in the lpk file as follows.          GlobalCEFApp.FrameworkDirPath     := 'd:\cef\Release';          GlobalCEFApp.ResourcesDirPath     := 'd:\cef\resources';          GlobalCEFApp.LocalesDirPath       := 'd:\cef\resources\locales';          GlobalCEFApp.EnableGPU            := True;      // Enable hardware acceleration          GlobalCEFApp.cache                := 'd:\cef\cache';          GlobalCEFApp.UserDataPath         := 'd:\cef\User Data';                                         Simple assigning this was not good enough. Some files are said still missing, and I copied files moving around the folders under d:\cef\. 7.  Then finally it says versions are not matching. Something is 114 but expecting 92? or something. 8.  I installed .lpk file, which I mentioned in the number 0). 9.  After that, now I can run SimpleBrowser. Probably the package from Online Package manager might not be the most recent version. Or will just assigning 'library' path of project options to d:\cef solve the problems related with GlobalCEFApp related paths? ---------------------------------------------------------------------- maurobio · 2023-07-14 21:25 Hi, @loaded, @egshu! I finally got the "BrowserWindow" demo working! Here is what I have done: 1) First of all, I installed the CEF4Delphi package from the GitHub repository (I rarely rely on the Lazarus OPM for installing packages); the installation worked fine after I also installed a required package (DCPciphers); 2) I copied the BrowserWindow demo to my working directory; 3) I copied the contents of the "Release" and "Resources" folders from the CEF distribution into the BrowserWindow demo directory; 4) I compiled and run the BrowserWindow demo without any further hassles! Thank you very much! With warmest regards,