Overview:
React-native-html-to-pdf is a library that allows users to convert HTML strings to PDF documents using React Native. This tool simplifies the process of generating PDFs from HTML content for mobile applications.
Features:
- Automatic linking with
react-native link - Manually integrate for iOS and Android
- Customizable filename and output directory
- Option to return base64 string of PDF file
- Adjustable document dimensions for height and width
- Customizable padding for iOS
- Custom font integration for Android
- Dynamic permission handling for Android M and above
Installation:
To install the react-native-html-to-pdf library, you can follow these steps:
Run
npm install react-native-html-to-pdf --savein your project directory.For automatic linking, run
react-native link.For manual integration on iOS:
- Add
libRNHTMLtoPDF.ato Build Phases -> Link Binary With Libraries in XCode. - Update
android/settings.gradleandandroid/app/build.gradle. - Adjust
MainApplication.javaandAndroidManifest.xmlas mentioned.
- Add
For Android-specific font customization, provide an array of custom fonts in the appropriate format.
Summary:
React-native-html-to-pdf is a versatile tool for React Native developers to convert HTML strings to PDF documents effortlessly. With features like automatic and manual integration, customizable output options, and platform-specific settings, this library offers flexibility and ease of use for PDF generation in mobile applications.