Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Export HTML to Pdf with incorrect image path

    Hello,

    I have a question related to export to pdf. I am using SmartGWT 5.1p.

    I have the following simple HTML. The path to the image is not correct, but I would like to export it either way to pdf, skipping the image.

    <html>
    <body>
    Text in here 2<br/>
    <img src="img/image_name_in_here.gif" alt="Alternate Text" />
    </body>
    </html>

    If I use RPCManager.exportContent I get the following warning: “Builtin RPC: getPdfObject: Server returned FAILURE with no error message performing operation 'custom'.” and no errors in the server console.
    If I use PdfExport- getPdfRenderer I get an error (caused by the path of the image that does not exist).
    ITextRenderer renderer = export.getPdfRenderer(html, settings);
    renderer.createPDF(file);
    java.lang.NullPointerException
    at com.isomorphic.contentexport.B64ImgReplacedElementFactory.createReplacedElement(B64ImgReplacedElementFactory.java:146)
    at org.xhtmlrenderer.render.BlockBox.calcDimensions(BlockBox.java:674)
    at org.xhtmlrenderer.render.BlockBox.calcDimensions(BlockBox.java:628)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:763)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
    at org.xhtmlrenderer.layout.InlineBoxing.layoutInlineBlockContent(InlineBoxing.java:393)
    at org.xhtmlrenderer.layout.InlineBoxing.layoutContent(InlineBoxing.java:290)
    at org.xhtmlrenderer.render.BlockBox.layoutInlineChildren(BlockBox.java:938)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:919)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:293)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:271)
    at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:89)
    at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:922)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
    at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
    at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:209)
    at com.isomorphic.contentexport.PdfExport.getPdfRenderer(PdfExport.java:347)

    If I do not use PdfExport and create a new ITextRenderer it will work correctly.
    ITextRenderer renderer = new ITextRenderer();
    renderer.setDocumentFromString(html);
    renderer.layout();
    renderer.createPDF(file);

    Is there a parameter that I can set on the settings map so that PdfExport – getPdfRenderer will work the same as creating a new ITextRenderer.

    Thank you very much for your help,
    Andreea

    #2
    Start by trying with the latest patched version and let us know if you have any similar problem. Remember also to always post your full version.

    You also need to explain how specifically you are providing that HTML and triggering export - is it inside an HTMLFlow? Just part of a CellFormatter or similar? We need enough information to reproduce the problem (if there really is one, once you are up to date..).

    Comment


      #3
      Hello,

      Thank you very much for your replay.
      I have download it the last build from 5.1p (Smart GWT Pro Edition (2017-05-18 nightly)) and it is still behaving in the same way.
      We have an HtmlPane to which we set the contents and we send the pane to export. Below is the code that we are using:

      HTMLPane hp = new HTMLPane();
      hp.setContents("<html><body>Text in here 2<br/><img src="img/image_name_in_here.gif" alt="Alternate Text" /></body></html>");
      hp.setWidth(500);
      hp.setHeight(500);

      DSRequest requestProperties = new DSRequest();
      requestProperties.setExportFilename("Pdf_name_in_here.pdf");
      requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
      requestProperties.setContentType("application/pdf");
      requestProperties.setSkinName("Enterprise");
      requestProperties.setDownloadResult(true);
      RPCManager.exportContent(hp, requestProperties);

      The error is below:

      Invocation threw exception
      java.lang.NullPointerException
      at com.isomorphic.contentexport.B64ImgReplacedElementFactory.createReplacedElement(B64ImgReplacedElementFactory.java:146)
      at org.xhtmlrenderer.render.BlockBox.calcDimensions(BlockBox.java:674)
      at org.xhtmlrenderer.render.BlockBox.calcDimensions(BlockBox.java:628)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:763)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
      at org.xhtmlrenderer.layout.InlineBoxing.layoutInlineBlockContent(InlineBoxing.java:393)
      at org.xhtmlrenderer.layout.InlineBoxing.layoutContent(InlineBoxing.java:290)
      at org.xhtmlrenderer.render.BlockBox.layoutInlineChildren(BlockBox.java:938)
      at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:919)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:293)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:271)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:89)
      at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:922)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:293)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:271)
      at org.xhtmlrenderer.layout.BlockBoxing.layoutContent(BlockBoxing.java:89)
      at org.xhtmlrenderer.render.BlockBox.layoutChildren(BlockBox.java:922)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:802)
      at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:732)
      at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:209)
      at com.isomorphic.contentexport.PdfExport.getPdfRenderer(PdfExport.java:347)
      at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:76)
      at com.isomorphic.rpc.BuiltinRPC.getPdfObject(BuiltinRPC.java:1159)
      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 com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:964)
      at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:794)
      at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:321)
      at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:67)
      at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:249)
      at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:355)
      at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:184)
      at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:152)
      at com.isomorphic.servlet.IDACall._processRequest(IDACall.java:119)
      at com.isomorphic.servlet.IDACall.doPost(IDACall.java:79)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
      at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:162)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      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)

      As mentioned in the previou post, if we create a servlet and use the code from below that receives an html content as a string we get the same error.

      Map settings = new HashMap();
      settings.put("skinName", "Enterprise");
      PdfExport export = new PdfExport();
      ITextRenderer renderer = export.getPdfRenderer("<html><body>Text in here<br/><img src="img/image_name_in_here.gif" alt="Alternate Text" /></body></html>", settings);
      renderer.createPDF(file);

      Thank you for your help,
      Andreea

      Comment


        #4
        We've made a change to address this issue. Please try the next nightly build, dated May 25.

        Regards
        Isomorphic Software

        Comment


          #5
          Hello,

          Thank you very much for your help. As soon as it is out I will give it a try.
          Have a great day,

          Andreea

          Comment


            #6
            Hello,

            It is working as expected. Thank you for making the change.

            Have a great weekend,
            Andreea

            Comment

            Working...
            X