Here is a small snippet that works locally - you can change it to configure your host:
URL url = new File("test.html").toURI().toURL(); WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage(url); OutputStream os = null; try{ os = new FileOutputStream("test.pdf"); ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(page,url.toString()); renderer.layout(); renderer.createPDF(os); } finally{ if(os != null) os.close(); }
Alternatively, here is the jsPDF link: http://code.google.com/p/jspdf
Here is a useful example of using jsPDF:
var doc = new jsPDF(); doc.text(20, 20, 'Hello world!'); doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.'); doc.addPage(); doc.text(20, 20, 'Do you like that?'); // Output as Data URI doc.output('datauri');
More information can be found here: http://snapshotmedia.co.uk/blog/jspdf
Tim Dodd Aug 24 2018-12-12T00: 00Z
source share