I’m using the new WKWebView-based htmlViewer and want to know if a PDF is displayed.
I’ve previously used this MBS function to get the data and then look to see if begins with “%PDF-”
dim pdf as string = myHTMLViewerWK.mainFrameMBS.dataSource.data
But mainFrameMBS is deprecated because it’s intended for 32-bit only and won’t work going forward.
The function HTMLTextMBS only returns text, which is empty if a PDF is displayed, and I haven’t been able to dig up any javascript functions that work.
Any suggestions?
What do you want to do ?
To read a pdf file as binary, use a BinaryStream. But this is certainly not what you what to do.
%pdf at the beginning of the file:
it is called a magic number. This exists also for png, heic, gif, 8BIM, etc.
More information here .
Not as straight forward as you used to, but, what about something in the event DocumentComplete, if the URL ends with pdf, use a socket to download it?
Change the channel to Add-ons and prefix the topic with MBS so that Christian can see the topic.
Maybe better change channel to Testers as Xojo 2020r2 is not yet released.
As I did recently do that for WebView.GetSourceData function in FileMaker, I can just copy & paste the code to our WKWebViewMBS class for Xojo.
So I’ll add for you:
MainResourceData(byref error as NSErrorMBS) as MemoryBlock
@Christian Schmidt
I’m using Xojo 2019R3, not a beta.
Thank you very much.
Then using myHTMLViewerWK.mainFrameMBS.dataSource.data should work perfectly!
Those web stuff is deprecated as we expect Xojo 2020 to come soon.
Christian I don’t think this is about the Xojo web framework.
As stated by the first post, mainFrameMBS is 32 bit only:
https://www.monkeybreadsoftware.net/HTMLViewer-mainframembs.shtml
No, that’s not correct. mainFrameMBS is working fine for 64bit. I’d guess that “This method is not available in Xojo 2020r1 or newer as it is for MacOS 32-bit only.” is a copy-pasta error. Only the first part of the sentence is okay.
Yes, mainFrameMBS will not work in Xojo 2020r1, but works fine in Xojo 2019r.
I’ll update documentation.
@Christian Schmidt
To be clear, the new MainResourceData() will provide the functionality of mainFrameMBS but will work with Xojo 2020R1. Right?