문제

I have an html template which I need to render as a .PDF and then save that pdf file on server. I'm using "rendering" plugin of grails. I'm able to render file as PDF but I don't understand how to save it on server location and not on user's system. Can anybody please help me ?

도움이 되었습니까?

해결책

The pdfRenderingService provided by the plugin allows you to call render and get back an OutputStream. Using that output stream you can write that to a file on your server. The documentation explains the basics of using the service.

Your code may look something like this:

new File("report.pdf").withOutputStream { outputStream ->
            outputStream << pdfRenderingService.render(template: '/report/report', model: [serial: 12345])
        }

다른 팁

Well, actually I changed my plugin. Got Wkhtmltopdf plugin of grails more helpful. you can find it here -- https://github.com/quorak/grails-wkhtmltopdf

Also instructions regarding using this plugin you can find on the same link or here --

[https://github.com/quorak/grails-wkhtmltopdf]

Using this you can get "bytes" which you can write to file system.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top