@capawesome/capacitor-pdf-generator 0.0.1 → 0.1.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
@@ -23,9 +23,14 @@ Capacitor plugin to generate paginated PDF files from HTML content or URLs.
23
23
 
24
24
  Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
25
25
 
26
- ## Newsletter
26
+ ## Use Cases
27
27
 
28
- Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
28
+ The PDF Generator plugin is typically used whenever an app needs to produce a document on the device, for example:
29
+
30
+ - **Invoices and receipts**: Generate an invoice or receipt as a paginated PDF file from an HTML template.
31
+ - **Reports**: Export app data as a paginated report with real page breaks and selectable page sizes.
32
+ - **Tickets and confirmations**: Turn a booking confirmation or ticket into a PDF file that can be printed or shared.
33
+ - **Web page snapshots**: Save a web page as a PDF file by passing its URL to `generateFromUrl(...)`.
29
34
 
30
35
  ## Compatibility
31
36
 
@@ -73,8 +78,14 @@ No configuration required for this plugin.
73
78
 
74
79
  ## Usage
75
80
 
81
+ The following examples show how to generate a PDF file from HTML content and from a URL.
82
+
76
83
  The generated PDF file is written to the cache directory and deleted on the next app launch. Move it to a permanent location if you want to keep it, for example with the `rename(...)` method of the [Filesystem](https://capacitorjs.com/docs/apis/filesystem) plugin. You can also hand the path to the [PDF Viewer](https://capawesome.io/docs/sdks/capacitor/pdf-viewer/), [Printer](https://capawesome.io/docs/sdks/capacitor/printer/), [File Opener](https://capawesome.io/docs/sdks/capacitor/file-opener/) or [Share](https://capacitorjs.com/docs/apis/share) plugin.
77
84
 
85
+ ### Generate a PDF file from HTML content
86
+
87
+ Generate a paginated PDF file from an HTML string, with a custom file name, page size and orientation. Only available on Android and iOS:
88
+
78
89
  ```typescript
79
90
  import { PdfGenerator, Orientation, PageSize } from '@capawesome/capacitor-pdf-generator';
80
91
 
@@ -87,6 +98,14 @@ const generateFromHtml = async () => {
87
98
  });
88
99
  return path;
89
100
  };
101
+ ```
102
+
103
+ ### Generate a PDF file from a URL
104
+
105
+ Generate a paginated PDF file from a web page. Use the `timeout` option to control how long the plugin waits for the page before the call is rejected with the `TIMEOUT` error code. Only available on Android and iOS:
106
+
107
+ ```typescript
108
+ import { PdfGenerator, Orientation, PageSize } from '@capawesome/capacitor-pdf-generator';
90
109
 
91
110
  const generateFromUrl = async () => {
92
111
  const { path } = await PdfGenerator.generateFromUrl({
@@ -210,6 +229,46 @@ Only available on Android and iOS.
210
229
 
211
230
  </docgen-api>
212
231
 
232
+ ## FAQ
233
+
234
+ ### How is this plugin different from other similar plugins?
235
+
236
+ It turns HTML content or a URL into a paginated PDF with real page breaks, selectable page sizes and orientation, and vector output so text stays sharp and selectable at any zoom. Results are written to a file rather than held in memory, so even large documents generate reliably, and a configurable timeout keeps a slow page from hanging your app — all through a fully typed API on Android and iOS using only official platform APIs. Actively maintained against the latest Capacitor version, it hands off cleanly to the PDF Viewer, Printer, and File Opener plugins.
237
+
238
+ ### Where is the generated PDF file stored?
239
+
240
+ The generated PDF file is written to the cache directory and deleted on the next app launch. Move it to a permanent location if you want to keep it, for example with the `rename(...)` method of the [Filesystem](https://capacitorjs.com/docs/apis/filesystem) plugin.
241
+
242
+ ### How can I display, print or share the generated PDF file?
243
+
244
+ The plugin returns the path of the generated file, which you can hand to other plugins: display it with the [PDF Viewer](https://capawesome.io/docs/sdks/capacitor/pdf-viewer/) plugin, print it with the [Printer](https://capawesome.io/docs/sdks/capacitor/printer/) plugin, open it with the [File Opener](https://capawesome.io/docs/sdks/capacitor/file-opener/) plugin, or share it with the [Share](https://capacitorjs.com/docs/apis/share) plugin.
245
+
246
+ ### Is this plugin available on the web?
247
+
248
+ No, this plugin is only available on Android and iOS. On the web, use `window.print()` with [print CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Printing) to let the user save a web page as a PDF file.
249
+
250
+ ### Why does the call reject with the `TIMEOUT` error code?
251
+
252
+ The PDF generation did not complete within the configured timeout, for example because the web page did not finish loading. By default, the plugin waits 30000 milliseconds. Increase the `timeout` option if your content needs more time to load.
253
+
254
+ ### Which page sizes and orientations are supported?
255
+
256
+ The plugin supports the page sizes A3, A4, A5 and US Letter in portrait or landscape orientation. The page size defaults to A4 and the orientation defaults to portrait.
257
+
258
+ ### Can I use this plugin with Ionic, React, Vue or Angular?
259
+
260
+ Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
261
+
262
+ ## Related Plugins
263
+
264
+ - [PDF Viewer](https://capawesome.io/docs/sdks/capacitor/pdf-viewer/): Display PDF documents in a fullscreen native viewer.
265
+ - [Printer](https://capawesome.io/docs/sdks/capacitor/printer/): Print HTML, PDFs, files and more on Android and iOS.
266
+ - [File Opener](https://capawesome.io/docs/sdks/capacitor/file-opener/): Open a file with the default application.
267
+
268
+ ## Newsletter
269
+
270
+ Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
271
+
213
272
  ## Changelog
214
273
 
215
274
  See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/pdf-generator/CHANGELOG.md).
@@ -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 {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-pdf-generator",
3
- "version": "0.0.1",
4
- "description": "Capacitor plugin to generate paginated PDF files from HTML content or URLs.",
3
+ "version": "0.1.1",
4
+ "description": "Capacitor plugin to generate paginated PDF files from HTML content or URLs on Android and iOS.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -40,7 +40,13 @@
40
40
  "native",
41
41
  "pdf",
42
42
  "pdf generator",
43
- "html to pdf"
43
+ "html to pdf",
44
+ "capacitor-plugin",
45
+ "url to pdf",
46
+ "generate pdf",
47
+ "pdf export",
48
+ "pdf creation",
49
+ "invoice pdf"
44
50
  ],
45
51
  "scripts": {
46
52
  "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",