You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-2Lines changed: 71 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,9 @@ Titanium Native Module (Android) and libraries for generating PDF files based on
15
15
* `pdfGeneration.js` depends on [mustache.js](https://github.com/janl/mustache.js) for parsing templates.
16
16
* For iOS, [NappPDFCreator](https://github.com/viezel/NappPDFCreator) is recommended
17
17
18
-
## Basic Usage
18
+
##PDFCreator Module
19
+
20
+
### Basic Usage
19
21
1. Make sure you have the module dependency added on `tiapp.xml`
20
22
21
23
```xml
@@ -36,7 +38,7 @@ Titanium Native Module (Android) and libraries for generating PDF files based on
36
38
* `generatePDFWithHTML()` - Parses some HTML string and creates a PDF file from it. Use `XMLWorker` for it. PDF files have the best quality but not all HTML/CSS properties are supported yet.
37
39
* `generatePDFwithWebView()` - Takes a screenshot from a given `Ti.UI.WebView` and divides the resulting image into several pages. PDF files have medium quality and use a lot of space on disk, but supports all the HTML/CSS properties available.
38
40
39
-
## Example
41
+
###Example
40
42
```javascript
41
43
var PdfCreator =require('com.propelics.pdfcreator');
42
44
@@ -71,3 +73,70 @@ webview.addEventListener('load', function (e) {
71
73
72
74
webview.url='www.apple.com';
73
75
```
76
+
77
+
## PDFGeneration lib
78
+
79
+
### Basic Usage
80
+
* This lib is intended to handle the common use cases for the PDF module creation. Therefore it depends on the `PDFCreator` module.
81
+
* Add `pdfGeneration.js` and `mustache.js` under `app/lib` (for Alloy projects).
82
+
* 2 functions are included to generate the PDF files
83
+
* `generateWithWebView()` - Generates a PDF file based on an HTML File using a webview to load it's data. **It does NOT use `PDFCreator.generatePDFwithWebView()`**
84
+
* `generatePDFWithTemplate()` - Generates a PDF file based on an HTML Template, will load using `mustache.js`
85
+
* Both functions take a set of options to generate the PDF.
86
+
* `htmlFile` - File object to load that includes the HTML file to parse
87
+
* `data` - Dictionary with data to be parsed inside the HTML before generating the PDF
88
+
* `sucessCallback` - Function called when the PDF gets generated
89
+
* `failCallback` - Function called if an error occurs
90
+
91
+
### Example
92
+
```javascript
93
+
var PdfGeneration =require('pdfGeneration');
94
+
95
+
// Workaround to load images
96
+
var imageFile =Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'image.jpg');
0 commit comments