1.0.3 • Published 3 years ago

react-native-html-to-base64image v1.0.3

Weekly downloads
23
License
-
Repository
-
Last release
3 years ago

react-native-react-native-html-to-base64image

Getting started

$ yarn add react-native-html-to-base64image

Mostly automatic installation

$ react-native link react-native-html-to-base64image

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-react-native-html-to-base64image and add RNReactNativeHtmlToBase64image.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNReactNativeHtmlToBase64image.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNReactNativeHtmlToBase64imagePackage; to the imports at the top of the file
  • Add new RNReactNativeHtmlToBase64imagePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-react-native-html-to-base64image'
    project(':react-native-react-native-html-to-base64image').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-react-native-html-to-base64image/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-react-native-html-to-base64image')

Usage

import HTMLtoBase64Image from 'react-native-html-to-base64image';

// TODO: What to do with the module?
RNReactNativeHtmlToBase64image;

export default class App extends Component{
  async createBase64Image() {
    let options = {
        html: '<h1>HTML</h1>',
        fileName: 'invoice',
        directory: 'VNPTRes',
        height: 1500,
        width: 500
      };

    let file = await HTMLtoBase64Image.convert(options)
    console.log(file);
  }
  render(){
    return(
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <TouchableOpacity style={{width: 200, height: 100, backgroundColor: 'green'}} onPress={this.createBase64Image}>
          <Text>ABC</Text>
        </TouchableOpacity>
      </View>
    );
  }
}