https://github.com/m1ga/ti.webviewpdf
Create a PDF from a WebView - Titanium SDK
https://github.com/m1ga/ti.webviewpdf
android pdf titanium-module
Last synced: about 2 months ago
JSON representation
Create a PDF from a WebView - Titanium SDK
- Host: GitHub
- URL: https://github.com/m1ga/ti.webviewpdf
- Owner: m1ga
- License: other
- Created: 2022-11-03T11:21:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-03T11:31:09.000Z (over 2 years ago)
- Last Synced: 2025-01-27T07:11:55.534Z (4 months ago)
- Topics: android, pdf, titanium-module
- Language: Java
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Setup
```xml
ti.webviewpdf
``````js
require("ti.webviewpdf").createPDF({webview: obj});
```## Methods
* createPDF:
* **webview**: (_required_) the webview object e.g. $.webview
* **pageWidth**: (int) the width in mils (thousandths of an inch) of the PDF
* **pageHeight**: (int) the height in mils (thousandths of an inch) of the PDF
* **pageSize**: (int) one of the default constants
* **showMenu**: (boolean) default false. Will show the printing menu and the user can change the paper size and storage place. There won't be a success call afterwards!
* **success**: (callback function), returns e.data (TiBlob) with the PDF
* **firstPageOnly**: (boolean) default false, only print first pageUse either _pageWidth/pageHeight_ OR _pageSize_. If you don't use any size it will be DIN A4
## Constants
* DIN_A4 (default)
* DIN_A3
* DIN_A2
* DIN_A1
* DIN_A5
* AUTO - will try to calculate the PDF page size depending on the webview height and screen width## Example
```js
require("ti.webviewpdf").createPDF({
webview: webview,
pageWidth: 5000,
pageHeight: 72000,
success: function(e) {
saveData(e.data);
}
});
```#### Tip
You can use `document.body.scrollHeight` to get the page height.