The Portable Document Format, aka PDF, is a de facto standard for document exchanges between users. Java programmers sometimes need to create document files of their application data to showcase business information or create a report that can be exchanged or printed without messing with the data layout and format. THE unique Spring Security education if you’re working with Java today. In this quick article, we'll focus on creating PDF document from scratch based on popular iText and PdfBox library. Both, the iText and PdfBox are java libraries used for creation/manipulation of pdf files. Although the final.
Active1 year, 6 months ago
I'm looking for a library to transform my web page into a PDF file after click event from a button. I'm trying
Angel Politisjspdf
, but it prints without the CSS, how can I make this using JavaScript/jQuery
and keep my CSS? Or another CSS that I can choose?8,0781212 gold badges3535 silver badges5555 bronze badges
Alejandro HinestrosaAlejandro Hinestrosa23133 gold badges99 silver badges2323 bronze badges
closed as off-topic by Stephen Kennedy, Baum mit Augen♦, E_net4 on strike, techraf, MachavityMar 23 '18 at 14:01
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.' – Stephen Kennedy, Baum mit Augen, E_net4 on strike, Machavity
3 Answers
There is a new jQuery + cloud solution that will render any HTML page and its CSS (including print media rules) to PDF. The solution is setup to print any region of your webpage, you just tell the Formatter which container element you want to print and the library does the rest. What you get back is an embeddable PDF or the backend will push back a PDF for download.
Here's your library (GitHub):
https://github.com/Xportability/css-to-pdf
https://github.com/Xportability/css-to-pdf
Here's your fiddle:
http://jsfiddle.net/kstubs/jrtM5/
http://jsfiddle.net/kstubs/jrtM5/
Here's a working demo:
http://xep.cloudformatter.com/doc/
http://xep.cloudformatter.com/doc/
Java Generate Pdf From Html Code Using Tcpdf In Php
Currently there are not useage instructions, but following along with the samples (view source) should be pretty self-explanatory (look for the Print It buttons) and here is, more or less the additional options/parameters that the Format method understands.
Here is list of CSS attributes that are currently supported.
Hope this helps!
Samuel Liew♦47.7k3737 gold badges121121 silver badges180180 bronze badges
kstubskstubs
![Pdf Pdf](/uploads/1/2/4/9/124917298/884339446.png)
try this npm package
htmlto
.It creates PDF from html with CSS stylinginstall:
![Generate Generate](/uploads/1/2/4/9/124917298/183685377.png)
npm install -S htmlto
npm install -S phantom
*you can also specify the dimensions.phantom version ^4.0.3 and node version v6.5.0 https://www.npmjs.com/package/htmlto
dev07dev07
I have created a simple & very easy to use API that uses the snappy library, based on the wkhtmltopdf webkit-based CLI, in order to convert an HTML page from the URL to PDF. Here is the Github repo: https://github.com/Dellos7/dhtml2pdf
This is an example of how to use it from an anchor tag. This will show the generated PDF of the
https://www.github.com
site in a new browser tab:Example of how to use it to download the PDF:
With this solution you don't even need to use javascript in order to generate your PDF.
But if you still need to do it using javascript, you can do it like this:
In the repo I also explain how to very easily clone & deploy your own API in Heroku so you can mantain the API yourself and not to depend on external services.
David LópezDavid López