Open a new terminal and run the application.Softonic review PDF to HTML Converter: Quick and Easy Conversion Let Metro Bundler run in its own terminal. Once you start Metro Bundler it will run forever on your terminal until you close it. To start Metro bundler run following command npx react-native start cd ProjectNameįirst, you will need to start Metro, the JavaScript bundler that ships with React Native. Open the terminal again and jump into your project using. Let file = await nvert(options) Įxample to Make PDF in React Native from HTML Text 'Hello GuysHere is an example of pdf Print in React NativeTeam About React', Message: 'App needs access to Storage data', Title: 'External Storage Write Permission', Import RNHTMLtoPDF from 'react-native-html-to-pdf' Ĭonst = useState('') Ĭonst granted = await PermissionsAndroid.request( Open App.js in any code editor and replace the code with the following code App.js // Example to Make PDF in React Native from HTML Text Code to Make PDF in React Native from HTML Text □ Now we are ready to go to the code section. Please follow the below screenshot for a clear understanding. To enable the multidex which is required by HTML to PDF converter library open Yourproject -> android -> app -> adle and search for defaultConfig which comes under android and add multiDe圎nabled true READ_EXTERNAL_STORAGE: To read the SD card.įor more about the permission, you can see this post.WRITE_EXTERNAL_STORAGE: To store the PDF in the SD card.We are going to add the following permissions in the AndroidMnifest.xml We are accessing external storage so we need to add some permission in AndroidManifest.xml file. So to install pods use cd ios & pod install & cd. CocoaPods InstallationĪfter the updation of React Native 0.60, they have introduced autolinking so we do not require to link the library but need to install pods. This command will copy all the dependencies into your node_module directory, You can find the directory in node_module the directory named react-native-html-to-pdf. Run the following command npm install react-native-html-to-pdf -save Open the terminal and jump into your project cd ProjectName To use RNHTMLtoPDF we need to install react-native-html-to-pdf package. This will make a project structure with an index file named App.js in your project directory. Try uninstalling the cli and run the cli using npx. Note If the above command is failing, you may have old version of react-native or react-native-cli installed globally on your pc. If you want to start a new project with a specific React Native version, you can use the -version argument: npx react-native init ProjectName -version X.XX.X If you have previously installed a global react-native-cli package, please remove it as it may cause unexpected issues: npm uninstall -g react-native-cli the following commands to create a new React Native project npx react-native init ProjectName We are going to use react native command line interface to make our React Native App. Getting started with React Native will help you to know more about the way you can make a React Native project. You can also visit Print HTML as a Document from React Native App for Android and iOS. To complete this task we will use react-native-html-to-pdf library. In this example, we will create a PDF file from the HTML text after the click of a button in our App. Here is an Example to Make PDF in React Native from HTML Text.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |