JSP/HTML/CSS to PDF generation - html

Basically a simple question:
In php you have mpdf/tcpdf etc libraries that convert your HTML/CSS as is into a pdf file.
I have now a JSP page from where i open up a popup JSP including kind of a organizational chart with divs created from HTML/CSS. Is it possible that i can just take this whole popup and convert it somehow into a pdf file -> in chrome you have the option of save as pdf -- and that works it creates a pdf file successfully ! But i want the website to create a pdf itself without browser plugin. Is it possible? Does Java/JSP have such an option to convert pure HTML/CSS to pdf?

You could use Wkhtmltopdf to convert from HTML to PDF. https://code.google.com/p/wkhtmltopdf/

Related

How can I do a preview of some HTML part of my code as PDF or DOCX file in Angular

I have some data that I should present on a container like if it is a PDF or DOCX file with separated pages. But I don't have PDF or DOCX at the moment. I have HTML code and in some div at the same page I should add such kind of preview so user could see how it will be exported to PDF or DOCX file. I searched a lot but didn't find any solution yet. I tried with embed and iframe but it requires data different from simple HTML code. How can I achieve simple HTML code be previewed as PDF or DOCX? I'm using Angular 9 on my project.

embed a pdf archive like it were part of the html code

i had a little question, i want to embed a pdf like it were part of the website, i could rewrite the pdf in html but it will be a lot of work, what would be the best looking option to embed it?
The pdf has pictures and letters with fonts and columns.
Thanks.
I would go with one of the two approaches. One is a native rendering of the PDF content in a DOM node, using PDF.js. It is an open source library that's used as the default PDF viewer in Firefox.
Another way is to emulate the look by converting the PDF pages to images when the PDF is uploaded. You may use imagemagick to parse the pages, and display the content in a slideshow/gallery widget.

Convert html 5 to PDF in MVC 3

I have created an application in asp.net MVC 3, I used highchart.js for rendering chart(stacked column) in view and its output is coming as svg.
I need to convert this chart page into PDF file. I tried iTextSharp but its not showing the chart page content.
Is there anyway to convert html 5 to PDF?
ExpertPDF is a nuget package you can install. For it to work without putting text over your pdf, you'll have to purchase a license. It can handle svg.
http://www.html-to-pdf.net/ExpertPDF-HtmlToPdf-Converter.aspx
You can also use a webkit component such as HTM2PDF to render HTML to PDF - see an explanation here:
Highcharts to PDF with Webkit
If you just want to convert svg to image then you can use PhantomJS (headless webkit browser). With help of PhantomJS you can render svg and make screenshot. Then you can create a PDF and insert that image into it.
Also you can Aspose.Pdf for converting svg into PDF directly. See: http://www.aspose.com/.net/pdf-component.aspx (it's a paid component!)

Convert PDF to HTML in ios?

To Do : Convert pdf file to HTML file
For Eg: The pdf file in link below
http://www.inkwelleditorial.com/pdfSample.pdf
should be converted to HTML file.
Study : I googled and found out few ways to convert HTML to PDF like
Convert html file to PDF Document in iOS using Cocoa-Touch
Creating a PDF with iOS
Generating PDF Content
but could not get any way to do vice versa ie convert pdf to HTML.
Is there any library available in objective C for above purpose?
sorry, I dont think there is a reliable way to keep the formatting (and neither for get all text.)
you'd be better off to display and search the pdf using pspdfkit

Can you embed an HTML webpage in a PDF file?

A flash file can be embedded in a PDF document. Does anyone know if it is also possible to embed an HTML webpage?
Added:
I don't mean just a plain HTML document, but a webpage with Javascript too.
The answer is no.
While you can embed videos, sounds and SWF files in a PDF, dynamic HTML files aren't supported. (Adobe AIR is more suitable to package and distribute HTML files).
The best you can do in a PDF is to use the ATTACH option in Adobe Acrobat. This will "attach" any file with the PDF document similar to how you add an attachment with an email. But the attachment can't be viewed within the PDF document, and has to be opened separately.
More info:
Javascript can be added to PDF files and used to manipulate various elements within the PDF file.
Not directly. Depending on what you're looking for, however, you can use something like dompdf (PHP) to generate a PDF file from an HTML document, then merge that document with your original. It even supports JavaScript, up to the level Adobe Reader supports JavaScript.
That said, the PDF file format is really for things you want to print (i.e. want to look the same everywhere), not things you want to click on (i.e. look sensible everywhere). Adobe's decision to include Flash support was probably made from a marketing standpoint, not a technical one.
The best workaround would be to create a web/html viewer in Adobe Flash and embed that in a PDF as an SWF. There is an option to "Add SWF" in Acrobat under "Rich Media."
Created a NPM module that allows you to add custom HTML and CSS to PDF's.
const pdf = require('add-html-to-pdf');
var options = {
input: 'sample.pdf',
output: 'done.pdf',
html: "<div style='color:red'>This is awesome!</div>",
useDocker: true
}
pdf.insertHTMLInPDF(options);
You could reconstruct the html, css and js on the web page using php.
Im using a plugin with a wordpress site that is pretty outdated but works very well for creating pdfs with html, css and javascript.
it's called tcpdf
plugins/tcpdf/tcpdf.php
https://tcpdf.org/examples/
the pdf is made on the fly as a function.