Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-13457

Customizing the PDF export CSS could cause a NPE

    Details

    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      Since upgrade to CSS4J 0.20, it is no more possible to customize the pdf stylesheet with styles using URLs.

      The issue happen because there no BaseURL associated to the exported document.

      An easy way to work around this issue is to add a

      <base href="$doc.externalURL" />

      tag in #pdfhtmlheader.vm# after the title tag. This will fix a value for the BaseURL of the document, and this will avoid the NPE happening in the CSS4J library.

      The error is silent and cause the CSS not to be applied.
      Here is the stacktrace of this issue that could reach the logs:

      2016-05-26 22:53:27,970 [http://localhost:8080/xwiki/bin/export/Sandbox/TestPDFExport/WebHome] WARN  c.x.x.p.i.PdfExportImpl        - Failed to apply CSS: null 
      java.lang.NullPointerException: null
      	at info.informatica.doc.dom4j.DOM4JDocumentCSSStyleSheet.getHref(DOM4JDocumentCSSStyleSheet.java:48)
      	at info.informatica.doc.style.css.dom.ComputedCSSStyle.setPropertyCSSValue(ComputedCSSStyle.java:76)
      	at info.informatica.doc.style.css.dom.BaseCSSStyleDeclaration.addStyle(BaseCSSStyleDeclaration.java:677)
      	at info.informatica.doc.style.css.dom.BaseCSSStyleSheet.computeStyle(BaseCSSStyleSheet.java:448)
      	at info.informatica.doc.dom4j.DOM4JDocumentCSSStyleSheet.getComputedStyle(DOM4JDocumentCSSStyleSheet.java:75)
      	at info.informatica.doc.dom4j.CSSStylableElement.getComputedStyle(CSSStylableElement.java:144)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyInlineStyle(PdfExportImpl.java:483)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyInlineStyle(PdfExportImpl.java:489)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyInlineStyle(PdfExportImpl.java:489)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyInlineStyle(PdfExportImpl.java:489)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyInlineStyle(PdfExportImpl.java:489)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyCSS(PdfExportImpl.java:449)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.applyCSS(PdfExportImpl.java:422)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.exportHtml(PdfExportImpl.java:257)
      	at com.xpn.xwiki.pdf.impl.PdfExportImpl.export(PdfExportImpl.java:243)
      	at com.xpn.xwiki.web.ExportAction.export(ExportAction.java:239)
      	at com.xpn.xwiki.web.ExportAction.render(ExportAction.java:81)
      	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:432)
      	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:193)
      	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
      	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
      	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
      	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
      	at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:115)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:127)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:137)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
      	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
      	at org.eclipse.jetty.server.Server.handle(Server.java:499)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
      	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
      	at java.lang.Thread.run(Thread.java:745)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vmassol Vincent Massol
                Reporter:
                softec Denis Gervalle
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: