To save changes to the current file, choose File Save. To save a copy of a PDF, choose File Save As. In Acrobat Reader, choose File Save As or File Save As Other Text. To save a copy of a PDF Portfolio, choose File Save As Other PDF Portfolio. If you’re previously using Chrome or Firefox or older version of Internet Explorer in which you can easily save any web page as HTML file or PDF file via “Save Page” option. However, in Edge browser saving a web page is not possible through default option. To save HTML file on Edge you’ve to download an app available on Microsoft Store.
Active3 months ago
Is it possible to save HTML page as PDF using JavaScript or jquery?
In Detail:
I generated one HTML Page which contains a table . It has one button 'save as PDF'. If user clicks that button then that HTML page has to convert as PDF file.
Is it possible using JavaScript or jquery?
ramram
Saving Html File As Pdf Download12 Answers
Yes, Use jspdf To create a pdf file. Canon scanner driver windows 7.
You can then turn it into a data URI and inject a download link into the DOM
You will however need to write the HTML to pdf conversion yourself.
Just use printer friendly versions of your page and let the user choose how he wants to print the page.
Edit: Apparently it has minimal support
So the answer is write your own PDF writer or get a existing PDF writer to do it for you (on the server).
AJPerez
2,34888 gold badges4949 silver badges6666 bronze badges
RaynosRaynos
139k4848 gold badges326326 silver badges380380 bronze badges
Ya its very easy to do with javascript. Hope this code is useful to you.
You'll need the JSpdf library.
BlackjokerBlackjoker
Here is how I would do it, its an idea not bulletproof design, you need to modify it
3,00766 gold badges3232 silver badges4949 bronze badges
You can use Phantomjs. Download here and use the following example to test the html->pdf conversion feature https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js
Example code:
singh1469singh1469
This might be a late answer but this is the best around:https://github.com/eKoopmans/html2pdf
Pure javascript implementation.Allows you to specify just a single element by ID and convert it.
Billcountry MwanikiBillcountry Mwaniki
I used
jsPDF and dom-to-image library to export HTML to PDF.
I post here as reference to whom concern.
Demo: https://jsfiddle.net/viethien/md03wb21/27/
Hien NguyenHien Nguyen
12.1k77 gold badges1414 silver badges3535 bronze badges
In short: no.The first problem is access to the filesystem, which in most browsers is set to no by default due to security reasons. Modern browsers sometimes support minimalistic storage in the form of a database, or you can ask the user to enable file access.
If you have access to the filesystem then saving as HTML is not that hard (see the file object in the JS documentation) - but PDF is not so easy. PDF is a quite advanced file-format that really is ill suited for Javascript. It requires you to write information in datatypes not directly supported by Javascript, such as words and quads. You also need to pre-define a dictionary lookup system that must be saved to the file. Im sure someone could make it work, but the effort and time involved would be better spent learning C++ or Delphi.
HTML export however should be possible if the user gives you non restricted access
Jon Lennart AasendenJon Lennart Aasenden
2,30122 gold badges2323 silver badges3939 bronze badges
Saving Html File As Pdf File
SantanuSantanu
There is another very obvious and easy way to convert HTML to PDf using JavaScript: use an online API for that. This will work fine if you don't need to do the conversion when the user is offline.
FreeHtmlToPdf.com is one option that has a nice API. I'm sure you can find alternatives (like PdfMage which obviously has its own API but doesn't share its protocol).
For FreeHtmlToPdf API you'd have something like this:
Andre BorgesAndre Borges
Yes. For example you can use the solution by https://grabz.it.
It's got a Javascript API which can be used in different ways to grab and manipulate the screenshot. In order to use it in your app you will need to first get an app key and secret and download the free Javascript SDK.
So, let's see a simple example for using it:
Then simply wait a short while and the image will automatically appear at the bottom of the page, without you needing to reload the page.
That's the simplest one. For more examples with image manipulation, attaching screenshots to elements and etc check the documentation.
JohnnyJohnny
5,99766 gold badges4949 silver badges8181 bronze badges
![]()
It is much easier and reliable to convert html to pdf server side. We are using Google Puppeteer. It is well maintained with wrappers for any server side language of your choosing. Puppeteer uses headless Chrome to generate screenshots and/or PDF files. It will save you a LOT of headache especially if you need to generate complex PDF files with tables, images, graphs, multiple pages and so
Matej JanovčíkMatej Janovčík
I think No because JavaScript can't write to disk you should send the page to the server and generate the pdf file then the client will download it
Khalid OmarKhalid Omar
1,15455 gold badges2323 silver badges4343 bronze badges
protected by eyllanescApr 26 '18 at 7:11Chrome Saving Pdf As Html
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead? Save Html Webpage As PdfNot the answer you're looking for? Browse other questions tagged javascriptjqueryjquery-ui or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |