How to download web pages as PDF in React JS

  Рет қаралды 32,844

Code Pro

Code Pro

Күн бұрын

Пікірлер: 61
@ajayprakashpp7229
@ajayprakashpp7229 Жыл бұрын
I don't know how to express my gratitude to this video. You have given solution for a problem on which i have been wandering around for 2 days. Thank you ♥
@SamGreen-n1l
@SamGreen-n1l Жыл бұрын
I love simple short tutorials that work. Thank you for this. Worked first time without any issues.
@anthonyezeh7511
@anthonyezeh7511 11 ай бұрын
I was able to integrate it following your steps. Everything works as instructed.
@vivekjaiswal2422
@vivekjaiswal2422 11 ай бұрын
I have to download a scrollable div, but by using the above same logic I am unable to do it. I am getting only the current view port in pdf.☹
@ashavytla8886
@ashavytla8886 2 ай бұрын
okay but can we download web pages into word document with all the css styles....??
@sunidhichouhan4103
@sunidhichouhan4103 Жыл бұрын
how can we make text selectable in pdf ? please help me oue.
@JamesYang-i4k
@JamesYang-i4k Жыл бұрын
Hi bro, thank you so much, i just have a little problem when i download the PDF my images dont render in it
@billyjoshuasalcedo3955
@billyjoshuasalcedo3955 Жыл бұрын
how can you optimize the downloading time? I'm having trouble into downloading the pdf because it takes around 5 seconds before downloading the pdf. I'm using useRef for the DivElement and is passing down the scale to 1 to lower the graphics but to no avail.
@g3zeck485
@g3zeck485 8 ай бұрын
Helo i have this error "incomplete or corrupt png file" Does anyone know the solution?
@skazzp
@skazzp Жыл бұрын
Great guide, everything worked from the first try, thank you
@CodePro-Jayanth
@CodePro-Jayanth Жыл бұрын
Thank you so much
@minhtringuyen1267
@minhtringuyen1267 10 ай бұрын
I have issue with the tag svg it's not render correctly, can u help me about this issue.
@olufemiajibade
@olufemiajibade 11 ай бұрын
Thanks for this, worked at first try 💯
@abelmurua6980
@abelmurua6980 11 ай бұрын
Thank you so much! Since I am using AWS ElasticBeanslkt Amazon Linux 2023, I couldn't use Puppeteer because of their environment its based on 64 bits. This solved my PDF need, I spent 2 days trying to find a solution, I appreciate your input!! thank you! The only thing I noticed is that TABLE layout its somehow off, not showing the same thing as it does on browser. th (headers) had some top padding on the cell, or the titles it self are alinged to bottom. I tried with lots of tailwindcss rules to reset that but I couldn't make it work, everything else looked great! I just removed the bg color so you cant tell there is a ht space.! Thank you again
@SanjaySanjay-zg1jy
@SanjaySanjay-zg1jy 8 ай бұрын
I want to download in a new tab. How to do using ur code
@showhow6827
@showhow6827 Жыл бұрын
Great tutorial, simple and to the point. One major issue though. When the content is longer than the viewport or wider and or even when the you have the window resize to smaller one then the it will not convert the full content. Does anyone have an idea about solving this issue?
@yeshthummer7256
@yeshthummer7256 Жыл бұрын
can i share a link using this package and save link and after save the pdf and open link from pdf ??
@MaharajanRavi
@MaharajanRavi Жыл бұрын
is there any other method to download as pdf with support svg images?
@rukaiyajahan1172
@rukaiyajahan1172 Жыл бұрын
Thank you so much. such a helpful video . Go ahead, all the best
@cricketfan3322
@cricketfan3322 Жыл бұрын
Ph er student naki?
@rukaiyajahan1172
@rukaiyajahan1172 Жыл бұрын
@@cricketfan3322 yes 🤔
@cricketfan3322
@cricketfan3322 Жыл бұрын
@@rukaiyajahan1172 amio same reason e ashchilam ekhane 😌😇
@cricketfan3322
@cricketfan3322 Жыл бұрын
@@rukaiyajahan1172 hmm done
@tamimhossain4141
@tamimhossain4141 5 ай бұрын
great but how I download multiple page
@niveditasingh7691
@niveditasingh7691 9 ай бұрын
If I need to add link to pdf, how does that work with this approach? @code pro
@shubhamdas6519
@shubhamdas6519 11 ай бұрын
what if i am rendering the image from online link?
@PrakashA-e1i
@PrakashA-e1i Жыл бұрын
how to take print long web page ? more than 1 page
@SachinSingh-fs2xe
@SachinSingh-fs2xe 2 ай бұрын
did you find the logic?
@rahulmohanty3822
@rahulmohanty3822 3 ай бұрын
what is the font name ?
@kanibis811
@kanibis811 Жыл бұрын
thank you @code pro, that's what I needed. I wanted to know about the step guide that you created - have you used animation for rendering the steps one-by-one? Please do reply, I'm in the learning phase and it'd really help me. Also can you please share step-guide's github link?
@CodePro-Jayanth
@CodePro-Jayanth Жыл бұрын
Thank you, actually I have created animation for rendering step by step
@hardikdangodara3272
@hardikdangodara3272 10 ай бұрын
thank you so much sir
@Arul_Sekar.S
@Arul_Sekar.S Ай бұрын
I have HTML link that link can convert into pdf
@kleatech6562
@kleatech6562 Жыл бұрын
please can you share the github link or the blog link
@jorgegarnicablanco8136
@jorgegarnicablanco8136 11 ай бұрын
const downloadPDF = () => { const input = quoteRef.current; html2canvas(input as HTMLElement).then((canvas) => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4', true); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = Math.min(pdfWidth / imgWidth, pdfHeight, imgHeight); const imgX = (pdfWidth - imgWidth * ratio) / 2; const imgY = 30; pdf.addImage( imgData, 'PNG', imgX, imgY, imgWidth * ratio, imgHeight * ratio ); pdf.save('cotizacion.pdf'); }); };
@DeveloperInside
@DeveloperInside 11 ай бұрын
Can we select text and copy in generated pdf
@CodePro-Jayanth
@CodePro-Jayanth 11 ай бұрын
It's not possible in this approach, for that we need to use react-pdf library. In few days I will post the video for that
@shuvomajumder5565
@shuvomajumder5565 9 ай бұрын
I got an error. Uncaught (in promise) Error: Attempting to parse an unsupported color function "oklch".
@olivierboulanger1118
@olivierboulanger1118 3 ай бұрын
Excatly the same No salution ?
@rodrigocastro3934
@rodrigocastro3934 Жыл бұрын
This is not the correct approach. This is only converting the web into an image, and then paste it on a pdf. Consequently: final pdf has no text you can select and/or copy, it is just an image; and second, if you have several pages this method does not work. Does anyone has a correct solution? Please leave it bellow 🙏🏻
@CodePro-Jayanth
@CodePro-Jayanth Жыл бұрын
With this library you can create multi page pdf as well
@Pkcollects
@Pkcollects 10 ай бұрын
@@CodePro-Jayanth how
@varunsalat619
@varunsalat619 9 ай бұрын
yes how? I was creating a dynamic invoice pdf that's why came here..
@anushkanemishte4538
@anushkanemishte4538 Ай бұрын
Please tell how
@Pkcollects
@Pkcollects 10 ай бұрын
scrollable content not capturing
@abdulragib6004
@abdulragib6004 Жыл бұрын
i follow same approach but it didn't work
@abhishekmeena2985
@abhishekmeena2985 Жыл бұрын
thank you, it was helpful
@kimothe2nd
@kimothe2nd 3 ай бұрын
That did NOT download the cv..
@varadtote2017
@varadtote2017 Жыл бұрын
I got it right but image quality is too bad
@kanishkakodithuwakku1944
@kanishkakodithuwakku1944 3 ай бұрын
thanx brother
@lubomirsevcik2252
@lubomirsevcik2252 9 ай бұрын
thx man
@anik1612
@anik1612 Жыл бұрын
informative
@cricketfan3322
@cricketfan3322 Жыл бұрын
Ph er student naki?
@khaouitiabdelhakim
@khaouitiabdelhakim Жыл бұрын
Thanks alot. th source code pleaaaaaaaaaaaaaaase!
@stan-beats
@stan-beats Жыл бұрын
thx
@shubhampatil5935
@shubhampatil5935 Ай бұрын
grow up from beginner mindset man.
@roufhasan
@roufhasan 10 ай бұрын
I am facing this error: Uncaught (in promise) Error: Attempting to parse an unsupported color function "oklch" html2canvas.js?v=82c7c37b:1685
@lasith123
@lasith123 9 ай бұрын
const handleDownloadPDF = () => { const input = pdfRef.current; html2canvas(input).then((canvas) => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4', true); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight); const imgX = (pdfWidth - imgWidth * ratio) / 2; const imgY = 30; pdf.addImage( imgData, 'PNG', imgX, imgY, imgWidth * ratio, imgHeight * ratio, ); pdf.save('invoice.pdf'); }); };
@ducnguyenminh5942
@ducnguyenminh5942 8 ай бұрын
thank bro!
@billyjoshuasalcedo3955
@billyjoshuasalcedo3955 Жыл бұрын
how can you optimize the downloading time? I'm having trouble into downloading the pdf because it takes around 5 seconds before downloading the pdf. I'm using useRef for the DivElement and is passing down the scale to 1 to lower the graphics but to no avail.
@miakablan8792
@miakablan8792 Жыл бұрын
can you use workers ?
How to Create PDFs With Node JS and React
25:57
JavaScript Mastery
Рет қаралды 147 М.
Generate a PDF in React
23:38
Colby Fayock
Рет қаралды 21 М.
I Turned My Mom into Anxiety Mode! 😆💥 #prank #familyfun #funny
00:32
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 5 МЛН
React to PDF Printing | React Tutorial
16:28
Hong Ly Tech
Рет қаралды 90 М.
How To Debug React Apps Like A Senior Developer
21:07
Web Dev Simplified
Рет қаралды 163 М.
ReactPDF Basic Setup
11:12
Arslan
Рет қаралды 105 М.
Master React JS in easy way
12:18
Nova Designs
Рет қаралды 120 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 197 М.
I Turned My Mom into Anxiety Mode! 😆💥 #prank #familyfun #funny
00:32