My GSP page has multiple tables and also some other HTML elements like input text fields and header <h1> <h2>
texts.
I want all this info to be captured in the generated text.
So far the examples i have seen is only good for generating one table.
Is there a quick way of generating the PDF from all the data that's already populated in GSP?
I am using the Export plugin.
compile ':export:1.6'
And below is the sample code i tried so far.
It draws one table with headers and no data in the rows.
def myPDFexport () {
String userNumber = params.UserInfoInstance;
UserInfo userObj = UserInfo.findByNumber(userNumber);
params.format = "pdf";
params.extension = "pdf"
List fields = ["User ID", "User Name", "User Password"]
Map labels = [userID: "User ID", userName: "User Name", userPW: "User Password"]
if(params?.format && params.format != "html"){
response.contentType = grailsApplication.config.grails.mime.types[params.format]
response.setHeader("Content-disposition", "attachment; filename=${woNumber}.${params.extension}")
exportService.export(params.format, response.outputStream, userObj.list(params), fields, labels, [:], [:])
}
}
I am almost lost on this as i am new to Grails and also have no previous experience with PDF generation.
If possible, please provide me with some sample code.