How to download remote PDF files in React Native

Saad Khan
Sep 25, 2022

--

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,

Output of the functionality:

Android & iOS download pdf

Sign up to discover human stories that deepen your understanding of the world.

--

--

Saad Khan
Saad Khan

Written by Saad Khan

Mobile App Dev (Mainly focused on React Native)

Responses (2)

Write a response