Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda