GithubHelp home page GithubHelp logo

gpc / rendering Goto Github PK

View Code? Open in Web Editor NEW
31.0 11.0 44.0 15.79 MB

Provides rendering of GSPs as PDFs, JPEGs, GIFs and PNGs

Home Page: http://gpc.github.com/rendering

License: Apache License 2.0

Groovy 97.16% Shell 2.84%

rendering's Introduction

Build Status

Rendering Grails Plugin

This plugin adds PDF, GIF, PNG and JPEG rendering facilities to Grails applications via the XHTML Renderer library.

Rendering is either done directly via one of the «format»RenderingService services …

ByteArrayOutputStream bytes = pdfRenderingService.render(template: "/pdfs/report", model: [data: data])

Or via one of the render«format»() methods added to controllers …

renderPdf(template: "/pdfs/report", model: [report: reportObject], filename: reportObject.name)

Please see the User Guide for more information.

The plugin is released under the Apache License 2.0 and is produced under the Grails Plugin Collective. However, it does LGPL libraries: XhtmlRenderer and iText.

rendering's People

Contributors

ari651 avatar burtbeckwith avatar codeconsole avatar graemerocher avatar halfbaked avatar ldaley avatar magx2 avatar sbglasius avatar zacharyklein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rendering's Issues

Unable to generate pdf with grails version 2.5.0

I am trying to render html file to pdf using rendering plugin, my controller method is,

    def download() {
    response.contentType = 'application/pdf'
    response.setHeader("Content-disposition", "attachment; filename=\"download.pdf\"")
    def items = []
    (101..105).each { number->
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        items << [number:number, bytes:bos.toByteArray()]
    }

    renderPdf (template:'download', model:[items:items])
}

And my _download.gsp file is,

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<body>
<g:each in="${items}" var="item">
    <div>This is the barcode for the number: ${item.number}</div>
    <hr/>
</g:each>
</body>
</html>

I have added following dependencies in BuildConfig.groovy file

compile ":rendering:1.0.0"

I received following stack-trace,

| Error 2015-08-06 16:35:28,925 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver  - NullPointerException occurred when processing request: [GET] /wheeloflife/test/download
Stacktrace follows:
Message: null
    Line | Method
->> 1281 | getPublicDeclaredMethods in java.beans.Introspector
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1141 | getTargetMethodInfo      in     ''
|    416 | getBeanInfo . . . . . .  in     ''
|    163 | getBeanInfo              in     ''
|     31 | init . . . . . . . . . . in grails.plugin.rendering.document.RenderEnvironment
|     68 | with                     in     ''
|     60 | with . . . . . . . . . . in     ''
|     65 | generateXhtml            in grails.plugin.rendering.document.XhtmlDocumentService
|     35 | createDocument . . . . . in     ''
|     36 | render                   in grails.plugin.rendering.RenderingService
|     35 | render . . . . . . . . . in     ''
|     65 | render                   in     ''
|     59 | doCall . . . . . . . . . in RenderingGrailsPlugin$_closure3
|     18 | download                 in com.codeharmony.wheeloflife.TestController$$EPKZmnkm
|    198 | doFilter . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter                 in grails.plugin.cache.web.filter.AbstractFilter
|     53 | doFilter . . . . . . . . in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
|     62 | doFilter                 in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . .  in java.lang.Thread

Note Update: The same code base works with grails version 2.2.4, problem only seen in grails version 2.5.0

Not compatible with the latest version of iText

With all the dependencies that one can encounter using this plugin in along with others like the export plugin, I had manually added a dependency to the latest version of iText, but it seems that this breaks if you try use the inLine images. It appears they have changed the constructor of the ImageResource class. They could really have left the original constructor!

Here is the related commit on flying saucer:

flyingsaucerproject/flyingsaucer@f529ecc

Plugin fails to render some elements that are referenced using absoute URL with the file URI notation file:///

After a while using the Rendering plugin I realized that the best way to reference resources (css, img, fonts, ...) is using the file:/// URI notation because we are going to render the PDF locally anyway. The problem is that although the plugin renders the images properly (eg: <img src="file:///..."/>), it fails to resolve the css resources using this perfectly valid URI notation (http://en.wikipedia.org/wiki/File_URI_scheme)

I have been trying to find the problem unsuccessfully.

This would make unnecessary to harcode the URL in the Groovy.config file and open the door to resolve the URLs dynamically and avoid network configuration problems.

Cheers,
Angel.

Plugin not working Grails 2.2.3 - Error java.io.IOException: Stream closed

After upgrading my project from 2.1.2 to 2.2.3 (cleaning and retesting old functionality) plugin is throwing IOException but eventually renders pdf

[ controller logic @ end of action ]
def args = [template:"pdf", model:[myDomainInstance:myDomainInstance]]
pdfRenderingService.render(args+[controller:this],response)

[ Stacktrace ]

| Error java.io.IOException: Stream closed
| Error at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:151)
| Error at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
| Error at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
| Error at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
| Error at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
| Error at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
| Error at java.io.InputStreamReader.read(InputStreamReader.java:184)
| Error at org.xhtmlrenderer.css.parser.Lexer.zzRefill(Lexer.java:1634)
| Error at org.xhtmlrenderer.css.parser.Lexer.yylex(Lexer.java:1865)
| Error at org.xhtmlrenderer.css.parser.CSSParser.next(CSSParser.java:1798)
| Error at org.xhtmlrenderer.css.parser.CSSParser.la(CSSParser.java:1810)
| Error at org.xhtmlrenderer.css.parser.CSSParser.stylesheet(CSSParser.java:159)
| Error at org.xhtmlrenderer.css.parser.CSSParser.parseStylesheet(CSSParser.java:89)
| Error at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:78)
| Error at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:95)
| Error at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:174)
| Error at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:123)
| Error at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:107)
| Error at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:175)
| Error at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
| Error at org.xhtmlrenderer.pdf.ITextRenderer$setDocument.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
| Error at grails.plugin.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:36)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:601)
| Error at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
| Error at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
| Error at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
| Error at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:43)
| Error at grails.plugin.rendering.pdf.PdfRenderingService.render(PdfRenderingService.groovy)
| Error at grails.plugin.rendering.RenderingService$render$1.callCurrent(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
| Error at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:37)
| Error at grails.plugin.rendering.pdf.PdfRenderingService.render(PdfRenderingService.groovy)
| Error at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:35)
| Error at grails.plugin.rendering.pdf.PdfRenderingService.render(PdfRenderingService.groovy)
| Error at grails.plugin.rendering.RenderingService$render$0.callCurrent(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
| Error at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:65)
| Error at grails.plugin.rendering.pdf.PdfRenderingService.render(PdfRenderingService.groovy)
| Error at grails.plugin.rendering.RenderingService$render.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
| Error at edu.harvard.hums.BatchListController.print(BatchListController.groovy:237)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:601)
| Error at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper.invoke(MixedGrailsControllerHelper.java:69)
| Error at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.invoke(ProxyAwareMixedGrailsControllerHelper.java)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleAction(AbstractGrailsControllerHelper.java:343)
| Error at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleAction(ProxyAwareMixedGrailsControllerHelper.java)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.executeAction(AbstractGrailsControllerHelper.java:226)
| Error at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.executeAction(ProxyAwareMixedGrailsControllerHelper.java)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:192)
| Error at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleURI(ProxyAwareMixedGrailsControllerHelper.java)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:116)
| Error at grails.plugin.cache.web.ProxyAwareMixedGrailsControllerHelper.handleURI(ProxyAwareMixedGrailsControllerHelper.java)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:72)
| Error at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
| Error at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:328)
| Error at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
| Error at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
| Error at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
| Error at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
| Error at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
| Error at grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter.doFilter(MemoryPageFragmentCachingFilter.java)
| Error at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
| Error at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
| Error at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
| Error at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
| Error at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
| Error at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
| Error at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:314)
| Error at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:279)
| Error at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:270)
| Error at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:222)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:206)
| Error at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:152)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at javax.servlet.FilterChain$doFilter.call(Unknown Source)
| Error at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanityFilter.groovy:44)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)
| Error at org.springframework.security.web.authentication.switchuser.SwitchUserFilter.doFilter(SwitchUserFilter.java:178)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
| Error at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
| Error at org.codehaus.groovy.grails.plugins.springsecurity.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:40)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.codehaus.groovy.grails.plugins.springsecurity.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:79)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
| Error at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
| Error at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)
| Error at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
| Error at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:66)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
| Error at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
| Error at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
| Error at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
| Error at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
| Error at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
| Error at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
| Error at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
| Error at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
| Error at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
| Error at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
| Error at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
| Error at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
| Error at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
| Error at java.lang.Thread.run(Thread.java:722)

