@capgo/capacitor-pdf-generator 8.0.14 → 8.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -30,7 +30,7 @@ android {
|
|
|
30
30
|
buildTypes {
|
|
31
31
|
release {
|
|
32
32
|
minifyEnabled false
|
|
33
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
lintOptions {
|
|
@@ -29,7 +29,7 @@ import java.util.Locale;
|
|
|
29
29
|
@CapacitorPlugin(name = "PdfGenerator")
|
|
30
30
|
public class PdfGeneratorPlugin extends Plugin {
|
|
31
31
|
|
|
32
|
-
private final String pluginVersion = "8.0.
|
|
32
|
+
private final String pluginVersion = "8.0.16";
|
|
33
33
|
|
|
34
34
|
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
35
35
|
private final List<PdfGenerationTask> tasks = new ArrayList<>();
|
|
@@ -4,7 +4,7 @@ import WebKit
|
|
|
4
4
|
|
|
5
5
|
@objc(PdfGeneratorPlugin)
|
|
6
6
|
public class PdfGeneratorPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
-
private let pluginVersion: String = "8.0.
|
|
7
|
+
private let pluginVersion: String = "8.0.16"
|
|
8
8
|
public let identifier = "PdfGeneratorPlugin"
|
|
9
9
|
public let jsName = "PdfGenerator"
|
|
10
10
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -125,7 +125,7 @@ private final class PdfGenerationTask: NSObject, WKNavigationDelegate {
|
|
|
125
125
|
|
|
126
126
|
private weak var plugin: PdfGeneratorPlugin?
|
|
127
127
|
private let source: Source
|
|
128
|
-
private
|
|
128
|
+
private var webView: WKWebView?
|
|
129
129
|
private var didFinish = false
|
|
130
130
|
|
|
131
131
|
init(plugin: PdfGeneratorPlugin, call: CAPPluginCall, source: Source, options: PdfGeneratorOptions) {
|
|
@@ -133,21 +133,24 @@ private final class PdfGenerationTask: NSObject, WKNavigationDelegate {
|
|
|
133
133
|
self.call = call
|
|
134
134
|
self.source = source
|
|
135
135
|
self.options = options
|
|
136
|
-
let configuration = WKWebViewConfiguration()
|
|
137
|
-
configuration.preferences.javaScriptEnabled = true
|
|
138
|
-
self.webView = WKWebView(frame: .zero, configuration: configuration)
|
|
139
136
|
super.init()
|
|
140
|
-
self.webView.navigationDelegate = self
|
|
141
137
|
}
|
|
142
138
|
|
|
143
139
|
func start() {
|
|
144
140
|
DispatchQueue.main.async {
|
|
141
|
+
// Create WKWebView on main thread
|
|
142
|
+
let configuration = WKWebViewConfiguration()
|
|
143
|
+
configuration.preferences.javaScriptEnabled = true
|
|
144
|
+
let webView = WKWebView(frame: .zero, configuration: configuration)
|
|
145
|
+
webView.navigationDelegate = self
|
|
146
|
+
self.webView = webView
|
|
147
|
+
|
|
145
148
|
switch self.source {
|
|
146
149
|
case let .url(url):
|
|
147
150
|
let request = URLRequest(url: url)
|
|
148
|
-
|
|
151
|
+
webView.load(request)
|
|
149
152
|
case let .html(html, baseUrl):
|
|
150
|
-
|
|
153
|
+
webView.loadHTMLString(html, baseURL: baseUrl)
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
}
|
|
@@ -160,9 +163,9 @@ private final class PdfGenerationTask: NSObject, WKNavigationDelegate {
|
|
|
160
163
|
|
|
161
164
|
private func cleanup() {
|
|
162
165
|
DispatchQueue.main.async {
|
|
163
|
-
self.webView
|
|
164
|
-
self.webView
|
|
165
|
-
self.webView
|
|
166
|
+
self.webView?.stopLoading()
|
|
167
|
+
self.webView?.navigationDelegate = nil
|
|
168
|
+
self.webView?.removeFromSuperview()
|
|
166
169
|
}
|
|
167
170
|
plugin?.taskDidComplete(self)
|
|
168
171
|
}
|
|
@@ -189,6 +192,11 @@ private final class PdfGenerationTask: NSObject, WKNavigationDelegate {
|
|
|
189
192
|
}
|
|
190
193
|
|
|
191
194
|
private func generatePdf() {
|
|
195
|
+
guard let webView = self.webView else {
|
|
196
|
+
fail(with: "WebView not initialized")
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
|
|
192
200
|
let configuration = WKPDFConfiguration()
|
|
193
201
|
configuration.rect = CGRect(origin: .zero, size: options.pageSize)
|
|
194
202
|
|
package/package.json
CHANGED