Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private xui As XUI
Private WebView1 As WebView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("Page1")
NavControl.ShowPage(Page1)
WebView1.LoadUrl("https://www.google.com")
End Sub
Sub Button1_Click
If App.OSVersion < 14 Then
Log("not supported")
Else
Dim no As NativeObject = Me
no.RunMethod("CreatePDF:", Array(WebView1))
End If
End Sub
Sub PDF_Created (Data As Object, Success As Boolean)
If Success Then
Dim no As NativeObject = Data
Dim arr() As Byte = no.NSDataToArray(Data)
File.WriteBytes(File.DirLibrary, "1.pdf", arr)
WebView1.LoadUrl(xui.FileUri(File.DirLibrary, "1.pdf"))
End If
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
#if OBJC
#import <WebKit/WebKit.h>
- (void) CreatePDF:(WKWebView*)wv {
if (@available(iOS 14, *)) {
[wv createPDFWithConfiguration:nil completionHandler:^(NSData* data, NSError* error) {
if (error != nil) {
NSLog(@"Error %@", error);
}
[self.bi raiseUIEvent:nil event:@"pdf_created::" params:@[data, @(error == nil)]];
}
];
}
}
#End If