Error in docs about save to File

Hi guys,

There's an error in documentation related to save PDF directly to a File. In chapter 3 'Rendering' on the second example box, one parameter is missing resulting in save a blank PDF. Here is the correct version. Otherwise it render a blank PDF...

// Get the bytes
def bytes = gifRenderingService.render(template: '/images/coupon', model: [serial: 12345])
// Render to a file
new File("coupon.jpg").withOutputStream { outputStream ->
jpegRenderingService.render([template: '/images/coupon', model: [serial: 12345]],outputStream)
}

I use this plugin for almost 3 years now for all embedded reports I need to do. It's really awesome.

Thanks in advance!

Issues with Grails PDF Renderer after using XWPF PDF Converter

Existing Grails Code is as follows:

FileOutputStream os = new FileOutputStream(filename)
ITextRenderer renderer = new ITextRenderer()
configureRenderer(renderer)
org.w3c.dom.Document document = getTheDocument()
renderer.setDocument(document, grailsApplication.config.grails.serverURL)
renderer.layout()
renderer.createPDF(os)

Now added

org.apache.poi.xwpf.converter.pdf.PdfOptions options = org.apache.poi.xwpf.converter.pdfPdfOptions.create();
OutputStream outputStream = new FileOutputStream(fileNameWithDirectory)
PdfConverter.getInstance().convert(docxDocument, outputStream, options)
outputStream.close()

Now call the original code again. Get an Exception on line creating new ITextRenderer() :

java.lang.RuntimeException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized.
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:470) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.<init>(ITextFontResolver.java:40) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:124) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:110) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:106) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:102) ~[flying-saucer-pdf-9.1.12.jar:na]
Caused by: com.lowagie.text.DocumentException: Font 'Courier-BoldOblique' with 'Cp1252' is not recognized.
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:696) ~[itext-4.2.1.jar:na]
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:603) ~[itext-4.2.1.jar:na]
    at com.lowagie.text.pdf.BaseFont.createFont(BaseFont.java:438) ~[itext-4.2.1.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:483) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createFont(ITextFontResolver.java:479) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:491) ~[flying-saucer-pdf-9.1.12.jar:na]
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:459) ~[flying-saucer-pdf-9.1.12.jar:na]

build.gradle is as follows:

compile 'org.xhtmlrenderer:flying-saucer-core:9.1.12'
compile 'org.xhtmlrenderer:flying-saucer-pdf:9.1.12'
compile 'org.xhtmlrenderer:flying-saucer-log4j:9.1.12'

compile ('org.grails.plugins:rendering:2.0.3') {
        exclude group: 'org.xhtmlrenderer', module: 'core-renderer'
}

compile("com.lowagie:itext:4.2.1")

rxjava-groovy - scala - Template not found exception

Hi,

I am not sure if this issue is related to grails-rendering, anyway when I tried to generate a pdf I always got an UnknownTemplateException (grails.plugin.rendering.document.UnknownTemplateException: Could not find template for '/test')

My template is located in /grails-app/views/_test.gsp and pdfRenderingService is called within a method "test" this way

            Future<Collection<XXX>> futureResult = ...
            ...
            futureResult.onComplete({scala.util.Try<Collection<XXX>> t ->
                Collection<XXX> coll = t.get()
                coll.each { item ->
                    try{
                        test(item)
                    }
                    catch(Throwable th){
                        log.error(th.message, th)
                    }
                }
            } as Function1, ec)

    void test(XXX item){
        ...
        final template = "/test"
        def bos = new ByteArrayOutputStream()
        pdfRenderingService?.render([template: template, model:model], bos)
        ...
    }

Support Grails 3

given Grails 3.0.0 GA was just released, it would be nice to see this plugin work with Grails 3 :)

thanks, zyro

Adding custom Font

I want to use font-family custom font family for the text in my rendered pdf but the plugin doesn't recognize the font-family I try to provide in the template. Tried every solution I could find, but no luck.

Thanks in advance

How to fetch corresponding data from table in grails using dropdown? IMPORTANT

I have a table consisting of 2 parameters(name and calendar).I have created the dropdown using <g:select> tag that consists list of names from the table,on selection I want to fetch the corresponding calendar and display it.Any idea how can I fetch the calendar related to name?

this is my gsp code which gives list of names as dropdown

