1

Can we customize the design of the "grails export plugin's " report ? Generally now, if we export a list (i.e a table) using export plugin in pdf it gives us the plain table. Can we add a logo or make any other kind of similar custom changes to the pdf ? Is there any kind of jrxml file which we can customize ourself that we do on other export API like Dynamic Jasper ?

Thanks in Advance.

Aman Adhikari
  • 3,240
  • 3
  • 22
  • 32

1 Answers1

2

From what I can see (not tested)

http://grails.org/plugin/export

Map parameters = [title: "Cool books", "column.widths": [0.2, 0.3, 0.5]]

exportService.export(params.format, response.outputStream, Book.list(params), fields, labels, formatters, parameters)

https://github.com/gpc/grails-export/blob/master/src/groovy/de/andreasschmitt/export/exporter/DefaultPDFExporter.groovy#L38

if (getParameters().containsKey(("pdf.logo"))){
String logoPath = getParameters().get("pdf.logo")
Image logo = Image.getInstance(logoPath)
document.add(logo)
}

so if you have an additional parameter of pdf.log in parameters with path to image - it should work -

Map parameters = [title: "Cool books", "column.widths": [0.2, 0.3, 0.5], "pdf.logo": '/path/to/image/image.jpg' ]
V H
  • 8,382
  • 2
  • 28
  • 48
  • Can you please check my question http://stackoverflow.com/questions/28555958/how-to-generate-multiple-reports-in-groovy-grails-using-export-plugin – VVB Feb 17 '15 at 07:02
  • Can you please tell me how to generate multiple reports using export plugin on single click on button? – VVB Feb 17 '15 at 07:02
  • Another way would be to use ajax - jquery get url so onclick of your first link it triggers a javscript function that sleeps and gets each controller action for the multiple files you wish to download and returns response to a div id... http://stackoverflow.com/questions/25913082/groovy-loading-into-divs/25931268#25931268 as an example but rather than remotefunction you call local javascript funtio – V H Feb 17 '15 at 09:01
  • Can we do something to get it achieved using the same way? – VVB Feb 17 '15 at 09:47
  • I have not tried it but can't see why it can't be possible – V H Feb 17 '15 at 09:53
  • I have seen it on SO, could you please share other useful links with me? – VVB Feb 17 '15 at 09:58
  • This is not a site to share links on - its primarily where you have been attempting something and it has not worked for you. Thus you post what you have tried and others will help you. At this point it seems you need to go away do some reading - possibly look at implementing ajax get method that is triggered upon onClick of a href that itself triggers multiple gets within it that then update a div and upon success the update div is the file being sent to download. Nothing I tried as yet... so hard for me to provide you with links for it. Look around for ajax get methods for a start. – V H Feb 17 '15 at 10:02
  • http://stackoverflow.com/questions/10431049/jquery-ajax-request-in-grails http://stackoverflow.com/questions/13251017/grails-jquery-ajax-request-url-not-working – V H Feb 17 '15 at 10:11
  • Can you please tell me how to take title in the centre of the page? – VVB Feb 19 '15 at 05:53
  • unsure you can, according to documentation: title.font.size (determines title font size, defaults to "10",allowed values: a number as String). You can increase title font size to make up for centralisation... According to http://api.itextpdf.com/itext/com/itextpdf/text/Paragraph.html indentationLeft which is what is defined when a title is added in the source of the plugin https://github.com/gpc/grails-export/blob/master/src/groovy/de/andreasschmitt/export/exporter/DefaultPDFExporter.groovy#L72 . You may have to either raise an issue with plugin or forking and making your own custom plugin – V H Feb 19 '15 at 09:24