Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.3.0 #22

Merged
merged 1 commit into from Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
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
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()
```