简体   繁体   中英

How to add page header & footer to pdf using export plugin in grails?

I am able to generate & download pdf file using export plugin . But, now I want to add PAGE HEADER & FOOTER in the pdf .

Can anybody please tell me how can I achieve that? Reference links are also ok. Thank you.

This plugin isn't designed to support these features, however, you can implement them if you want.

If you take a look at the default implementation for the DefaultPDFExporter which is used by the plugin to render PDF documents you will see it does include a blank footer, but you can't configure the text. You will also see that it doesn't support adding in a header either. This means you are going to have to write your own PDF exporter implementation.

Since you want to generate a custom PDF document you will need to implement your own version of the DefaultPDFExporter which does support these features. You can do this by extending the AbstractExporter and using the DefaultPDFExporter as your guide. You will also need to configure your application to use your own implementation instead of the default. Take a look at the doWithSpring section of the ExportGrailsPlugin.groovy to see how your exporter bean should be defined in your Resources.groovy .

This isn't something that is exactly straight forward or easy. It does require you to have a good understanding of Grails, Spring, and Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM