pepite / play--pdf

Render a PDF document from your HTML template
53 stars 30 forks source link

ClassCastException: org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox #28

Open tazmaniax opened 11 years ago

tazmaniax commented 11 years ago

Hi Nicolas,

I'm experiencing the following exception when trying to render a PDF: play.exceptions.UnexpectedException: Unexpected Error at play.modules.pdf.RenderPDFTemplate.apply(RenderPDFTemplate.java:102) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:252) at Invocation.HTTP Request(Play!) Caused by: org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException: ERROR: An unhandled exception occured: org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:809) at play.modules.pdf.RenderPDFTemplate.renderDoc(RenderPDFTemplate.java:142) at play.modules.pdf.RenderPDFTemplate.renderPDF(RenderPDFTemplate.java:118) at play.modules.pdf.RenderPDFTemplate.apply(RenderPDFTemplate.java:100) ... 2 more Caused by: java.lang.ClassCastException: org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:127) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:139) at org.xhtmlrenderer.layout.BoxCollector.collect(BoxCollector.java:46) at org.xhtmlrenderer.layout.Layer.paint(Layer.java:314) at org.xhtmlrenderer.pdf.ITextRenderer.paintPage(ITextRenderer.java:391) at org.xhtmlrenderer.pdf.ITextRenderer.writePDF(ITextRenderer.java:355) at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:322) at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:287) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:790) ... 5 more

I believe this issue is more to do with the Flying Saucer transformer then the play-pdf plugin. In fact I think it is this issue which is fixed by this pull request. I'm trying to work out how I get this fix all the way back in to my play app. Is it the case that the Flying Saucer transformer is included via the YaHP project? So will I have to update and build Flying Saucer, then YaHP and then play-pdf? Any assistance appreciated.

cheers, Chris

jayhawk commented 10 years ago

Hi @tazmaniax

did you find a way to fix this issue? I'm also encountering this issue. I tried updating the 3rd party libs but it doesn't work.

lanceon commented 10 years ago

This fix https://github.com/philcali/flyingsaucer/commit/e653850a67b06a08364030a51e5ae4a855213016 with rebuilt jar actually solves the problem.