Thank. You for the video. Is a nice code to implement in many applications
@javascriptmastery5 жыл бұрын
Glad you find value in it, many more tutorials are coming soon!
@TheChinobi235 жыл бұрын
JavaScript Mastery awesome!! Good job
@chris_and_music4 жыл бұрын
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"); }); }); }
@AdithyaKahawanugoda4 жыл бұрын
this method doesn't work,it shows pdf file can not open
@afaque.4 жыл бұрын
it just solved the error I was having from html-pdf
@afaque.4 жыл бұрын
but now ALL PDF ARE CORRUPTED so thanks but no thanks
@AdithyaKahawanugoda4 жыл бұрын
@@afaque. means?
@sadraquesantos97665 жыл бұрын
I've been looking for a simple solution like this for months, thanks for the tutorial.
@javascriptmastery5 жыл бұрын
Glad you finally stumbled upon my video! 😀
@justinnguyen80492 жыл бұрын
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!
@thanishahamed47553 жыл бұрын
Cheers from Sri Lanka! Found the sollution with easy steps to use in my applications 🙂
@sandun72663 жыл бұрын
😉
@alwikah56645 жыл бұрын
Top video ! Thanks a lot ! Advice : +zoom on IDE
@javascriptmastery5 жыл бұрын
Thanks man, I will definitely zoom it for the next vid!
@allancoder5 жыл бұрын
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. 😁😃
@javascriptmastery5 жыл бұрын
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! 😀
@andersbraathen1256 Жыл бұрын
Thank you for the tutorial!
@sadeedkhan53444 жыл бұрын
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!!
@animeshtimsina36603 жыл бұрын
Thanks man! But I have some problems. Why aren't some css properties like flex supported?
@MrMiguelapb354 жыл бұрын
Very nice project, and very useful, thanks man
@javascriptmastery4 жыл бұрын
Glad you like it!
@andygolem55144 жыл бұрын
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?
@tuseeqtoor33952 жыл бұрын
I have the same issue...Did you find any solutions?
@rodrigomartinez12029 ай бұрын
Amazing video man!!
@adityaekawade10605 жыл бұрын
Awesome. Thank you for such a great tutorial!
@Fullflexno5 жыл бұрын
Thank you for the video, excelent content. Cheers from Norway!
@javascriptmastery5 жыл бұрын
Thanks man, since I am just starting, it really means a lot! Stay tuned for more! :)
@subhashgn17753 жыл бұрын
very well explained.
@risingstars68523 жыл бұрын
Thanks for great tutorial
@girishthatte4 жыл бұрын
Thanks a lot dude ... Your video is really awesome and also had nice explanation !
@devanshbhushan10574 жыл бұрын
Thanks a lot!! Your code helped me a lot!!
@johnfazio25133 жыл бұрын
Great video, I subscribed
@theAbdikhaliq Жыл бұрын
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;
@JonoBaritaspasial5 жыл бұрын
Thanks. Very usefull
@javascriptmastery5 жыл бұрын
Thanks! Glad you like it.
@doufer95285 жыл бұрын
really good video!
@javascriptmastery5 жыл бұрын
Thanks!
@kevinwirth25485 жыл бұрын
Thank you. Cool Tutorial :)
@javascriptmastery5 жыл бұрын
Since I'm just starting out, I extremely appreciate any feedback, thanks! 😊
@fayequehannan24734 жыл бұрын
Please zoom in your screen..its is difficult to watch on mobiles...otherwise video is great and helps me a lot..thank you
@juhikh65444 жыл бұрын
You are awesome!!! Thanks!!!
@РоманМосолов-ы1ш5 жыл бұрын
Thanks for knowledges.
@javascriptmastery5 жыл бұрын
Thank you for watching!
@nishantkumar69603 жыл бұрын
Thank you so much !!!
@domy6675 жыл бұрын
great vid. Thanks!
@javascriptmastery5 жыл бұрын
Thanks, appreciate it!
@elie34234 жыл бұрын
to run nodemon, type one of these in the terminal: npm install -g nodemon OR yarn global add nodemon
@dheflowgeming5 жыл бұрын
goodjob dude
@javascriptmastery5 жыл бұрын
Thanks!
@shahrukhm80932 жыл бұрын
Thank you,
@BulletSP4 жыл бұрын
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!
@rakeshrinawa4 жыл бұрын
Great video. Can anyone tell how to apply your choice of Logo as image and use it in real life Project? Thanks
@kamildziech20214 жыл бұрын
Did you solve this problem? I want to know because I have the same :/
@davidadeleye12594 жыл бұрын
@@kamildziech2021 Have you tried saving the image in your React project folder and importing it in whatever component you want to use it in?
@shivaprasad8919 Жыл бұрын
Can we use inside the template string? will it work
@CipMassageTherapyToronto2 жыл бұрын
I'm just getting the error "__dirname is not defined" in my server console. The receipt is generated. Any solutions?
@Viralvlogvideos3 жыл бұрын
please make complete JS course from zero to hero
@javascriptmastery3 жыл бұрын
I already have one. Complete Path to JavaScript Mastery
@Viralvlogvideos3 жыл бұрын
@@javascriptmastery not on youtube :(
@enesgungor67883 жыл бұрын
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 ?
@dolevdo3 жыл бұрын
this is amazing video , do you have any suggestions about how to edit the number of products dynamically ?
@akiempaul1117 Жыл бұрын
The list of products should be in an array, use the map function and return the div in string format
@davidfry35525 жыл бұрын
How would you do this if you wanted a multi-page pdfs? How do you specify page breaks?
@zuzukouzina-original2 жыл бұрын
He can’t answer this question, it’s just a simple hello world code he is showing.
@abelmurua698011 ай бұрын
Nice video! can I create a template using TailwindCss?
@shneorBachar3 жыл бұрын
thanks!!!!!!! How to display images using node.js server??? INTO INDEX.JS
@JoshuaMusau Жыл бұрын
Awesome!
@karamokanagi92965 жыл бұрын
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
@尼古拉丝土豆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.
@thangtea18bec5 жыл бұрын
Can you demonstrate printing react component
@prashant60452 жыл бұрын
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
@samking6185 ай бұрын
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?
@ahmedali0064 ай бұрын
how do i store the generated pdf to my phone (I'm developing this in react native)
@latifjames72082 жыл бұрын
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
@ngneerin3 жыл бұрын
Wouldn't it be a better solution to convert react to pdf directly on frontend
@zuzukouzina-original2 жыл бұрын
I agree with you, it’s just he only knows this method from a blog on the internet, it’s a kind of copycat
@JadeclonOfficial2 жыл бұрын
Why is flexbox not working in the template?
@yashmalviya99313 жыл бұрын
I have created my template but flex are not working
@willigeek20135 жыл бұрын
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 ?
@Shadyholic5 жыл бұрын
did this work for you ? even when i downloaded the files from github it still isn't working... did you had any problems ?
@pratikshemare71162 жыл бұрын
How to create template with Array of Objects? please reply...
@amineselmi83805 жыл бұрын
great tutorial , but the thing is . I dont have the Render() function generated
@javascriptmastery5 жыл бұрын
What exactly are you referring to? What minute in the video?
@amineselmi83805 жыл бұрын
@@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 '
@javascriptmastery5 жыл бұрын
In that case, simply copy the render code I have. You should be good to go then.
@syedmujeebh44013 жыл бұрын
Pls make a video on parsing pdf with streams buffers and chunks
@danielwaiter99904 жыл бұрын
Is it possible to generate PDF from an object array as well ?? If so, how ? Thanks
@aneekaatrocities24895 жыл бұрын
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?
@rohitdalal9545 жыл бұрын
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?
@javascriptmastery5 жыл бұрын
Thanks for the feedback! Feel free to try it and let me know! 😁
@gamingdaavago1743 жыл бұрын
Is this working?
@gamingdaavago1743 жыл бұрын
External css?
@Victor-wh9bs2 жыл бұрын
ThankU
@redskater425 жыл бұрын
wonder if i can get some help, I'm getting an error where my browser is unable to open/read pdf file. Any thoughts?
@javascriptmastery5 жыл бұрын
Did you manage to resolve the issue?
@redskater425 жыл бұрын
@@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.
@Shadyholic5 жыл бұрын
@@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.
@ArmandoHinojosaCcamaSARC5 жыл бұрын
Thank you for this ^_^ !!!
@javascriptmastery5 жыл бұрын
Thank you for watching! :)
@huirenchuah35974 жыл бұрын
how to actually use this with functional component in react like hooks. Do I need to like specify const [name, setName]=useState(' ')??
@dilshodrahmatov30582 жыл бұрын
Can you update this tutorial? Thank you.
@techchunk672 жыл бұрын
.then().then() was calling api's two time in my case so it was not working So you can simply use async and await
@TheSulaimanKhaled4 жыл бұрын
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
@EmilianoC764 жыл бұрын
I'm downloading a pdf but when opening the file it ways it's corrupt :(
@SarahAbouyassine5 жыл бұрын
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
@nikicamaksimovski99644 жыл бұрын
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.
@nikicamaksimovski99644 жыл бұрын
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()) } }) })
@wibbs885 жыл бұрын
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.
@wibbs885 жыл бұрын
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.
@javascriptmastery5 жыл бұрын
This article might help - stackoverflow.com/questions/1757397/how-can-i-merge-data-into-an-xdp-file-and-return-a-pdf-via-net
@wibbs885 жыл бұрын
@@javascriptmastery Thanks I'll take a look
@androsanju25264 жыл бұрын
Please also explain commands for Windows users.
@kamildziech20214 жыл бұрын
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?
@danieldebellis50394 жыл бұрын
Hey. Imagens can be displayed by setting . The trick is on "file:///" with 3 slashes. Hope this works.
@kamildziech20214 жыл бұрын
@@danieldebellis5039 yes, thanks
@swastikagarwal86054 жыл бұрын
@@danieldebellis5039 Hey can you help me with this im trying to configure it but its not working
@danieldebellis50394 жыл бұрын
Of course! What’s going wrong?? Did you tried to put the 3 slashes after “file”? Are you working on mac, linux or windows?
@swastikagarwal86054 жыл бұрын
@@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.
@alanalvarado91515 жыл бұрын
Hi, nice work. Works for react-native too?
@trisutrisnoadri9804 жыл бұрын
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
@jhmesseroux3 жыл бұрын
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 ??
@bikramchettri94052 жыл бұрын
Hey can you please update this tutorial?
@TarcisioPqdt3 жыл бұрын
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?
@arpanmaji35963 жыл бұрын
how to delete the generated file in backend after download
@gangaprasadk2 жыл бұрын
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
@xxMegha33xx4 жыл бұрын
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?
@samrat78584 жыл бұрын
How to loop through an array inside the html template ?
@KevinMcGee_CSSian5 жыл бұрын
Tips: (1) npm init without having it ask any questions, (2) no need for bodyParser anymore: (1) $ npm init -y . (docs.npmjs.com/cli/init) (2) The middleware bodyParser is now a part of "Express v4.16.0 onwards." (expressjs.com/en/api.html)
@javascriptmastery5 жыл бұрын
Damn man, thanks for the tips! I didn't know that , you learn something new everyday. Thanks for the feedback, keep watching the vids! 😀
@mohamedyoussef88352 жыл бұрын
Awesome video +++++++++++++ 😃
@YuriiKratser4 жыл бұрын
Hi! Thanks! Does it support Russian or Chinese languages?
@tacituskilgore22583 жыл бұрын
which theme do you use?
@janmichaelbesinga3867 Жыл бұрын
html-pdf is now deprecated.
@changhaoliu71194 жыл бұрын
Can you explain where you put "_dirname"? Thank you!
@raihanuddin11673 жыл бұрын
Pls kindly help me how can use daynamic value in mongobd use pdf
@testingpro43784 жыл бұрын
sir i face "Internal server error 500" please suggest any solution
@lamarlaing49975 жыл бұрын
Hi, thanks for this video. Im using Laravel with react, does this work in that framework?
@JahangirAlam-ox8cn3 жыл бұрын
how can I create pdf from React component ?
@yannapolchatkaewmanewong61242 жыл бұрын
How to save to database help me please
@blahmezah5 жыл бұрын
Good video, but it is so hard to see your screen and the code compared to alot of coding videos I watch
@javascriptmastery5 жыл бұрын
Don't worry, I will definitely bump up the font size for the next video! :)
@saurabhrajput11884 жыл бұрын
Can We Create a pdf in portrait mode
@jayjayDrm2 жыл бұрын
ok, but how to generate a pdf from react/jsx, not from html?
@stefanomartell84135 жыл бұрын
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!
@javascriptmastery5 жыл бұрын
Yes! The pdf gets stored in the server! :)
@stefanomartell84135 жыл бұрын
JavaScript Mastery in a database? Where exactly?
@javascriptmastery5 жыл бұрын
@@stefanomartell8413 check 25:20 of the video, under the server directory. There is results.pdf.
@stefanomartell84135 жыл бұрын
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!
@javascriptmastery5 жыл бұрын
@@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!
@mannaimounir13585 жыл бұрын
thanks for the Great tutorial! i need some help since i have a blank page downloaded
@javascriptmastery5 жыл бұрын
Is the code exactly the same as in the video? You can also check the Medium article in description and then compare it.
@mannaimounir13585 жыл бұрын
@@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...
@javascriptmastery5 жыл бұрын
@@mannaimounir1358 contact me on Instagram @javascriptmastery so we can try to resolve the issue :)
@disrael21012 жыл бұрын
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
@HrishikeshTS3 жыл бұрын
I seem to have an error in res.sendFile() in backend, or res.data in frontend.
@lukasmasevicius48653 жыл бұрын
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