Jump to content
CarloM

FMX.WebBrowser on MacOS raises error "the specified file was not found"

Recommended Posts

Hello

 

When I show a PDF via TWebBrowser on Mac OS, it only works well for first time.

Then when I try to view another PDF raises an error "The specified file was not found", on Windows works well.

 

I use delphi professional rio update 1.

 

I see related question but not solution on these links:

 

https://forums.embarcadero.com/thread.jspa?threadID=252540

 

https://forums.embarcadero.com/thread.jspa?threadID=260250&tstart=0

 

Regards

 

 

Share this post


Link to post

I'll take a look into this.. hopefully in the next few hours. If there's a QP entry, please let me know

Edited by Dave Nottage

Share this post


Link to post

You might have to provide a reproducible test case, because I'm unable to reproduce the problem.

 

I deployed a couple of example PDF files in the app, using the default remote path of /Contents/MacOS/Startup, and used this code to load them:

 

procedure TForm1.OpenPDF(const AFileName: string);
var
  LSourceName, LDestName: string;
begin
  // Bit of a "hack" to get the exact paths of the pdf files deployed to /Contents/Resources/Startup
  LSourceName := TPath.GetDirectoryName(ParamStr(0));
  LSourceName := TPath.Combine(StringReplace(LSourceName, '/MacOS', '', []), 'Resources/Startup/' + AFileName);
  LDestName := TPath.Combine(TPath.GetTempPath, 'open.pdf');
  // Delete any existing temp file
  TFile.Delete(LDestName);
  // Copy from resources to common location
  TFile.Copy(LSourceName, LDestName);
  WebBrowser1.Navigate('file://' + LDestName);
end;

Works every time. My guess is that the problem is with your file retrieval/copy, rather than it being a WebBrowser issue

Share this post


Link to post

maybe need another way: free the TWebBrowser and create it again ?

 

Or, you need a html file with JavaScrip to load PDF file, you just load html file into TWebBrowser and let the javascript to load PDF for you.

 

I just guess, no try.  I have no Apple mobile phone.

Edited by pcplayer99

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×