[SOLVED] OpenUrl local file with parameters

Hi, I’m can’t open local pdf file in browser with parameters.
url:
file:///F:/myfile.pdf#page=4
But when url are opened - in browser url is: file:///F:/myfile.pdf

Can you halp me?

What platform is this? And what browser?

Does doing the same thing from the command line (e.g. with ‘open’ on a Mac, or ‘xdg-open’ on Linux) work the way you want?

TBH, I do not think you can do that. You are not calling a url interpreter, you are calling a file name. So, when you try that, it is going to load the file with the hashtag in it. This of course is going to throw a big fat “file not found” error.

Solved.
I’m create html file in persistent folder, wich open my url on load.

private string localHTMLbody= "<html><head><script type=\"text/javascript\">function load(){window.location.href = \"{0}\";}</script></head><body onload=\"load()\"></body></html>";

    public void OpenPdfInBrowser(string url, string localPdf)
    {
        string body =string.Format(localHTMLbody, url);
        File.WriteAllText(localPdf, body);
        Application.OpenURL("file:///"+localPdf);
    }
2 Likes

Hi, I kind of need to accomplish the same thing. Would you please walk me through the proccess? I have a pdf file in the Streaming Assets folder, named file.pdf. Then, how do I load that pdf file to a web browser using the Application.OpenURL() call? Thanks!

Hello, if I open file with script, script never got executed. HTML loads correctly, but that script doesnt show even alert or document.write(). Are you sure this shoud work? And how?

Brilliant idea! Thanks for sharing. BTW, I think it’s better to create the temp html file inside Application.temporaryCachePath.