<g:select class="form-control" id="savedCalendar" name="savedCalendar.id" noSelection="['null':'']" from="${globalCalendar?.name}" onchange="return showcal()"/>

what should I do in function so that I can fetch calendar and display it

`
function showcal(){

       ????

}
`
Can anyone please guide me on this?
Thanks in advance

Inconsistent capitalization of pdfRenderingService

When importing the service in a controller the service needs to be named PdfRenderingService but when using in the controller action it must be pdfRenderingService

class SystemController {
    def PdfRenderingService

    def compose_one_for() {
        if (!params?.id) params.id = 1
        def customer = Customer.findById(params.id)
        pdfRenderingService.render(template: "/pdfs/firstLetter", model:[customer:customer], response)
    }
}

When changing the capitalization of pdfRenderingService in one case it wont work.

Version 1.0.0 not supported on Grails 1 (< Grails 2.0)

On the Grails Plugin site, this plugin claims to be supported on versions Grails 1.3.0 and greater. However, due to the addition of the grails.util.Holders class on the XhtmlDocumentService.groovy, this plugin is not supported by any Grails version less than Grails 2.0.

Please update the Plugin description on grails.org/plugin or release a change to version 1.0.0 that makes it compatible with the earlier versions of Grails.

Link to page indicating it is compatible with Grails 1.3.0 >:
https://grails.org/plugin/rendering?skipRedirect=true

Deceptive license

The grails-rendering plugin is licensed as Apache 2.0, but utilizes LGPL 2.1 dependencies in the form of XHTML core-renderer (org.xhtmlrenderer:core-renderer:R8).

Might want to make this a bit clearer from the get go. It can be a make-or-break factor for a lot of developers.

No wiring beans when using Grails Rendering Plugin

When I add Grails Rendering Plugin (compile "org.grails.plugins:rendering:2.0.1") into my dependencies all my SpockUnit test with controllers are getting broken.

The error that I got is:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [grails.plugins.rendering.image.PngRenderingService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
    ... 38 more

Also I have in my build.gradle file dependency on Spring test: runtime 'org.springframework:spring-test:4.1.7.RELEASE'. As far as I know this is needed for rendering plugin

Grails version: 3.0.9

Won't render pdf

Grails version: 3.3.1 Rendering plugin: 2.0.3
To duplicate, create a Grails project with one class called Person with three String attributes: name, surname, emailAddress. At the bottom of the show view I have this:
<g:link class="edit" action="pdfThis" resource="${this.person}">Pdf This</g:link>
The method in the controller is this:

def pdfThis(Long id){
        def person = Person.get(id)
        if(person){
            pdfRenderingService.render(template: "/templates/pdf/person", model: [person: person], controller: "person", response) // this is line 105
        }
    }

I notice that def pdfRenderingService does not work anymore. One has to have:
grails.plugins.rendering.pdf.PdfRenderingService pdfRenderingService in the controller.

This is the template, called _person.gsp, in views/templates/pdf/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
    <head>
        <title>A PDF Document</title>
    </head>
    <body>
        <h1>${person?.name} ${person?.surname}</h1>
        <p>
            Your email address: ${person?.emailAddress}
        </p>
    </body>
 </html>

These are the exceptions:

java.lang.reflect.InvocationTargetException: null
        at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
        at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
        at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
        at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
        at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1337)
        at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197)
        at java.beans.Introspector.getBeanInfo(Introspector.java:426)
        at java.beans.Introspector.getBeanInfo(Introspector.java:173)
        at grails.plugins.rendering.document.RenderEnvironment.init(RenderEnvironment.groovy:31)
        at grails.plugins.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:68)
        at grails.plugins.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:60)
        at grails.plugins.rendering.document.XhtmlDocumentService.generateXhtml(XhtmlDocumentService.groovy:65)
        at grails.plugins.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:35)
        at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:36)
        at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:35)
        at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:65)
        at rendering.PersonController.pdfThis(PersonController.groovy:105)

I have no idea what is null and why it is null. Everything I am responsible for is there and is not null.

& character

I having an error org.xml.sax.SAXParseException when rendering pdf when my model have '&' character value. how to resolve this?

Can't read cyrillic text

