@capgo/capacitor-pdf-generator 7.0.0 → 7.2.1

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/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
  <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
3
 
4
4
  <div align="center">
5
- <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
- <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
5
+ <h2><a href="https://capgo.app/?ref=plugin_pdf_generator"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin_pdf_generator"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
7
7
  </div>
8
8
 
9
9
 
@@ -11,6 +11,10 @@ Generate PDF files from HTML strings or remote URLs.
11
11
 
12
12
  Port of the Cordova [pdf-generator](https://github.com/feedhenry-staff/pdf-generator) plugin for Capacitor with a modernized native implementation.
13
13
 
14
+ ## Documentation
15
+
16
+ The most complete doc is available here: https://capgo.app/docs/plugins/pdf-generator/
17
+
14
18
  ## Install
15
19
 
16
20
  ```bash
@@ -42,6 +46,7 @@ if (result.type === 'base64') {
42
46
 
43
47
  * [`fromURL(...)`](#fromurl)
44
48
  * [`fromData(...)`](#fromdata)
49
+ * [`getPluginVersion()`](#getpluginversion)
45
50
  * [Interfaces](#interfaces)
46
51
  * [Type Aliases](#type-aliases)
47
52
 
@@ -84,6 +89,19 @@ Generates a PDF from a raw HTML string.
84
89
  --------------------
85
90
 
86
91
 
92
+ ### getPluginVersion()
93
+
94
+ ```typescript
95
+ getPluginVersion() => Promise<{ version: string; }>
96
+ ```
97
+
98
+ Get the native Capacitor plugin version
99
+
100
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
101
+
102
+ --------------------
103
+
104
+
87
105
  ### Interfaces
88
106
 
89
107
 
@@ -28,34 +28,27 @@ public final class CapgoPdfPrintUtils {
28
28
  void onError(@NonNull String message);
29
29
  }
30
30
 
31
- public static void createBase64(
32
- Context context,
33
- PrintDocumentAdapter adapter,
34
- PrintAttributes attributes,
35
- Base64Callback callback
36
- ) {
31
+ public static void createBase64(Context context, PrintDocumentAdapter adapter, PrintAttributes attributes, Base64Callback callback) {
37
32
  Writer writer = new Writer(adapter, attributes);
38
33
  writer.writeToTempFile(
39
34
  context,
40
35
  new Writer.FileResultCallback() {
41
36
  @Override
42
37
  public void onSuccess(@NonNull File file, @NonNull ParcelFileDescriptor descriptor) {
43
- new Thread(
44
- () -> {
45
- try {
46
- String base64 = PdfIoUtils.readBase64(file);
47
- callback.onSuccess(base64);
48
- } catch (Exception ex) {
49
- callback.onError("Failed to convert PDF to base64.");
50
- } finally {
51
- PdfIoUtils.closeQuietly(descriptor);
52
- // best-effort cleanup
53
- //noinspection ResultOfMethodCallIgnored
54
- file.delete();
55
- }
38
+ new Thread(() -> {
39
+ try {
40
+ String base64 = PdfIoUtils.readBase64(file);
41
+ callback.onSuccess(base64);
42
+ } catch (Exception ex) {
43
+ callback.onError("Failed to convert PDF to base64.");
44
+ } finally {
45
+ PdfIoUtils.closeQuietly(descriptor);
46
+ // best-effort cleanup
47
+ //noinspection ResultOfMethodCallIgnored
48
+ file.delete();
56
49
  }
57
- )
58
- .start();
50
+ })
51
+ .start();
59
52
  }
60
53
 
61
54
  @Override
@@ -29,6 +29,8 @@ import java.util.Locale;
29
29
  @CapacitorPlugin(name = "PdfGenerator")
30
30
  public class PdfGeneratorPlugin extends Plugin {
31
31
 
32
+ private final String pluginVersion = "7.2.1";
33
+
32
34
  private final Handler mainHandler = new Handler(Looper.getMainLooper());
33
35
  private final List<PdfGenerationTask> tasks = new ArrayList<>();
34
36
 
@@ -84,25 +86,21 @@ public class PdfGeneratorPlugin extends Plugin {
84
86
  new CapgoPdfPrintUtils.Base64Callback() {
85
87
  @Override
86
88
  public void onSuccess(@NonNull String base64) {
87
- mainHandler.post(
88
- () -> {
89
- JSObject result = new JSObject();
90
- result.put("type", "base64");
91
- result.put("base64", base64);
92
- task.call.resolve(result);
93
- task.finish();
94
- }
95
- );
89
+ mainHandler.post(() -> {
90
+ JSObject result = new JSObject();
91
+ result.put("type", "base64");
92
+ result.put("base64", base64);
93
+ task.call.resolve(result);
94
+ task.finish();
95
+ });
96
96
  }
97
97
 
98
98
  @Override
99
99
  public void onError(@NonNull String message) {
100
- mainHandler.post(
101
- () -> {
102
- task.call.reject(message);
103
- task.finish();
104
- }
105
- );
100
+ mainHandler.post(() -> {
101
+ task.call.reject(message);
102
+ task.finish();
103
+ });
106
104
  }
107
105
  }
108
106
  );
@@ -121,12 +119,10 @@ public class PdfGeneratorPlugin extends Plugin {
121
119
 
122
120
  @Override
123
121
  public void onError(@NonNull String message) {
124
- mainHandler.post(
125
- () -> {
126
- task.call.reject(message);
127
- task.finish();
128
- }
129
- );
122
+ mainHandler.post(() -> {
123
+ task.call.reject(message);
124
+ task.finish();
125
+ });
130
126
  }
131
127
  }
132
128
  );
@@ -141,11 +137,7 @@ public class PdfGeneratorPlugin extends Plugin {
141
137
  return;
142
138
  }
143
139
 
144
- Uri uri = FileProvider.getUriForFile(
145
- getContext(),
146
- getContext().getPackageName() + ".capgo.pdfgenerator.fileprovider",
147
- file
148
- );
140
+ Uri uri = FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".capgo.pdfgenerator.fileprovider", file);
149
141
 
150
142
  Intent shareIntent = new Intent(Intent.ACTION_SEND);
151
143
  shareIntent.setType("application/pdf");
@@ -176,6 +168,17 @@ public class PdfGeneratorPlugin extends Plugin {
176
168
  builder.setMinMargins(PrintAttributes.Margins.NO_MARGINS);
177
169
  return builder.build();
178
170
  }
171
+
172
+ @PluginMethod
173
+ public void getPluginVersion(final PluginCall call) {
174
+ try {
175
+ final JSObject ret = new JSObject();
176
+ ret.put("version", this.pluginVersion);
177
+ call.resolve(ret);
178
+ } catch (final Exception e) {
179
+ call.reject("Could not get plugin version", e);
180
+ }
181
+ }
179
182
  }
180
183
 
181
184
  interface PdfSource {
@@ -237,16 +240,14 @@ final class PdfGenerationTask extends WebViewClient {
237
240
  return;
238
241
  }
239
242
 
240
- activity.runOnUiThread(
241
- () -> {
242
- webView = new WebView(plugin.getContext());
243
- WebSettings settings = webView.getSettings();
244
- settings.setJavaScriptEnabled(true);
245
- settings.setDatabaseEnabled(true);
246
- webView.setWebViewClient(this);
247
- source.load(webView);
248
- }
249
- );
243
+ activity.runOnUiThread(() -> {
244
+ webView = new WebView(plugin.getContext());
245
+ WebSettings settings = webView.getSettings();
246
+ settings.setJavaScriptEnabled(true);
247
+ settings.setDatabaseEnabled(true);
248
+ webView.setWebViewClient(this);
249
+ source.load(webView);
250
+ });
250
251
  }
251
252
 
252
253
  void finish() {
@@ -256,17 +257,15 @@ final class PdfGenerationTask extends WebViewClient {
256
257
  finished = true;
257
258
  Activity activity = plugin.getActivity();
258
259
  if (activity != null) {
259
- activity.runOnUiThread(
260
- () -> {
261
- if (webView != null) {
262
- webView.stopLoading();
263
- webView.setWebViewClient(null);
264
- webView.destroy();
265
- webView = null;
266
- }
267
- plugin.removeTask(this);
260
+ activity.runOnUiThread(() -> {
261
+ if (webView != null) {
262
+ webView.stopLoading();
263
+ webView.setWebViewClient(null);
264
+ webView.destroy();
265
+ webView = null;
268
266
  }
269
- );
267
+ plugin.removeTask(this);
268
+ });
270
269
  } else {
271
270
  plugin.removeTask(this);
272
271
  }
package/dist/docs.json CHANGED
@@ -42,6 +42,25 @@
42
42
  "PdfGeneratorFromDataOptions"
43
43
  ],
44
44
  "slug": "fromdata"
45
+ },
46
+ {
47
+ "name": "getPluginVersion",
48
+ "signature": "() => Promise<{ version: string; }>",
49
+ "parameters": [],
50
+ "returns": "Promise<{ version: string; }>",
51
+ "tags": [
52
+ {
53
+ "name": "returns",
54
+ "text": "an Promise with version for this device"
55
+ },
56
+ {
57
+ "name": "throws",
58
+ "text": "An error if the something went wrong"
59
+ }
60
+ ],
61
+ "docs": "Get the native Capacitor plugin version",
62
+ "complexTypes": [],
63
+ "slug": "getpluginversion"
45
64
  }
46
65
  ],
47
66
  "properties": []
@@ -53,4 +53,13 @@ export interface PdfGeneratorPlugin {
53
53
  * Generates a PDF from a raw HTML string.
54
54
  */
55
55
  fromData(options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult>;
56
+ /**
57
+ * Get the native Capacitor plugin version
58
+ *
59
+ * @returns {Promise<{ id: string }>} an Promise with version for this device
60
+ * @throws An error if the something went wrong
61
+ */
62
+ getPluginVersion(): Promise<{
63
+ version: string;
64
+ }>;
56
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type PdfGeneratorDocumentSize = 'A3' | 'A4';\n\nexport type PdfGeneratorOutputType = 'base64' | 'share';\n\nexport interface PdfGeneratorCommonOptions {\n /**\n * Document size used when rendering the PDF.\n * Only `A3` and `A4` are supported right now and default to `A4`.\n */\n documentSize?: PdfGeneratorDocumentSize;\n /**\n * Page orientation. Defaults to `portrait`.\n */\n orientation?: 'portrait' | 'landscape';\n /**\n * @deprecated Use `orientation` instead. Kept for backward compatibility with the Cordova plugin.\n */\n landscape?: 'portrait' | 'landscape' | boolean;\n /**\n * How the result should be returned. Defaults to `base64`.\n */\n type?: PdfGeneratorOutputType;\n /**\n * File name used when the PDF is exported to disk (share mode).\n */\n fileName?: string;\n}\n\nexport interface PdfGeneratorFromUrlOptions extends PdfGeneratorCommonOptions {\n url: string;\n}\n\nexport interface PdfGeneratorFromDataOptions extends PdfGeneratorCommonOptions {\n /**\n * HTML document to render.\n */\n data: string;\n /**\n * Base URL to use when resolving relative resources inside the HTML string.\n * When omitted, `about:blank` is used.\n */\n baseUrl?: string;\n}\n\nexport type PdfGeneratorResult =\n | {\n type: 'base64';\n base64: string;\n }\n | {\n type: 'share';\n completed: boolean;\n };\n\nexport interface PdfGeneratorPlugin {\n /**\n * Generates a PDF from the provided URL.\n */\n fromURL(options: PdfGeneratorFromUrlOptions): Promise<PdfGeneratorResult>;\n /**\n * Generates a PDF from a raw HTML string.\n */\n fromData(options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type PdfGeneratorDocumentSize = 'A3' | 'A4';\n\nexport type PdfGeneratorOutputType = 'base64' | 'share';\n\nexport interface PdfGeneratorCommonOptions {\n /**\n * Document size used when rendering the PDF.\n * Only `A3` and `A4` are supported right now and default to `A4`.\n */\n documentSize?: PdfGeneratorDocumentSize;\n /**\n * Page orientation. Defaults to `portrait`.\n */\n orientation?: 'portrait' | 'landscape';\n /**\n * @deprecated Use `orientation` instead. Kept for backward compatibility with the Cordova plugin.\n */\n landscape?: 'portrait' | 'landscape' | boolean;\n /**\n * How the result should be returned. Defaults to `base64`.\n */\n type?: PdfGeneratorOutputType;\n /**\n * File name used when the PDF is exported to disk (share mode).\n */\n fileName?: string;\n}\n\nexport interface PdfGeneratorFromUrlOptions extends PdfGeneratorCommonOptions {\n url: string;\n}\n\nexport interface PdfGeneratorFromDataOptions extends PdfGeneratorCommonOptions {\n /**\n * HTML document to render.\n */\n data: string;\n /**\n * Base URL to use when resolving relative resources inside the HTML string.\n * When omitted, `about:blank` is used.\n */\n baseUrl?: string;\n}\n\nexport type PdfGeneratorResult =\n | {\n type: 'base64';\n base64: string;\n }\n | {\n type: 'share';\n completed: boolean;\n };\n\nexport interface PdfGeneratorPlugin {\n /**\n * Generates a PDF from the provided URL.\n */\n fromURL(options: PdfGeneratorFromUrlOptions): Promise<PdfGeneratorResult>;\n /**\n * Generates a PDF from a raw HTML string.\n */\n fromData(options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -3,4 +3,7 @@ import type { PdfGeneratorFromDataOptions, PdfGeneratorFromUrlOptions, PdfGenera
3
3
  export declare class PdfGeneratorWeb extends WebPlugin implements PdfGeneratorPlugin {
4
4
  fromURL(_options: PdfGeneratorFromUrlOptions): Promise<PdfGeneratorResult>;
5
5
  fromData(_options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult>;
6
+ getPluginVersion(): Promise<{
7
+ version: string;
8
+ }>;
6
9
  }
package/dist/esm/web.js CHANGED
@@ -6,5 +6,8 @@ export class PdfGeneratorWeb extends WebPlugin {
6
6
  async fromData(_options) {
7
7
  throw this.unimplemented('fromData is not available in the web implementation.');
8
8
  }
9
+ async getPluginVersion() {
10
+ return { version: 'web' };
11
+ }
9
12
  }
10
13
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,OAAO,CAAC,QAAoC;QAChD,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAqC;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC,CAAC;IACnF,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n PdfGeneratorFromDataOptions,\n PdfGeneratorFromUrlOptions,\n PdfGeneratorPlugin,\n PdfGeneratorResult,\n} from './definitions';\n\nexport class PdfGeneratorWeb extends WebPlugin implements PdfGeneratorPlugin {\n async fromURL(_options: PdfGeneratorFromUrlOptions): Promise<PdfGeneratorResult> {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n\n async fromData(_options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult> {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,OAAO,CAAC,QAAoC;QAChD,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAqC;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n PdfGeneratorFromDataOptions,\n PdfGeneratorFromUrlOptions,\n PdfGeneratorPlugin,\n PdfGeneratorResult,\n} from './definitions';\n\nexport class PdfGeneratorWeb extends WebPlugin implements PdfGeneratorPlugin {\n async fromURL(_options: PdfGeneratorFromUrlOptions): Promise<PdfGeneratorResult> {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n\n async fromData(_options: PdfGeneratorFromDataOptions): Promise<PdfGeneratorResult> {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
@@ -13,6 +13,9 @@ class PdfGeneratorWeb extends core.WebPlugin {
13
13
  async fromData(_options) {
14
14
  throw this.unimplemented('fromData is not available in the web implementation.');
15
15
  }
16
+ async getPluginVersion() {
17
+ return { version: 'web' };
18
+ }
16
19
  }
17
20
 
18
21
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst PdfGenerator = registerPlugin('PdfGenerator', {\n web: () => import('./web').then((m) => new m.PdfGeneratorWeb()),\n});\nexport * from './definitions';\nexport { PdfGenerator };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class PdfGeneratorWeb extends WebPlugin {\n async fromURL(_options) {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n async fromData(_options) {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC;AACvF,IAAI;AACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC;AACxF,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst PdfGenerator = registerPlugin('PdfGenerator', {\n web: () => import('./web').then((m) => new m.PdfGeneratorWeb()),\n});\nexport * from './definitions';\nexport { PdfGenerator };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class PdfGeneratorWeb extends WebPlugin {\n async fromURL(_options) {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n async fromData(_options) {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC;AACvF,IAAI;AACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC;AACxF,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -12,6 +12,9 @@ var capacitorCapacitorPdfGenerator = (function (exports, core) {
12
12
  async fromData(_options) {
13
13
  throw this.unimplemented('fromData is not available in the web implementation.');
14
14
  }
15
+ async getPluginVersion() {
16
+ return { version: 'web' };
17
+ }
15
18
  }
16
19
 
17
20
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst PdfGenerator = registerPlugin('PdfGenerator', {\n web: () => import('./web').then((m) => new m.PdfGeneratorWeb()),\n});\nexport * from './definitions';\nexport { PdfGenerator };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class PdfGeneratorWeb extends WebPlugin {\n async fromURL(_options) {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n async fromData(_options) {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC;IACvF,IAAI;IACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC;IACxF,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst PdfGenerator = registerPlugin('PdfGenerator', {\n web: () => import('./web').then((m) => new m.PdfGeneratorWeb()),\n});\nexport * from './definitions';\nexport { PdfGenerator };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class PdfGeneratorWeb extends WebPlugin {\n async fromURL(_options) {\n throw this.unimplemented('fromURL is not available in the web implementation.');\n }\n async fromData(_options) {\n throw this.unimplemented('fromData is not available in the web implementation.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC;IACvF,IAAI;IACJ,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,sDAAsD,CAAC;IACxF,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -4,11 +4,13 @@ import WebKit
4
4
 
5
5
  @objc(PdfGeneratorPlugin)
6
6
  public class PdfGeneratorPlugin: CAPPlugin, CAPBridgedPlugin {
7
+ private let pluginVersion: String = "7.2.1"
7
8
  public let identifier = "PdfGeneratorPlugin"
8
9
  public let jsName = "PdfGenerator"
9
10
  public let pluginMethods: [CAPPluginMethod] = [
10
11
  CAPPluginMethod(name: "fromURL", returnType: CAPPluginReturnPromise),
11
12
  CAPPluginMethod(name: "fromData", returnType: CAPPluginReturnPromise),
13
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
12
14
  ]
13
15
 
14
16
  private var tasks: [PdfGenerationTask] = []
@@ -58,7 +60,7 @@ public class PdfGeneratorPlugin: CAPPlugin, CAPBridgedPlugin {
58
60
  DispatchQueue.main.async {
59
61
  task.call.resolve([
60
62
  "type": "base64",
61
- "base64": base64,
63
+ "base64": base64
62
64
  ])
63
65
  task.finish()
64
66
  }
@@ -90,7 +92,7 @@ public class PdfGeneratorPlugin: CAPPlugin, CAPBridgedPlugin {
90
92
  } else {
91
93
  task.call.resolve([
92
94
  "type": "share",
93
- "completed": completed,
95
+ "completed": completed
94
96
  ])
95
97
  }
96
98
  try? FileManager.default.removeItem(at: temporaryURL)
@@ -106,6 +108,10 @@ public class PdfGeneratorPlugin: CAPPlugin, CAPBridgedPlugin {
106
108
  presenter.present(activity, animated: true)
107
109
  }
108
110
  }
111
+
112
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
113
+ call.resolve(["version": self.pluginVersion])
114
+ }
109
115
  }
110
116
 
111
117
  private final class PdfGenerationTask: NSObject, WKNavigationDelegate {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-pdf-generator",
3
- "version": "7.0.0",
3
+ "version": "7.2.1",
4
4
  "description": "Generate PDF files from HTML strings or URLs on iOS and Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -37,9 +37,9 @@
37
37
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
38
38
  "verify:web": "npm run build",
39
39
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
40
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
40
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
41
41
  "eslint": "eslint . --ext .ts",
42
- "prettier": "prettier \"**/*.{css,html,ts,js,java,kt,swift}\" --plugin=prettier-plugin-java",
42
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
43
43
  "swiftlint": "node-swiftlint",
44
44
  "docgen": "docgen --api PdfGeneratorPlugin --output-readme README.md --output-json dist/docs.json",
45
45
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",