Skip to content

Commit

Permalink
Release 0.3.0 (christopherdro#22)
Browse files Browse the repository at this point in the history
- Add base64 support for iOS and Android
- Add `fileName` and `directory` options for Android
- Update iOS header files to support RN 0.40.0
- Update example to latest version
  • Loading branch information
christopherdro authored Jan 16, 2017
1 parent f04f7a6 commit 2af3574
Show file tree
Hide file tree
Showing 58 changed files with 5,349 additions and 595 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ Carthage/Build
#
node_modules/
npm-debug.log

# Android/IJ
.idea
.gradle
android/**/*.iml
local.properties
46 changes: 0 additions & 46 deletions HTMLToPDFExample/.flowconfig

This file was deleted.

28 changes: 0 additions & 28 deletions HTMLToPDFExample/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions HTMLToPDFExample/.npmignore

This file was deleted.

60 changes: 0 additions & 60 deletions HTMLToPDFExample/iOS/HTMLToPDFExample/AppDelegate.m

This file was deleted.

8 changes: 0 additions & 8 deletions HTMLToPDFExample/iOS/HTMLToPDFExample/main.jsbundle

This file was deleted.

13 changes: 0 additions & 13 deletions HTMLToPDFExample/package.json

This file was deleted.

72 changes: 35 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,43 @@ Convert html strings to PDF documents using React Native

### Manual

#### iOS

2. Open your project in XCode, right click on [Libraries](http://url.brentvatne.ca/jQp8) and select [Add Files to "Your Project Name](http://url.brentvatne.ca/1gqUD).
3. Add `libRNHTMLtoPDF.a` to `Build Phases -> Link Binary With Libraries`
[(Screenshot)](http://url.brentvatne.ca/17Xfe).

#### Android
The android module pulls in iText to convert html to pdf. You are supposed to obtain a license for commercial use of iText.

- Edit `android/settings.gradle` to included

```java
include ':react-native-html-to-pdf'
project(':react-native-html-to-pdf').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-html-to-pdf/android')
```

- Edit `android/app/build.gradle` file to include

```java
dependencies {
....
compile project(':react-native-html-to-pdf')

}
```

- Edit `MainApplication.java` to include

```java
// import the package
import com.christopherdro.htmltopdf.RNHTMLtoPDFPackage;

// include package
new MainReactPackage(),
new RNHTMLtoPDFPackage()
```

## Usage
```javascript

Expand All @@ -40,7 +73,7 @@ var Example = React.createClass({
html: '<h1>PDF TEST</h1>', // HTML String

// ****************** OPTIONS BELOW WILL NOT WORK ON ANDROID **************
fileName: 'test', /* Optional: Custom Filename excluded extention
fileName: 'test', /* Optional: Custom Filename excluded extension
Default: Randomly generated
*/

Expand All @@ -52,7 +85,7 @@ var Example = React.createClass({
base64: true /* Optional: get the base64 PDF value
Default: false
*/

height: 800 /* Optional: 800 sets the height of the DOCUMENT that will be produced
Default: 612
Expand All @@ -71,7 +104,6 @@ var Example = React.createClass({
console.log(data.filePath);
console.log(data.base64);
});
// data.base64 will be empty if base64 is set to false
},

render() {
Expand All @@ -83,37 +115,3 @@ var Example = React.createClass({
}
});
```

## Example
The example project included demonstrates how you can create a PDF file from a html string and email it as an attachment using `react-native-mail`.

## Android
The android module pulls in iText to convert html to pdf. You are supposed to obtain a license for commercial use of iText.

- Edit `android/settings.gradle` to included

```java
include ':react-native-html-to-pdf'
project(':react-native-html-to-pdf').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-html-to-pdf/android')
```

- Edit `android/app/build.gradle` file to include

```java
dependencies {
....
compile project(':react-native-html-to-pdf')

}
```

- Edit `MainApplication.java` to include

```java
// import the package
import com.parkerdan.htmltopdf.RNHTMLtoPDFPackage;

// include package
new MainReactPackage(),
new RNHTMLtoPDFPackage()
```
Loading

0 comments on commit 2af3574

Please sign in to comment.