npm.io
1.0.7 • Published 1 year ago

react-native-suno-pdf

Licence
MIT
Version
1.0.7
Deps
0
Size
27 kB
Vulns
0
Weekly
0

react-native-suno-pdf

React native Suno Pdf generator

Installation

npm install react-native-suno-pdf

Usage

import { useEffect, useState } from 'react';
import { StyleSheet, View, Text, Platform } from 'react-native';
import { convert, type PdfOption, type PdfResult } from 'react-native-suno-pdf';

export default function App() {
  const [result, setResult] = useState<string>('No files');
  const initialize = async () => {
    if (Platform.OS === 'android') {
      const option: PdfOption = {
        html: '<html><body><p>Test pdf generator</p></body></html>',
        fileName: 'sunopdfexample',
        directory: '/Android/data/com.sunopdfexample/cache',
        padding: 0,
        bgColor: '',
      };
      const pdfResult: PdfResult = await convert(option);
      setResult(pdfResult.filePath);
    } else {
      const option: PdfOption = {
        html: '<html><body><p>Test pdf generator</p></body></html>',
        fileName: 'sunopdfexample',
        directory: 'Documents',
        padding: 0,
        bgColor: '#ffffff',
      };
      const pdfResult: PdfResult = await convert(option);
      setResult(pdfResult.filePath);
    }
  };
  useEffect(() => {
    initialize();
  }, []);

  return (
    <View style={styles.container}>
      <Text>Result: {JSON.stringify(result)}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  box: {
    width: 60,
    height: 60,
    marginVertical: 20,
  },
});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Keywords