Hi, In have an Asp.net web application and using itext sharp library, I can create pdf at server-side.


Now I have requirement to generate pdf at client side. Basically there are blog post , which acces to all, and now want to add features where end-user can get a PDF format of blog post (not whole webpage(exclude navigation bar ,menus etc, but include only part of blog post)
Reference any open-source library, or any tutorial much appreciated.
jsPDF https://github.com/MrRio/jsPDF but beware, it gets annoying real quick. There’s a reason why you hardly ever see client side generated PDFs but something along the lines of “enter your email and we’ll send you a link to download the PDF”
Will try jspdf , will it generate pdf only specific part of webpage and not whole html. Also can we have working links on generated pdf(what ever we have on actually webpages)
As /u/rickt3420 said, client side PDF generation can be quite annoying.
Is there a reason you can’t do server side generation? I’m guessing it must be that you don’t have the ability in this case. If you are able to, however, and you have the data to generate the page server side, you should be able to generate the PDF server side and push it to the client seamlessly. Even if you don’t have the data server side, you can send it with an Ajax call.
The user experience will be to click the button and then they will get the PDF download prompt (or it opens in browser).
Generating pdf of blog post on each user click hit on server-side, which impact high load on server if traffic is increased. If we able to generate PDF client side, then data is already available on browser, so no load on our server.
Also blog post are getting updated frequently, so user gets updated content pdf whenever he/she click s
Normally I either go for server side PDF generation or I do window.print() so they can save the page as pdf.
Thanks for idea , if nothing works for me, will think to go with window.print()
I recall doing something similar before but it was a hybrid approach. On the server side I had the PDF rendered configured to use the frontend HTML’s Print stylesheet. When clicking a button on the UI, the HTML DOM node of whatever was to be printed was sent to the backend and inserted into the PDF and rendered.


How many blog posts are you talking about? Why not have it so when post is submitted it also generates a pdf copy of it? Even if you have write a script to retroactively generate pdfs for previous blog posts, cron it to run off peak hours and you’re still in better shape than the mental headache that client side pdf generation is gonna give you.
Members
Online

source