Reputation: 13
I want to export the information on my gsp page to pdf.
How can I do that. Can you share some example. Please check the image attached.
Upvotes: 0
Views: 452
Reputation: 1219
I have used the Grails Rendering plugin for generating PDFs from Grails. Easy to use and generates from a GSP uses iText under the covers.
https://plugins.grails.org/plugin/grails/rendering
Here is how it is called and templates start with a underscore:
response.setHeader('Content-Disposition', 'inline; filename="Case_Summary_'+selectedCase+'.pdf"')
renderPdf(template: "print", model: [selectedCase: selectedCase, locationList: locationList])
Here is the top of the GSP with some iText settings:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Case ${selectedCase} Summary</title>
<style type="text/css">
@page {
size: 8.5in 11in;
margin: 0.25in;
counter-increment: page;
@bottom-right { content: "Created <g:formatDate format='MM/dd/yyyy hh:mm a' date="${new Date()}"/>"};
@bottom-left { content: "Page " counter(page);};
}
body {
font-family: 'Arial', 'sans-serif';
font-size: 9pt;
}
</style>
</head>
Upvotes: 1
Reputation: 331
Maybe you could use Grails Jasper Plugin and create a jasper report with the same format as your GSP and then export it to PDF.
Upvotes: 0