Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Path to a file React Native

I have a pdf file in /assets/pdfs folder. I'm trying to display it but getting an empy page:

import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import Pdf from 'react-native-pdf';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
import Feather from 'react-native-vector-icons/Feather';

import Main from '../Main'

var RNFS = require('react-native-fs');

export default function ItalyUserAgreement({ navigation }) {
    const source = {uri: 'file://' + RNFS.DocumentDirectoryPath + '/assets/pdfs/thereactnativebook-sample.pdf'}
    console.log(source)

    return (
        <View style={styles.container}>
            <View style={styles.appBar}>
                <MaterialIcon name="arrow-back" size={32} color="#ffffff" backgroundColor={'none'} onPress={() => navigation.goBack()} />
                <Text style={styles.appBarText}>Italy</Text>
                <Feather name="x" size={32} color="#ffffff" backgroundColor={'none'} onPress={() => navigation.navigate(Main)} />
            </View>
            <Pdf
                source={source}
                style={styles.pdf}
            />
        </View>
    )
}

I've also tried:

const source = {uri: 'file://assets/pdfs/thereactnativebook-sample.pdf'} 

and

const source = require('/assets/pdfs/thereactnativebook-sample.pdf')

But none of those worked for me

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

These are all the possible ways as stated in the docs:

// const source = { uri: 'http://samples.leanpub.com/thereactnativebook-sample.pdf', cache: true };
// const source = require('./test.pdf');  // ios only
// const source = {uri:'bundle-assets://test.pdf' };
// const source = {uri:'file:///sdcard/test.pdf'};
// const source = {uri:"data:application/pdf;base64,JVBERi0xLjcKJc..."};
// const source = {uri:"content://com.example.blobs/xxxxxxxx-...?offset=0&size=xxx"};
// const source = {uri:"blob:xxxxxxxx-...?offset=0&size=xxx"};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!