How to Create PDFs With Node JS and React

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2019
  • In this video you will learn how to generate dynamic PDFs using Node JS and React. PDFs are going to be generated from an HTML file. Anything that you can write in HTML and CSS can be converted to a dynamic PDF.
    GitHub Repository - github.com/adrianhajdin/tutor...
    Article on Medium - / kvihzkiv2t
    HTML Template - gist.github.com/adrianhajdin/...
    If you found this video educational, a subscribe would mean a lot, a lot of interesting tutorials are coming - bit.ly/2ArnMyb.
    Many of you had requested that I create a patreon, here it is, you get the chance to become one of the first supporters - / javascriptmastery .
    Learn Async/Await - bit.ly/2Q2i2Qb
    Learn ES6 - bit.ly/2s19DD8
    Don't click this link - bit.ly/2ArnMyb
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @TheChinobi23
    @TheChinobi23 5 ปีที่แล้ว +26

    Thank. You for the video. Is a nice code to implement in many applications

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

      Glad you find value in it, many more tutorials are coming soon!

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

      JavaScript Mastery awesome!! Good job

  • @sadraquesantos9766
    @sadraquesantos9766 5 ปีที่แล้ว +14

    I've been looking for a simple solution like this for months, thanks for the tutorial.

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

      Glad you finally stumbled upon my video! 😀

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

    I had to watch so many videos until I found you :) Thank you so much for the great video. This is perfect for all sorts of web applications!

  • @chris_and_music
    @chris_and_music 4 ปีที่แล้ว +12

    Thank you so much!
    Just a tip for anyone who is interested in just making a Post request and download the pdf WITHOUT creating it in the local computer (you will need to use Fetch instead of Axios)
    //Node
    server.post("/create-pdf", (req, res) => {
    pdf.create(pdfTemplate()).toBuffer(function (err, buffer) {
    if (err) return res.send(err);
    res.type("pdf");
    res.end(buffer, "binary");
    });
    });
    //React
    createAndDownloadPdf = () => {
    fetch("/create-pdf", {
    method: "POST",
    body: JSON.stringify(this.props),
    }).then((res) => {
    res.arrayBuffer().then((res) => {
    var blob = new Blob([res], { type: "application/pdf" });
    saveAs(blob, "newPdf");
    });
    });
    }

    • @AdithyaKahawanugoda
      @AdithyaKahawanugoda 3 ปีที่แล้ว

      this method doesn't work,it shows pdf file can not open

    • @afaque.
      @afaque. 3 ปีที่แล้ว

      it just solved the error I was having from html-pdf

    • @afaque.
      @afaque. 3 ปีที่แล้ว

      but now ALL PDF ARE CORRUPTED so thanks but no thanks

    • @AdithyaKahawanugoda
      @AdithyaKahawanugoda 3 ปีที่แล้ว

      @@afaque. means?

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

    Awesome. Thank you for such a great tutorial!

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

    Thank you for the video, excelent content. Cheers from Norway!

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Thanks man, since I am just starting, it really means a lot! Stay tuned for more! :)

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

    Thank you so much, you have no idea how big of a problem you have solved for me. God bless you!! Thanks alot for making this tutorial!!

  • @thanishahamed4755
    @thanishahamed4755 3 ปีที่แล้ว

    Cheers from Sri Lanka! Found the sollution with easy steps to use in my applications 🙂

  • @girishthatte
    @girishthatte 4 ปีที่แล้ว

    Thanks a lot dude ... Your video is really awesome and also had nice explanation !

  • @devanshbhushan1057
    @devanshbhushan1057 3 ปีที่แล้ว

    Thanks a lot!! Your code helped me a lot!!

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

    Thank you for the tutorial!

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

    Very nice project, and very useful, thanks man

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

    Top video !
    Thanks a lot !
    Advice : +zoom on IDE

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Thanks man, I will definitely zoom it for the next vid!

  • @risingstars6852
    @risingstars6852 3 ปีที่แล้ว

    Thanks for great tutorial

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

    Thank you. Cool Tutorial :)

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Since I'm just starting out, I extremely appreciate any feedback, thanks! 😊

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

    very well explained.

  • @rodrigomartinez1202
    @rodrigomartinez1202 5 หลายเดือนก่อน

    Amazing video man!!

  • @allancoder
    @allancoder 5 ปีที่แล้ว +5

    All of your videos are great buddy, keep up the good work. Please increase the font size of the VS code in future videos so that the code is clearly visible on smaller screens too. 😁😃

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Thanks, I'm just starting out. Planning to improve the audio quality and much more.
      Thanks for the recommendation, I will definitely increase font size! 😀

  • @johnfazio2513
    @johnfazio2513 3 ปีที่แล้ว

    Great video, I subscribed

  • @user-sh8bl3ij9v
    @user-sh8bl3ij9v 5 ปีที่แล้ว +1

    Thanks for knowledges.

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

    great vid. Thanks!

  • @juhikh6544
    @juhikh6544 4 ปีที่แล้ว

    You are awesome!!! Thanks!!!

  • @nishantkumar6960
    @nishantkumar6960 3 ปีที่แล้ว

    Thank you so much !!!

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

    Thanks. Very usefull

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

    Thanks man! But I have some problems. Why aren't some css properties like flex supported?

  • @user-de8ev2bn2d
    @user-de8ev2bn2d 4 ปีที่แล้ว

    FileSaver is built for saving client side generated content, but if the content is coming from a server then there is different ways to achieve the goal of saving the file downloaded from the cloud.

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

    really good video!

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

    this is amazing video , do you have any suggestions about how to edit the number of products dynamically ?

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

      The list of products should be in an array, use the map function and return the div in string format

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

    Hi really nice video . Perfectly solves my problem . Just a question how to do multiple page pdf in it ? whatever HTML I am writing its generating single page PDF only. And if header and footer can be added for each page constant will be awesome

  • @willigeek2013
    @willigeek2013 4 ปีที่แล้ว

    The timing of this tutorial is perfect. i was wondering how would you access the data in the pdf file if the dynamic data were saved in a database first ( nedb ) for example ?

    • @Shadyholic
      @Shadyholic 4 ปีที่แล้ว

      did this work for you ? even when i downloaded the files from github it still isn't working... did you had any problems ?

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

    Thank you

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

    goodjob dude

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

    Thank you,

  • @lamarlaing4997
    @lamarlaing4997 5 ปีที่แล้ว

    Hi, thanks for this video. Im using Laravel with react, does this work in that framework?

  • @SarahAbouyassine
    @SarahAbouyassine 4 ปีที่แล้ว

    Hii .. Thank you very much for this video its very very helpful .. but I just want to ask how can i send an array and export it and display it on the table (server html code) ?? pleaase i really need your help

  • @huirenchuah3597
    @huirenchuah3597 4 ปีที่แล้ว

    how to actually use this with functional component in react like hooks. Do I need to like specify const [name, setName]=useState(' ')??

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

    Thank you for this tutorial mate🙌.
    One doubt, what if we want to include CSS file externally i.e using ?
    Will this still work or not?

  • @elie3423
    @elie3423 4 ปีที่แล้ว

    to run nodemon, type one of these in the terminal:
    npm install -g nodemon
    OR
    yarn global add nodemon

  • @andygolem5514
    @andygolem5514 4 ปีที่แล้ว +5

    Hi there how would get dynamic data to appear in the pdf document, more specifically if I have a list that I am sending to the pdf renderer, how can I display the list items dynamically, can I use a for loop or map function in my document template?

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

      I have the same issue...Did you find any solutions?

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

    Thanks for very helpful video. Can we use similar HTML templates to print any reports from ReactJS application. If so, can you make a video that shows how we store these templates in backend and then, based on the user choice, get a template into ReactJS application using a REST API and use it in printing a report. Thanks

  • @ArmandoHinojosaCcamaSARC
    @ArmandoHinojosaCcamaSARC 4 ปีที่แล้ว

    Thank you for this ^_^ !!!

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

    Can you demonstrate printing react component

  • @fayequehannan2473
    @fayequehannan2473 4 ปีที่แล้ว

    Please zoom in your screen..its is difficult to watch on mobiles...otherwise video is great and helps me a lot..thank you

  • @alanalvarado9151
    @alanalvarado9151 4 ปีที่แล้ว

    Hi, nice work. Works for react-native too?

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

    Awesome!

  • @karamokanagi9296
    @karamokanagi9296 5 ปีที่แล้ว

    Its a good video. is it possible to get the data from the database and print a pdf file once a button is click.... Please help me this. Thanks

  • @nikicamaksimovski9964
    @nikicamaksimovski9964 4 ปีที่แล้ว

    Great video, and very simple too.
    Just one problem, when I change state, and try to download the pdf, we still get the old data, and we need to download again to get the data we want.

    • @nikicamaksimovski9964
      @nikicamaksimovski9964 4 ปีที่แล้ว

      Little change in the post request fixes the problem :)
      app.post('/create-pdf', (req, res) => {
      pdf.create(pdfTemplate(req.body), {}).toFile('result.pdf', (err, response) => {
      if(err) res.send(Promise.reject())
      else {
      if(response) res.send(Promise.resolve())
      }
      })

      })

  • @BulletSP
    @BulletSP 3 ปีที่แล้ว

    Hi, I am able to create the entire pdf , (display grid and flex-box not working) just not getting the css styling from tag.. Please help!

  • @syedmujeebh4401
    @syedmujeebh4401 3 ปีที่แล้ว

    Pls make a video on parsing pdf with streams buffers and chunks

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

    can you create a dropdown in html and save it as pdf with dropdown format included in the pdf. meaning when it save as pdf the dropdown still option on the pdf. i want to create a form that save from html to pdf with the bottom option have a dropdown for the manager to finish fill out

  • @aneekaatrocities2489
    @aneekaatrocities2489 4 ปีที่แล้ว

    Looks like this is based on phantom js . People say its deprecated and no more in future. So is this html-pdf good one to go with for future?

  • @androsanju2526
    @androsanju2526 4 ปีที่แล้ว

    Please also explain commands for Windows users.

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

    Awesome. Like the other comments.. I've been searching for a pdf generator tutorial for a while now. Also, how is it possible to create a pre-designed PDF and then just have your input fields populate it to create your pdf forms? So it's not generating the html, only the data entered? Many thanks.

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

      Ps: I know how to design a pdf in indesign and acrobat and to label the input fields. The question is about just the input data populating from a web form to a pre-designed uploaded pdf. Thanks.

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

      This article might help - stackoverflow.com/questions/1757397/how-can-i-merge-data-into-an-xdp-file-and-return-a-pdf-via-net

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

      @@javascriptmastery Thanks I'll take a look

  • @enesgungor6788
    @enesgungor6788 3 ปีที่แล้ว

    I have a HTML file and I want to convert it to pdf. I followed the video but my program doesnt work correctly . When I run HTML code separately it working very well but when I convert it to pdf it is crushing . Flexbox isnt work correctly . How can I fix that ?

  • @danielwaiter9990
    @danielwaiter9990 4 ปีที่แล้ว

    Is it possible to generate PDF from an object array as well ?? If so, how ? Thanks

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

    thanks for the Great tutorial!
    i need some help since i have a blank page downloaded

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Is the code exactly the same as in the video? You can also check the Medium article in description and then compare it.

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

      @@javascriptmastery yes the code is the same in the video! the problem that i don't get any error, i think it's something with the create or toFile method...

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      @@mannaimounir1358 contact me on Instagram @javascriptmastery so we can try to resolve the issue :)

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

    Great video. Can anyone tell how to apply your choice of Logo as image and use it in real life Project? Thanks

    • @kamildziech2021
      @kamildziech2021 4 ปีที่แล้ว

      Did you solve this problem? I want to know because I have the same :/

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

      @@kamildziech2021 Have you tried saving the image in your React project folder and importing it in whatever component you want to use it in?

  • @samrat7858
    @samrat7858 4 ปีที่แล้ว

    How to loop through an array inside the html template ?

  • @jhmesseroux
    @jhmesseroux 3 ปีที่แล้ว

    if i'm using fetch how can i get the res.data cause i tried with res.body , res.json() it did work , someone can help me please ??

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

    Can we use inside the template string? will it work

  • @Victor-wh9bs
    @Victor-wh9bs ปีที่แล้ว

    ThankU

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

    I'm just getting the error "__dirname is not defined" in my server console. The receipt is generated. Any solutions?

  • @changhaoliu7119
    @changhaoliu7119 4 ปีที่แล้ว

    Can you explain where you put "_dirname"? Thank you!

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

    Awesome video +++++++++++++ 😃

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

    How would you do this if you wanted a multi-page pdfs? How do you specify page breaks?

    • @zuzukouzina-original
      @zuzukouzina-original 2 ปีที่แล้ว

      He can’t answer this question, it’s just a simple hello world code he is showing.

  • @abelmurua6980
    @abelmurua6980 8 หลายเดือนก่อน

    Nice video! can I create a template using TailwindCss?

  • @xxMegha33xx
    @xxMegha33xx 4 ปีที่แล้ว

    Hey! I have done this and I am getting Cannot Get / error when I run my server. Can anyone please please help me with that?

  • @ahmedali006
    @ahmedali006 หลายเดือนก่อน

    how do i store the generated pdf to my phone (I'm developing this in react native)

  • @tacituskilgore2258
    @tacituskilgore2258 3 ปีที่แล้ว

    which theme do you use?

  • @trisutrisnoadri980
    @trisutrisnoadri980 4 ปีที่แล้ว

    If you are experiencing this error:
    AssertionError:
    html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'
    Module 'html-pdf' needs a dependency called phantom-js. We should install prebuilt-phantomjs module on the server side via terminal
    cd..
    cd server
    npm install phantomjs-prebuilt@2.1.13

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

    Is it just me or did he increased the speed of whatever he was saying at 8:06? I didn't understand anything. I literally had to check the speed of the video

  • @shneorBachar
    @shneorBachar 3 ปีที่แล้ว

    thanks!!!!!!! How to display images using node.js server??? INTO INDEX.JS

  • @YuriiKratser
    @YuriiKratser 3 ปีที่แล้ว

    Hi! Thanks! Does it support Russian or Chinese languages?

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

    .then().then() was calling api's two time in my case so it was not working
    So you can simply use async and await

  • @arpanmaji3596
    @arpanmaji3596 3 ปีที่แล้ว

    how to delete the generated file in backend after download

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

    great tutorial , but the thing is . I dont have the Render() function generated

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      What exactly are you referring to? What minute in the video?

    • @amineselmi8380
      @amineselmi8380 5 ปีที่แล้ว

      @@javascriptmastery When i do generate a react projet , i do no have the " class App extends component " , i just have function App { } . And the render function under it , i dont have it . I think its a new version of react and i m having issues applying your tutorial in it . would it be cool if you help me out with it ? ' discord '

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      In that case, simply copy the render code I have. You should be good to go then.

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

    How to create template with Array of Objects? please reply...

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

    Why is flexbox not working in the template?

  • @samking618
    @samking618 2 หลายเดือนก่อน

    backend guys, how do you guys work with in templates (HTML & CSS) in real apps? For e.g I want to create invoice pdf using a template, so is there a way to generate templates with our desired look and feel from somewhere or we have to write HTML and CSS from scratch ourself?

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

    Good video, but it is so hard to see your screen and the code compared to alot of coding videos I watch

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Don't worry, I will definitely bump up the font size for the next video! :)

  • @stefanomartell8413
    @stefanomartell8413 5 ปีที่แล้ว

    Awesome video! Does this store the newly generated PDF in the backend? What I want to accomplish is that the user clicks a link and a PDF is automatically generated. All the needed data is already in the frontend. Thanks!

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Yes! The pdf gets stored in the server! :)

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

      JavaScript Mastery in a database? Where exactly?

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

      @@stefanomartell8413 check 25:20 of the video, under the server directory. There is results.pdf.

    • @stefanomartell8413
      @stefanomartell8413 5 ปีที่แล้ว

      JavaScript Mastery Right I see, one doubt I have about that is that say I have 200 users in my app. Whenever one of them clicks on the pdf button generation it will create a mew file and store it in my db? Or results.pdf is only a temporary file that is destroyed righr after the backend sends it to the frontend, and its overwriten by the next generated file? Thanks a lot man!

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      @@stefanomartell8413 whenever user creates a new file, the previous one will be overwritten because it has the same name (in this case) if you want to avoid that, you may want to give every result a new id as a name. There are a lot of libraries that do that, but you could also create a timestamp in milliseconds as a name.
      That way, a lot of pdfs will be generated, every one under the different name.
      Hope I answered your question!

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

    html-pdf is now deprecated.

  • @testingpro4378
    @testingpro4378 4 ปีที่แล้ว

    sir i face "Internal server error 500" please suggest any solution

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

    wonder if i can get some help, I'm getting an error where my browser is unable to open/read pdf file. Any thoughts?

    • @javascriptmastery
      @javascriptmastery  5 ปีที่แล้ว

      Did you manage to resolve the issue?

    • @redskater42
      @redskater42 5 ปีที่แล้ว

      @@javascriptmastery
      Negative. Got the server to send the file over to the client. However there was a error with opening the .pdf file with preview and chrome did not open PDF view either.
      The Error message read about a a damage or altered file. I'm wondering if it is to do with my res.sendfile() statement.

    • @Shadyholic
      @Shadyholic 4 ปีที่แล้ว

      @@redskater42 did you fix this ? make sure you have const pdfBlob = new Blob([res.data] , i switch to try something [res.data] to [res.body] and it gave me broken pdfs, but i have another problems the input aren't going into the pdf and I don't know why.

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

    Wouldn't it be a better solution to convert react to pdf directly on frontend

    • @zuzukouzina-original
      @zuzukouzina-original 2 ปีที่แล้ว

      I agree with you, it’s just he only knows this method from a blog on the internet, it’s a kind of copycat

  • @HrishikeshTS
    @HrishikeshTS 3 ปีที่แล้ว

    I seem to have an error in res.sendFile() in backend, or res.data in frontend.

    • @lukasmasevicius4865
      @lukasmasevicius4865 3 ปีที่แล้ว

      Make sure that you have correctly entered file path in backend. I would preffer smth like this: var file = path.join(__dirname, "result.pdf"); res.sendFile(file);
      Also when taking the response in the frontend use .then after axios.get

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

    please make complete JS course from zero to hero

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

      I already have one. Complete Path to JavaScript Mastery

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

      @@javascriptmastery not on youtube :(

  • @raihanuddin1167
    @raihanuddin1167 3 ปีที่แล้ว

    Pls kindly help me how can use daynamic value in mongobd use pdf

  • @TarcisioPqdt
    @TarcisioPqdt 3 ปีที่แล้ว

    I try this:
    pdf.create(html, { format: 'Letter' }).toFile('result.pdf', (err) => {
    if (err) return res.status(500).send(err)
    return res.status(200).send("ok")
    })
    but, it works only in my localhost environment.
    When I hosted my application on Azure, this function never returns anything! And azure gives me this error message: "The page cannot be displayed because an internal server error has occurred.". It does not execute the line: " if (err) return res.status(500).send(err)"
    I'm using, node 14.16.0, and my entire application works fine on Azure, only the html-pdf not works on it :(
    Does anyone have any ideas?

  • @EmilianoC76
    @EmilianoC76 4 ปีที่แล้ว

    I'm downloading a pdf but when opening the file it ways it's corrupt :(

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

    Can you update this tutorial? Thank you.

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

    Hi, I can't upload any image to my html template. Only borders and inscription from alt=" " are visible in pdf. Do you know how to solve this problem?

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

      Hey. Imagens can be displayed by setting .
      The trick is on "file:///" with 3 slashes. Hope this works.

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

      @@danieldebellis5039 yes, thanks

    • @swastikagarwal8605
      @swastikagarwal8605 4 ปีที่แล้ว

      @@danieldebellis5039 Hey can you help me with this im trying to configure it but its not working

    • @danieldebellis5039
      @danieldebellis5039 4 ปีที่แล้ว

      Of course! What’s going wrong?? Did you tried to put the 3 slashes after “file”? Are you working on mac, linux or windows?

    • @swastikagarwal8605
      @swastikagarwal8605 4 ปีที่แล้ว

      @@danieldebellis5039 ya so i tried file:/// and it worked for my local path , so i put C: etc, but i cant seem to figure it out for my directory so other people can use it as well, im using a directory pretty similar as this videos creator and i have an image folder inside the server folder so right beside documents which has index.js which has the html file.

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

    I have created my template but flex are not working

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

    Anyone not comfortable with class components. This code may work:
    import React, { useState } from 'react';
    import axios from 'axios';
    import { saveAs } from 'file-saver';
    import './App.css';
    const App = () => {
    const [state, setState] = useState({
    name: '',
    receiptId: 0,
    price1: 0,
    price2: 0,
    });
    const handleChange = ({ target: { value, name } }) =>
    setState((prevState) => ({ ...prevState, [name]: value }));
    const createAndDownloadPdf = () => {
    axios.post('/create-pdf', state)
    .then(() => axios.get('fetch-pdf', { responseType: 'blob' }))
    .then((res) => {
    const pdfBlob = new Blob([res.data], { type: 'application/pdf' });
    saveAs(pdfBlob, 'newPdf.pdf');
    });
    };
    return (





    Download PDF

    );
    };
    export default App;

  • @saurabhrajput1188
    @saurabhrajput1188 3 ปีที่แล้ว

    Can We Create a pdf in portrait mode

  • @JahangirAlam-ox8cn
    @JahangirAlam-ox8cn 3 ปีที่แล้ว

    how can I create pdf from React component ?

  • @swastikagarwal8605
    @swastikagarwal8605 4 ปีที่แล้ว

    Hey i know you get a lot comments but i want to ask if its possible to download the pdf in landscape

    • @javascriptmastery
      @javascriptmastery  4 ปีที่แล้ว

      Sure, research the package we used in the video

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

    How would we get this on a hosted server to use in a seperate app

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

      You could use a service like heroku to host the server side, and github pages to serve the client side. Hope it helped. Cheers!

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

      Thanks that helped im doing a project in school and this saved me

    • @walfreaguilar8276
      @walfreaguilar8276 5 ปีที่แล้ว

      @@javascriptmastery hi :)... awesome video, thanks a lot :D
      and, it can be hosted on firebase hosting? boths? thakns in advace :)

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

      @@walfreaguilar8276 Sure, there shouldn't be any issues! :)

    • @walfreaguilar8276
      @walfreaguilar8276 5 ปีที่แล้ว

      @@javascriptmastery excellent :D

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

    It's awesome project but lack explanation line by line for beginners, also i get 404 error on console when trying to generate the PDF, if i can send you the code link for check would be really appreciated

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

    How to save to database help me please