react-native-suno-pdf
v1.0.7
Published
React Native Suno Pdf
Readme
react-native-suno-pdf
React native Suno Pdf generator
Installation
npm install react-native-suno-pdfUsage
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
