1
votes

I'm generating pdf file on symfony2 using SpraedPDFGeneratorBundle. My problem is that this bundle generates this error only when specifying a path to a css file:

link rel="stylesheet" href="{{ app.request.scheme ~'://'~ app.request.httpHost ~ asset('assets/plugins/bootstrap/css/bootstrap.css') }}"

CRITICAL - Uncaught PHP Exception RuntimeException: "The exit status code '1' says something went wrong: stderr: "Exception in thread "main" 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:46) at org.xhtmlrenderer.layout.Layer.paint(Layer.java:314) at org.xhtmlrenderer.pdf.ITextRenderer.paintPage(ITextRenderer.java:384) at org.xhtmlrenderer.pdf.ITextRenderer.writePDF(ITextRenderer.java:348) at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:315) at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:280) at com.spraed.flyingsaucer.PDFGenerator.main(PDFGenerator.java:98) " stdout: "" command: java -Djava.awt.headless=true -jar "C:\wamp\www\EchriliPro\vendor\spraed\pdf-generator-bundle\Spraed\PDFGeneratorBundle/Resources/java/spraed-pdf-generator.jar" --html "C:\Windows\TEMP\tmp5593ef4087c76." --pdf "C:\Windows\TEMP\output5593ef4087c76.pdf" --encoding UTF-8." at C:\wamp\www\EchriliPro\vendor\spraed\pdf-generator-bundle\Spraed\PDFGeneratorBundle\PDFGenerator\PDFGenerator.php line 175
1
Maybe it's not able to parse bootstrap.css.Please have a look at stackoverflow.com/questions/28764146/…smarber
However if I write css classes in <style> it works fine.Besbes Riadh
thanks!! that worked fine.Besbes Riadh

1 Answers

0
votes

I had the same problem. As commented in this issue your asset URLs need to be absolute.

This can be accomplished in symfony using the asset twig funtion and "package urls":

http://symfony.com/doc/current/reference/configuration/framework.html#assets-base-urls