🔴 How to Create PDF from HTML in React-Native | Export PDF from HTML | React-Native

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2024

ความคิดเห็น • 58

  • @samur44i
    @samur44i 2 ปีที่แล้ว +1

    cool

  • @irfaniffi5279
    @irfaniffi5279 ปีที่แล้ว +1

    thanks man! your video helped me alot ❤

  • @victorhugomartinezzamora1639
    @victorhugomartinezzamora1639 3 ปีที่แล้ว +3

    Thank you! Your video helped me a lot

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +1

      Glad it helped!!

  • @diogomota4126
    @diogomota4126 2 ปีที่แล้ว +1

    congratulations thank you

  • @acepew9091
    @acepew9091 2 ปีที่แล้ว +3

    does anyone has a problem saying possible unhandled promise rejection? please help

  • @saxenavedant61
    @saxenavedant61 3 ปีที่แล้ว +4

    How to use state data in this, data being an array iterating over it and making dynamic table ?

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +2

      You have to create function for it and construct data by pushing in array with html's table tag "tr" and "td" and store it into state variable and then can pass that state into html content..

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +3

      checkout this th-cam.com/video/fnwiIWUlo8U/w-d-xo.html
      I have created dynamic table in html then created pdf, it will help you.

    • @saxenavedant61
      @saxenavedant61 3 ปีที่แล้ว +1

      @@vishalpwr thanks 👍

  • @southredmondtoxik1885
    @southredmondtoxik1885 ปีที่แล้ว +1

    Bro how to add network images and local images?.
    When I add network images it doesn't appear.

    • @vishalpwr
      @vishalpwr  ปีที่แล้ว

      You have to use HTML tags for that!

    • @southredmondtoxik1885
      @southredmondtoxik1885 ปีที่แล้ว +1

      @@vishalpwr I already used HTML tags bro. But it didn't show atleast it's space.
      But i did with expo. Can I?

  • @AnandKumarSingh-r3o
    @AnandKumarSingh-r3o 5 หลายเดือนก่อน

    iOS how to show header and footer on all the pages

  • @edgarcandales2191
    @edgarcandales2191 3 ปีที่แล้ว +1

    How did you get the html code of that pdf file? I mean I need to do something similar, but with a different pdf document. The problem is that I dont know how to convert it into html.

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +1

      I didn't convert pdf into html, I just get that html code from internet and used here, you can also google it and find html code as per your requirement and create pdf 😎.

  • @spinoops
    @spinoops 3 ปีที่แล้ว +1

    Hi, I'm desperately looking to create Header/Footer in each pages in my pdf. Do you know a solution ? Thanks !

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +1

      You can check html design on web, You'll get designs(template) as per your requirement, or HTML is very simple markup language so you can easily customize any design according to your need.

    • @axelmy
      @axelmy ปีที่แล้ว

      @@vishalpwr I don't think this really answers the question as their is no way to say "I want the same footer on every page". Did anyone find a solution yet ?

  • @fernandoruizmorales8555
    @fernandoruizmorales8555 3 ปีที่แล้ว +2

    Could you generate a pdf but with data extracted from the database? I would love for you to show an example greetings from Mexico

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +3

      Okay, I will try.
      Please like share and subscribe.

  • @vishalpwr
    @vishalpwr  2 ปีที่แล้ว +1

    Checkout Expo Example: th-cam.com/video/fnwiIWUlo8U/w-d-xo.html
    Source Code: github.com/vishalpwr/Expo-App

    • @nguyentuanminh6916
      @nguyentuanminh6916 2 ปีที่แล้ว

      Could I have htmlContent code please?

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      it's on repo you can download/copy it. or if your requirement is different then you can just search on google for it.

  • @everton7982
    @everton7982 2 ปีที่แล้ว

    How do I save the file in a specific folder on my device, it is saving in the com. from the app that is there in android\data\media\com.myapp ?

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      You can set {directory: 'Download',} name
      but in some device it may not be work then it is stored in default dir.

    • @everton7982
      @everton7982 2 ปีที่แล้ว

      @@vishalpwr So it is saving the file in the com folder. from the app which is in android\data\media\com.myapp, I need it to save the file in storage/emulated/0/myapp

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      Instead of 'Download' you can use other dir like 'Documents' ,
      or try with other dir also like 'pdf'. (this is working in real device)
      if it is not work then may be you need to do search on the internet/stackoverflow or may be need legacy support in android.

  • @sujayc6864
    @sujayc6864 2 ปีที่แล้ว

    in this video when you export pdf it is stored in/storage/emulated/0/Download/---.pdf and I followed same procedure but the file is storing in root directory of the application i.e. /storage/emulated/0/Android/data/com.mypackage/files/Download/---.pdf
    Any idea what to do about this?? or plz update all package and check if your app is still working fine

    • @ikennaudokporo6061
      @ikennaudokporo6061 2 ปีที่แล้ว

      Hello Sujay,
      Did you ever solve this issue and how did you do it please?

    • @sujayc6864
      @sujayc6864 2 ปีที่แล้ว

      @@ikennaudokporo6061 I used react native print and saved it as pdf, this way you can save it in downloads

  • @TemitopeJoshua10
    @TemitopeJoshua10 2 ปีที่แล้ว

    Please how can create multiple pages inside the pdf library is very adjust.

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      It's totally depends on your HTML content.

  • @HimanshuNanikwal
    @HimanshuNanikwal 2 ปีที่แล้ว

    hello, I have followed the same but getting error like ' Cannot call a class as a function' can you please help

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว

      Make sure you have used functional component as shown in tutorial, or you can checkout the repo(link in the description)
      checkout this if used class component->
      stackoverflow.com/questions/38481857/getting-cannot-call-a-class-as-a-function-in-my-react-project

  • @ChandruChandru-ts7nz
    @ChandruChandru-ts7nz ปีที่แล้ว

    I did same like what you did but for me pdf is not downloading it only showing the file path

    • @vishalpwr
      @vishalpwr  ปีที่แล้ว +1

      It is also depends on OS version and permissions please check and provide necessary permission.

  • @byanberlian102
    @byanberlian102 3 ปีที่แล้ว +1

    why if I use it in the expo can't ?

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +2

      Expo doesn't support linking, so you can't use this package in expo,
      you can try expo print for this 👇
      docs.expo.dev/versions/latest/sdk/print/#printprinttofileasyncoptions

    • @byanberlian102
      @byanberlian102 3 ปีที่แล้ว +1

      @@vishalpwr u can give me the tutorial for this ?

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +1

      Okay, I will try 😇.

    • @byanberlian102
      @byanberlian102 3 ปีที่แล้ว +1

      @@vishalpwr thank you brother , i'll wait

    • @vishalpwr
      @vishalpwr  3 ปีที่แล้ว +1

      check out this: th-cam.com/video/fnwiIWUlo8U/w-d-xo.html
      Create Pdf in expo.

  • @zingjj6855
    @zingjj6855 2 ปีที่แล้ว

    is there's more permission code? coz I just followed your steps but mine don't work in Android..:(

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      Please check in AndroidManifest.xml permissions, and also allow the permission from app, and let me know specific error you getting, also check the package doc maybe you missed something

  • @kaner.studio
    @kaner.studio 2 ปีที่แล้ว

    i got [TypeError: Cannot read property 'startsWith' of undefined] when opening file path. I'm using TypeScript and paste all your code to my project.
    let file = await RNHTMLtoPDF.convert(Options)
    Alert.alert('Thông báo','Xuất file PDF thành công:' + file.filePath,[
    {text:'Cancel',style:'cancel'},
    {text:'Open',onPress:()=>openFile(file.filepath)}
    ],{cancelable:true});
    }
    const openFile = (filepath: any) => {
    const path = filepath;
    FileViewer.open(path)
    .then(()=>{
    //success
    console.log(`Successfully export PDF file`);

    })
    .catch(error => {
    console.log(error);
    });
    }

  • @mariamikram1959
    @mariamikram1959 2 ปีที่แล้ว

    What do i do to make this pdf file shareable too?

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +2

      You can use React Native share module for that and share exported pdf uri(path).

    • @mariamikram1959
      @mariamikram1959 2 ปีที่แล้ว +1

      @@vishalpwr thanks ❤️👍

  • @JaskaranSingh-nq5oy
    @JaskaranSingh-nq5oy 2 ปีที่แล้ว

    I am getting permission error

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      What error you getting?

    • @JaskaranSingh-nq5oy
      @JaskaranSingh-nq5oy 2 ปีที่แล้ว

      @@vishalpwr like it's not going to create pdf function. Error is please give external write permission. I copied the exact code

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      have you added permission in android AndroidManifest.xml file?
      If not then copy permissions from repo, get link in description.

    • @JaskaranSingh-nq5oy
      @JaskaranSingh-nq5oy 2 ปีที่แล้ว

      @@vishalpwr yes I have added the permission

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว

      Have you given access from your device to the app to use external storage?

  • @favournnabue7523
    @favournnabue7523 2 ปีที่แล้ว

    getting error "Possible Unhandled Promise Rejection (id: 6):
    ReferenceError: Can't find variable: RNHTMLtoPDF
    _callee$" help any solution?

    • @vishalpwr
      @vishalpwr  2 ปีที่แล้ว +1

      Please check that dependency installed successfully or not.
      also check you imported RNHTMLtoPDF with the same name in your component.