HTMLViewer.LoadPage temp file on windows

During a call to:

HTMLViewer.LoadPage ( Source As String, RelativeTo As FolderItem )

“On Windows, temporary files are created beside the passed RelativeTo FolderItem.”

I can’t seem to find any reference to this file, is the filename of the temporary file returned somewhere or do I need to fish around for it to delete it at a later time?

I usually employ a temporary folderItem

HTMLViewer.LoadPage ( mySource, GetTemporaryFolderItem )

Since the content is deleted at launch time, you may not have to clean it yourself.

I can’t use a GetTemporaryFolderItem because my content is also in that folder (images, css, etc.)

Ah, I’ve got it.

When the page is rendered (to its temp file), HTMLViewer.DocumentComplete fires with the filename in the URL parameter.

This isn’t ideal in all situations, so feedback://showreport?report_id=49493 if someone searches for this at a later date.

Create a “global” temp dir using GetTemporaryItem that will contain all your content
Then put your “relative to” root page + css, images etc in that temporary dir
And remove all the contents of that temporary dir when your app quits

But all the generated pages would then reference the temp dir. So I would have to copy my entire html content (images, css etc.) into the temp dir every time the program is launched.

Use relative references
Copy things in on demand as needed or once when the app starts
Kill it all when the app quits

This IS something you can already manage today without requiring API changes to the HTML viewer

The alternative is simply to generate the HTML page in a folder where you have all your HTML paraphernalia : images and stuff. Usually nicely tucked in a subfolder of Specialfolder.ApplicationData. Then do a loadURL.

I would find that a whole lot more logical. Then you don’t have to worry about src for images and path for anything else.

You could just use

HTMLViewer.LoadPage( HTMLasString, NIL )

And the page will automatically be created in a temp file that’s destroyed upon DocumentComplete :slight_smile:

No need to create unnecessary FolderItem objects :slight_smile:

Using this method you can even load HTML from a database or anywhere really.

If you’d like a demo of loading entire website from a database I’ll be more than glad to provide a demo.

You can also try MBS Plugin:

HTMLViewer.IELoadHTMLMBS(HTMLText as string) as boolean

this method loads html without temp file.

see
https://www.monkeybreadsoftware.net/pluginpart-windowshtmlviewer.shtml

[quote=349532:@Matthew Combatti]You could just use

HTMLViewer.LoadPage( HTMLasString, NIL )

And the page will automatically be created in a temp file that’s destroyed upon DocumentComplete :-)[/quote]

I checked with Process Monitor, it just creates a temp file in C:\Users\\AppData\Local\Temp instead, for both Native and WebKit and doesn’t remove it.

[quote=349562:@Christian Schmitz]You can also try MBS Plugin:

HTMLViewer.IELoadHTMLMBS(HTMLText as string) as boolean

this method loads html without temp file.

see
https://www.monkeybreadsoftware.net/pluginpart-windowshtmlviewer.shtml[/quote]

Thanks Christian, I’ll give it a try