I'm trying to use thymeleaf and flyingsaucer to generate pdf from html-template. thymeleaf fills template and flyingsaucer create pdf-file. I'm using cyrillic font in template, but after generate pdf-file is empty.
Code
ITextFontResolver fontResolver = renderer.getFontResolver(); ClassPathResource regular = new ClassPathResource("fonts/arial.ttf"); fontResolver.addFont(regular.getURL().toString(), BaseFont.IDENTITY_H, true);
is working great, but I want to avoid this approach. So, I tried to use approach like in this example stackoverflow.com/questions/7525403/how-to-embed-font-in-pdf-created-from-html-with-itext-and-flying-saucer but it doesnt work in my case.
My html-style section:
@font-face { font-family: 'Arial Serif'; src: url('../fonts/arial.ttf'); -fs-pdf-font-embed: embed; -fs-pdf-font-encoding: Identity-H; }
and the body-tag:
body style="font-family: 'Arial Serif'"
Tell me, please, where is I've made mistake.

Add SVG support

Hi,

I have some graphics in my project I made using d3.js but the plugin hasn't been able to render them as pdf.

Thanks

please add font-family support

I want to use font-family verdana for the text in my rendered pdf but the plugin doesn't recognize the css with font-family and the rendered pdf is with default font-family and serif.

It would be also fine if you would update the itext version.

Having trouble getting it to work with grails 3

Hi there,

I am trying to migrate an old grails app to grails 3. I am using grails 3.0.10. I was using the rendering plugin in my old app to generate PDFs and have a bunch of PDFs built this way which I would like to keep intact, so I'm trying to get this rendering plugin installed in my grails 3 app. As suggested, I have added the following line to my build.gradle under the dependencies:

compile "org.grails.plugins:rendering:2.0.0-SNAPSHOT"

This seems to correctly pull this plugin .jar file and the run-app works. However, when I try to render a gsp as a PDF through my controller I'm getting a NullPointerException that is being thrown by some code in the rendering plugin. I am including the stack trace below. Can you please let me know how I could correct this issue?

ERROR org.grails.web.errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /test/testPDF
Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: java.lang.NullPointerException: null
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1281) ~[na:1.7.0_79]
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1141) ~[na:1.7.0_79]
at java.beans.Introspector.getBeanInfo(Introspector.java:416) ~[na:1.7.0_79]
at java.beans.Introspector.getBeanInfo(Introspector.java:163) ~[na:1.7.0_79]
at grails.plugins.rendering.document.RenderEnvironment.init(RenderEnvironment.groovy:31) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:68) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:60) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.document.XhtmlDocumentService.generateXhtml(XhtmlDocumentService.groovy:65) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:35) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:36) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:35) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:65) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at grails.plugins.rendering.RenderingTrait$Trait$Helper.renderPdf(RenderingTrait.groovy:47) ~[rendering-2.0.0-SNAPSHOT.jar:na]
at com.svp.controller.TestController$_closure1.doCall(TestController.groovy:14) ~[main/:na]
... 3 common frames omitted

plugin does'nt work with Grails 2.0.0.M1

Hi, i'm trying to use the plugin with grails 2.0.0.M1, but it complains that the namespace "rendering" can't be found.
Tag [inlinePng] does not exist. No tag library found for namespace: rendering

Exception on using External CSS

Hi there,
Is anyone successfully used external css like bootstrap.css on rendering pdf?. I am getting pdf that has only contents not styles with some exception thrown as shown below. If anyone got solution for this?

grails version 3.1.11
rendering:2.0.0-SNAPSHOT
spring-test:4.2.1.RELEASE

