How to download remote PDF files in React Native

Photo by Rodion Kutsaev on Unsplash

In this post, I will document my learning on downloading remote pdf files on iOS and android.

Setup the project: Let’s first create a blank project by hitting,

npx react-native init DownloadPdf

It will just have one button that will try to download this sample pdf file. This is our initial code,

Download PDF: Now, let’s write our download functionality. Before that, we will need to download 2 modules.

  1. react-native-blob-util: great library for downloading files.
  2. react-native-share: for iOS, we would like to save the files on our phone, hence the share library.

here is the gist,https://saadbashar.medium.com/media/3e3449377bf362935f1b5d62f371c3ad

Output of the functionality:

Android & iOS download pdf

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *