Announcement

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

    Problems with pdf export

    SmartClient Version: v9.0p_2013-08-16/Pro Deployment (built 2013-08-16)

    I'm having some problems exporting a Layout to PDF in a deployed environment.

    All the package dependencies have been added according to the manual, and export works fine in hosted mode, but when i deploy to a local tomcat server, export just opens a new tab with the following text in a small textbox:

    //isc_RPCResponseStart-->[{status:-1,data:null}]//isc_RPCResponseEnd


    This is the code used to create the export.

    Code:
    DSRequest requestProperties = new DSRequest();
    requestProperties.setExportFilename(reportTitle.replace(' ', '_'));
    requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
    requestProperties.setContentType("application/pdf");
    requestProperties.setDownloadResult(true);
    RPCManager.exportContent(contentLayout, requestProperties);
    I have looked in the tomcat logfiles, but can find no errors.

    Do you have any idea what could cause this error?

    #2
    This response indicates a (generic) server error.
    (Normally this response text would be interpreted by the framework and an error message would be displayed as part of the standard RPCManager handleError flow, but it's not happening in this case as the response is being sent to a new window for download).

    In short, something is going wrong on the server, and there should be an error being logged for this! Without seeing the error we can't comment on what the problem might be (though it's most likely some subtle configuration error).
    If you can't find the problem yourself, show us the complete server logs (for the transaction) and we'll take a look.

    Regards
    Isomorphic Software

    Comment


      #3
      Okay so it seems like the error is caused by a missing font because it is looking for the font in a weird place. (/var/lib/tomcat7/webapps/ROOT/com.wolwa.emp.Application/sc/skins/Forecast/imagesfile:/usr/share/tomcat7/agenda-medium-webfont.eot)

      For some reason it has added "imagesfile:/usr/share/tomcat7/" in front of the filename.
      Code:
      === 2013-12-05 13:10:27,572 [-219] INFO  PdfExport - CharSet used: UTF-8
      === 2013-12-05 13:10:27,779 [-219] WARN  ResourceLoader - Failed to download file:/usr/share/tomcat7/agenda-medium-webfont.eot: java.io.FileNotFoundException: /usr/share/tomcat7/agenda-medium-webfont.eot (No such file or directory)
      === 2013-12-05 13:10:27,779 [-219] WARN  ResourceLoader - Resource 'file:/usr/share/tomcat7/agenda-medium-webfont.eot' not found: java.io.FileNotFoundException: /var/lib/tomcat7/webapps/ROOT/com.wolwa.emp.Application/sc/skins/Forecast/imagesfile:/usr/share/tomcat7/agenda-medium-webfont.eot (No such file or directory)
      === 2013-12-05 13:10:27,779 [-219] DEBUG RPCDMI - Invocation threw exception
      java.lang.NullPointerException
      	at org.xhtmlrenderer.swing.NaiveUserAgent.getBinaryResource(NaiveUserAgent.java:228)
      	at org.xhtmlrenderer.pdf.ITextFontResolver.importFontFaces(ITextFontResolver.java:97)
      	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:178)
      	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
      	at com.isomorphic.contentexport.PdfExport.getPdfRenderer(PdfExport.java:335)
      	at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:77)
      	at com.isomorphic.rpc.BuiltinRPC.getPdfObject(BuiltinRPC.java:826)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:616)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:972)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:804)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:309)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
      	at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:231)
      	at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:284)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:168)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:137)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      	at java.lang.Thread.run(Thread.java:679)
      === 2013-12-05 13:10:27,780 [-219] WARN  RequestContext - rpcRequest.execute() failed: 
      java.lang.NullPointerException
      	at org.xhtmlrenderer.swing.NaiveUserAgent.getBinaryResource(NaiveUserAgent.java:228)
      	at org.xhtmlrenderer.pdf.ITextFontResolver.importFontFaces(ITextFontResolver.java:97)
      	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:178)
      	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
      	at com.isomorphic.contentexport.PdfExport.getPdfRenderer(PdfExport.java:335)
      	at com.isomorphic.contentexport.PdfExport.getPdfObject(PdfExport.java:77)
      	at com.isomorphic.rpc.BuiltinRPC.getPdfObject(BuiltinRPC.java:826)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:616)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:972)
      	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:804)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:309)
      	at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
      	at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:231)
      	at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:284)
      	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:168)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:137)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      	at java.lang.Thread.run(Thread.java:679)
      === 2013-12-05 13:10:27,781 [-219] DEBUG RPCManager - Content type for RPC transaction: text/html; charset=UTF-8
      This is how the font is defined in the skin, and this works fine in the app.
      Code:
      @font-face {
         font-family: 'agendamedium';
         src: url('agenda-medium-webfont.eot');
         src: url('agenda-medium-webfont.eot?#iefix') format('embedded-opentype'),
              url('agenda-medium-webfont.woff') format('woff'),
              url('agenda-medium-webfont.ttf') format('truetype'),
              url('agenda-medium-webfont.svg#agendamedium') format('svg');
         font-weight: normal;
         font-style: normal;
      }
      Do we need to change something for the pdfexport to look for the font in the right place?

      Comment


        #4
        Are you using an extra stylesheet to define your font? if so, how are you setting this extra stylesheet in your server.properties file?.
        On the other hand, where is your font file located in your app?.

        Note, if you are using an extra stylesheet, you should have something like this:
        @font-face {
        font-family: 'Arial Unicode MS';
        src: url('fonts/ARIALUNI.TTF');
        }
        The font file should be located in the "fonts" directory under the directory where the extra stylesheet is located.

        Regards
        Isomorphic Software

        Comment


          #5
          No, the font is defined in the original skin_styles.css for the skin we are using.

          As you can see in my previous post, the font is defined similarly to your suggestion.

          The font is placed in the same directory as the css file and as I said before, it works in hosted mode, just not when it is deployed.

          The problem is it adds the string "imagesfile:/usr/share/tomcat7/" in front of the font filename which messes up the path causing a FileNotFoundException, but only when deployed, not in hostedmode.

          Comment


            #6
            It appears the problem is that we make use of the ITTextFontResolver class, and that class doesn't support loading fonts with the .eot extension.

            The solution is probably going to be to convert your font to .otf or .ttf.

            We would actually expect this limitation to be present when running in dev mode, as well as in your final tomcat deployment.

            Regardless, converting the font should resolve this issue

            Regards
            Isomorphic Software

            Comment


              #7
              Okay, so it works if we only have a single ttf file in the font src list, but since IE support for ttf is limited we would like to have the other formats as well. (To ensure cross-browser compatibility) Is it possible to define a different css file to be used only when exporting, or would you suggest another solution to this?

              Comment


                #8
                bump bump bump

                Comment


                  #9
                  If required, it is possible to use an extra stylesheet. To make the extra stylesheet available for this process, follow these steps:
                  1. In server.properties, set:
                  Code:
                  skin.[skinName].extraStyleSheet: path/to/stylesheet/[extraStyleSheet.css]
                  For example:
                  Code:
                  skin.Enterprise.extraStyleSheet: dirSkins/mySkins/myStyleSheet.css
                  The dirSkins/ folder must be placed under webroot.

                  2. When using images within the extra stylesheet, these images must be placed in, for example:
                  - dirSkins/mySkins/images/picture1.png (as in the previous example)

                  Or, when these images are in a different folder other than the extra stylesheet:

                  - myCustomImages/48x48/picture1.png (The myCustomImages/ folder must be placed under webroot)

                  Further information about the PdfExport class, please visit this link

                  Comment


                    #10
                    Thank you that is very helpful, but it is still unclear to me how I would make the pdf export use this extra stylesheet.
                    Do I define it in the settings argument of getPdfRenderer(java.lang.String html, java.util.Map settings) or what?

                    I see in your linked example that the skin name is set like this:
                    Code:
                    Map settings = new HashMap();
                    settings.put("skinName", data.get("skinName").toString());
                    Is it possible to set the style sheet in the same way or should I create a completely new skin to use for pdf export?
                    Last edited by Niels_EMP; 17 Dec 2013, 03:56. Reason: additional question

                    Comment


                      #11
                      According to your sample:
                      Code:
                      DSRequest requestProperties = new DSRequest();
                      requestProperties.setExportFilename(reportTitle.replace(' ', '_'));
                      requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
                      requestProperties.setContentType("application/pdf");
                      requestProperties.setDownloadResult(true);
                      RPCManager.exportContent(contentLayout, requestProperties);
                      you should add a line of code like this:
                      Code:
                      requestProperties.setSkinName("Enterprise");
                      and in your server.properties file you should set something like this:
                      Code:
                      skin.Enterprise.extraStyleSheet: path/to/stylesheet/[extraStyleSheet.css]
                      That's all you need to set.

                      The extra stylesheet could be a new one or one based on another .css file.

                      Please, do not forget to visit this link for further information.

                      Regards
                      Isomorphic Software

                      Comment

                      Working...
                      X