java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:159)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at org.xhtmlrenderer.css.parser.Lexer.zzRefill(Lexer.java:1634)
    at org.xhtmlrenderer.css.parser.Lexer.yylex(Lexer.java:1865)
    at org.xhtmlrenderer.css.parser.CSSParser.next(CSSParser.java:1798)
    at org.xhtmlrenderer.css.parser.CSSParser.la(CSSParser.java:1810)
    at org.xhtmlrenderer.css.parser.CSSParser.stylesheet(CSSParser.java:159)
    at org.xhtmlrenderer.css.parser.CSSParser.parseStylesheet(CSSParser.java:89)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:78)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:95)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:174)
    at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:123)
    at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:107)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:175)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
    at org.xhtmlrenderer.pdf.ITextRenderer$setDocument.call(Unknown Source)
    at grails.plugins.rendering.pdf.PdfRenderingService.doRender(PdfRenderingService.groovy:36)
    at sun.reflect.GeneratedMethodAccessor207.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1432)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
    at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:43)
    at grails.plugins.rendering.RenderingService$render$1.callCurrent(Unknown Source)
    at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:37)
    at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:35)
    at grails.plugins.rendering.RenderingService$render$0.callCurrent(Unknown Source)
    at grails.plugins.rendering.RenderingService.render(RenderingService.groovy:65)
    at grails.plugins.rendering.RenderingService$render.call(Unknown Source)
    at com.test.SampleController$$EPwfKUe8.$tt__renderPdf(SampleController.groovy:110)
    at com.test.SampleController$$DPwfKUe8.$tt__renderPdf(Unknown Source)
    at com.test.SampleController.$tt__renderPdf(SampleController.groovy)
    at com.test.SampleController$_renderPdf_closure4$$EPwfKVAO.doCall(SampleController.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springsource.loaded.ri.ReloadedTypeInvoker$2.invoke(ReloadedTypeInvoker.java:133)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
    at groovy.lang.Closure.call(Closure.java:414)
    at com.test.SampleController$_renderPdf_closure4.call(SampleController.groovy)
    at groovy.lang.Closure.call(Closure.java:430)
    at com.test.SampleController$_renderPdf_closure4.call(SampleController.groovy)
    at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
    at com.test.SampleController$$EPwfKUe8.renderPdf(SampleController.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springsource.loaded.ri.ReloadedTypeInvoker$2.invoke(ReloadedTypeInvoker.java:133)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
    at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:210)
    at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:187)
    at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:89)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:75)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

Achieving Page Rotation with Rendering Plugin

Hello!

We are using the rendering plugin (0.4.4) with grails version 2.2.4 to generate a pdf file via the RenderingService. Our controller uses the following lines of code to generate and save the file locally on the server:

new File(completeFileName).withOutputStream { outputStream ->
            pdfRenderingService.render(controller: this, template: 'report/ReportPdfTmpl', model:[id : id], outputStream)};

We are trying to rotate the first page 90 degrees counterclockwise so that even if it is printed as portrait, it still has a default landscape orientation. This is similar to what we can achieve via the transform : rotate (-90deg) property in html markup in a browser. Is it possible to achieve this for the generated pdf? If so, please let us know how.

Thank you!

Add custom config property(optional) for resolving relative links

The plugin uses grails.serverURL to handle relative links. Can you add support for some custom config property which can override this behaviour?It would be useful when you want to easily specify different url base for resources.

For example, I have an application using SSL, so my grails.serverURL = 'https://....'.
When rendering engine want to resolve css and images, application also makes https request, but it does not have proper certificate (it's not the browser).
If I could specify some other config variable to 'http:localhost:8080' for example, than the application would not have to go via apache, and the resources will be fetched without any problems.

Thank you

incompatible return type issue

I am working on a grails 3 (version 3.2.3) project where it needs to convert a gsp into a pdf. I tried to use the rendering plugin provided by grails. I imported the plugin using:
compile 'org.grails.plugins:rendering:2.0.3'
in my build.gradle file
and in my controller i used:
ByteArrayOutputStream bytes = pdfRenderingService.render(template: "/templates/pdf_PI", model: [proformaInvoice: proformaInvoice])
to render the pdf. The service is injected using def pdfRenderingService

however i m getting this error

grails-app/controllers/chsam/re/ProformaInvoiceController.groovy: -1: The return type of java.lang.Object getPdfRenderingService() in chsam.re.ProformaInvoiceController is incompatible with grails.plugins.rendering.pdf.PdfRenderingService in grails.plugins.rendering.RenderingTrait. At [-1:-1] @ line -1, column -1.

NoUniqueBeanDefinitionException with service extending PdfRenderingService in Grails 3

I have a project where we needed to override the pdfRenderingService behavior slightly, so we added a Grails service extending PdfRenderingService named "FixedPdfRenderingService". This causes an error on startup:

NoUniqueBeanDefinitionException: No qualifying bean of type 'grails.plugins.rendering.pdf.PdfRenderingService' available: expected single matching bean but found 2: renderingPdfRenderingService,fixedPdfRenderingService

It seems that in Grails 3.2.4, plugin service beans get prefixed by the plugin name, so "pdfRenderingService" from the rendering plugin becomes "renderingPdfRenderingService". I'm not sure if this is causing problems with @Autowire directly, or whether having two beans with this type causes a non-unique exception.

Should RenderingTrait specify rendering*Service instead? Is there a different way we should be overriding PdfRenderingService behavior?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.