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

206
Vistas
How to print dynamic pdf in React-Native

Print Data To PDF in React-Native. I have seen many tutorials but haven't got the exact answer to this question.

Invoice.js

 import React from 'react';
        import { View, SafeAreaView ,StyleSheet, ScrollView, Button, Platform, Text } from "react-native";
        import { Card } from "react-native-elements";
        import { DataTable } from "react-native-paper";
        import Pdf from "../components/Pdf";
        
        const Invoice = () => {
            return (
              <SafeAreaView>
                <ScrollView>
                  <Card>
                    <Text h3>Invoice #7654</Text>
                      <View>
                            <Text>
                            <Text style={{ fontWeight: "bold" }}>From:</Text>
                            {"\n"}Tata 56 view Pune
                            {"\n"}Email: sumit@.com
                            {"\n"}Phone: 5252146954
                          </Text>
                       </View>
                    <Pdf />
                  </Card>
                </ScrollView>
              </SafeAreaView>
            );
        }

        export default Invoice

Pdf.js

import * as React from 'react';
import { View, StyleSheet, Button, Platform, Text } from 'react-native';
import * as Print from 'expo-print';
import { shareAsync } from 'expo-sharing';
import RNPrint from 'react-native-print';
import Invoice from './Invoice';

export default function Pdf() {
  
  
  const printToFile = async () => {
    const { uri } = await Print.printToFileAsync({
      <Invoice />
    });
    console.log('File has been saved to:', uri);
    await shareAsync(uri, { UTI: '.pdf', mimeType: 'application/pdf' });
  }


  return (
    <View style={styles.container}>
      <View />
      <Button title="Print to PDF file" onPress={printToFile} />
    </View>
  );
}

const styles = StyleSheet.create({
  container:{
    marginTop: 20
  }
}); 

I want to print the Invoice.js which I am importing in pdf. Any suggestions on how to print PDF in React-Native?

about 4 years ago · Juan Pablo Isaza
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