diff --git a/README.md b/README.md index 39aa964..9d6808e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ - ## PDF Generator for React Native. -Is a light weight native library that transform HTML to PDF, or even better transform the content of a URL like ```https://google.com``` into a PDF. +Is a light weight native library that transform HTML to PDF, or even better transform the content of a URL like `https://google.com` into a PDF. The PDF is returned in base64 format so you can use more specialized modules to mail, sharing, visualizing, etc. @@ -15,17 +14,14 @@ For Android it just use [WebView](https://developer.android.com/reference/androi #### Changelog -**1.6.4:** Adding React Native ``0.6x`` compatibility. +**1.6.5:** Added maven plugin on android build.gradle for compatibility with gradle 7.x version. +**1.6.4:** Adding React Native `0.6x` compatibility. **1.6.1:** Removed deprecated UIWebView. - ### Supported Devices -* iOS >=8 -* Android >=19 - - - +- iOS >=8 +- Android >=19 ## Getting started @@ -42,39 +38,32 @@ To install the library: [hard way...](https://facebook.github.io/react-native/docs/linking-libraries-ios) - ### Usage To transform raw HTML into PDF: ```javascript -import PDF from 'rn-pdf-generator'; +import PDF from "rn-pdf-generator" PDF.fromHTML(`

HELLO WORLD

`, `http://localhost`) - .then( data => console.log(data)) // WFuIGlzIGRpc3Rpbm.... - .catch( err => console.log('error->', err) ) + .then(data => console.log(data)) // WFuIGlzIGRpc3Rpbm.... + .catch(err => console.log("error->", err)) ``` -> In case you this HTML fetch resources from external servers you can specify the location using the second parameter ````. +> In case you this HTML fetch resources from external servers you can specify the location using the second parameter ``. Transforming a remote webpage: ```javascript +import PDF from "rn-pdf-generator" -import PDF from 'rn-pdf-generator'; - -PDF.fromURL('https://www.google.com/') - .then( data => console.log(data)) // WFuIGlzIGRpc3Rpbm.... - .catch( err => console.log('error->', err) ) - +PDF.fromURL("https://www.google.com/") + .then(data => console.log(data)) // WFuIGlzIGRpc3Rpbm.... + .catch(err => console.log("error->", err)) ``` -### Demo - +### Demo -[This demo](https://github.com/cesarvr/react-native-pdf-generator-demo) that generates a PDF and then display it using [react-native-pdf plugin](https://www.npmjs.com/package/react-native-pdf). +[This demo](https://github.com/cesarvr/react-native-pdf-generator-demo) that generates a PDF and then display it using [react-native-pdf plugin](https://www.npmjs.com/package/react-native-pdf). ![Demo](https://github.com/cesarvr/react-native-pdf-generator-demo/blob/master/demo-img/pdf_document.gif?raw=true) - - - diff --git a/android/build.gradle b/android/build.gradle index b4da54a..a11b497 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,7 +12,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 28 def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' -def DEFAULT_MIN_SDK_VERSION = 16 +def DEFAULT_MIN_SDK_VERSION = 19 def DEFAULT_TARGET_SDK_VERSION = 28 def safeExtGet(prop, fallback) { @@ -20,7 +20,7 @@ def safeExtGet(prop, fallback) { } apply plugin: 'com.android.library' -apply plugin: 'maven' +apply plugin: 'maven-publish' buildscript { // The Android Gradle plugin is only required when opening the android folder stand-alone. @@ -39,7 +39,7 @@ buildscript { } apply plugin: 'com.android.library' -apply plugin: 'maven' +apply plugin: 'maven-publish' android { compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) @@ -124,12 +124,12 @@ afterEvaluate { project -> } task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from androidJavadoc.destinationDir } task androidSourcesJar(type: Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from android.sourceSets.main.java.srcDirs include '**/*.java' } @@ -148,12 +148,11 @@ afterEvaluate { project -> archives androidJavadocJar } - task installArchives(type: Upload) { - configuration = configurations.archives - repositories.mavenDeployer { - // Deploy to react-native-event-bridge/maven, ready to publish to npm - repository url: "file://${projectDir}/../android/maven" - configureReactNativePom pom + publishing { + publications { + maven(MavenPublication) { + artifact androidSourcesJar + } } - } + } } diff --git a/package.json b/package.json index 9632c5b..735881b 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,33 @@ { - "name": "rn-pdf-generator", - "version": "1.6.4", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://github.com/cesarvr/react-native-pdf-generator.git" - }, - "keywords": [ - "react-native", - "pdf", - "generator", - "html to pdf", - "html2pdf" - ], - "author": { - "name": "Cesar Valdez", - "email": "cvaldezrx@gmail.com" - }, - "license": "MIT", - "peerDependencies": { - "react": "^16.8.1", - "react-native": ">=0.60.0-rc.0 <1.0.x" - }, - "devDependencies": { - "react": "^16.9.0", - "react-native": "^0.61.5" - } + "name": "rn-pdf-generator", + "version": "1.6.5", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/cesarvr/react-native-pdf-generator.git" + }, + "keywords": [ + "react-native", + "pdf", + "generator", + "html to pdf", + "html2pdf" + ], + "author": { + "name": "Cesar Valdez", + "email": "cvaldezrx@gmail.com" + }, + "license": "MIT", + "peerDependencies": { + "react": "^16.8.1", + "react-native": ">=0.60.0-rc.0 <1.0.x" + }, + "devDependencies": { + "react": "^16.9.0", + "react-native": "^0.61.5" + } }