DEV Community

shyam manek
shyam manek

Posted on Edited on

React Native HTML to PDF NPM Package, File download Wrong filePath problem

Go directly to the source code in your node module

`
react-native-html-pdf -> android -> com -> christopherdro -> htmltopdf -> RNHTMLtoPDFModule.java
In the convert() function change this code block

`

File path = (Environment.MEDIA_MOUNTED.equals(state)) ?
          new File(mReactContext.getExternalFilesDir(null), options.getString(DIRECTORY)) :
          new File(mReactContext.getFilesDir(), options.getString(DIRECTORY));

Enter fullscreen mode Exit fullscreen mode

Replace With

File path =  new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), options.getString(DIRECTORY));


Enter fullscreen mode Exit fullscreen mode

Top comments (0)