Fop
  1. Fop
  2. FOP-1184

NullpointerException in RTFHandler

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 0.92
    • Fix Version/s: None
    • Component/s: rtf
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: Other
    • External issue ID:
      39553

      Description

      The RTFHandler crashes with a Nullpointer exception while processing following
      XSL-FO document. The same Code works for PDF very well.

      Stacktrace:
      ----------------
      java.lang.NullPointerException
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1588)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1625)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1625)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1625)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1625)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1625)
      at org.apache.fop.render.rtf.RTFHandler.recurseFONode(RTFHandler.java:1583)
      at org.apache.fop.render.rtf.RTFHandler.endPageSequence(RTFHandler.java:233)
      at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:147)
      at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:358)
      at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:193)

      Code bit
      -----------------------
      ....
      FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
      out = new FileOutputStream(pdf);
      out = new BufferedOutputStream(out);
      Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent,
      out);
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transformer = factory.newTransformer();
      Source src = new StreamSource(fo);
      Result res = new SAXResult(fop.getDefaultHandler());
      transformer.transform(src, res);
      ...

      XSL-FO
      ----------

      <?xml version="1.0" encoding="UTF-8"?>
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
      xmlns:fox="http://xml.apache.org/fop/extensions">
      <fo:layout-master-set>
      <fo:page-sequence-master master-name="chapter-master">
      <fo:repeatable-page-master-alternatives>
      <fo:conditional-page-master-reference master-reference="common-page"
      odd-or-even="odd" page-position="first"/>
      <fo:conditional-page-master-reference master-reference="common-page"
      odd-or-even="even" page-position="first"/>
      <fo:conditional-page-master-reference master-reference="common-page"
      odd-or-even="odd" page-position="rest"/>
      <fo:conditional-page-master-reference master-reference="common-page"
      odd-or-even="even" page-position="rest"/>
      </fo:repeatable-page-master-alternatives>
      </fo:page-sequence-master>
      <fo:simple-page-master page-width="21cm" page-height="29.7cm" margin-top="0cm"
      margin-bottom="0cm" margin-left="0cm" margin-right="0cm" master-name="cover">
      <fo:region-body margin-top="72pt"/>
      <fo:region-before extent="15cm"/>
      <fo:region-after extent="24pt"/>
      <fo:region-end extent="10cm"/>
      </fo:simple-page-master>
      <fo:simple-page-master page-width="51pc" page-height="66pc" margin-top="3pc"
      margin-bottom="3pc" margin-left="6pc" margin-right="6pc" master-name="common-page">
      <fo:region-body margin-top="12pt" margin-bottom="36pt"/>
      <fo:region-before extent="12pt"/>
      <fo:region-after extent="24pt"/>
      </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:bookmark-tree>
      <fo:bookmark internal-destination="N20006">
      <fo:bookmark-title>Total Traffic per Message Type</fo:bookmark-title>
      </fo:bookmark>
      </fo:bookmark-tree>
      <fo:page-sequence master-reference="cover">
      <fo:static-content flow-name="xsl-region-before">
      <fo:block margin-left="2cm" margin-top="1cm" text-align="left">
      <fo:external-graphic content-width="70%"
      src="file:///E:/workspace/XSL_FOP_Test/reports/topics/img/logo2.png"/>
      </fo:block>
      </fo:static-content>
      <fo:static-content flow-name="xsl-region-after">
      <fo:block line-height="normal" font-weight="bold" font-size="11pt"
      margin-top="1cm">
      © Copyright company</fo:block>
      </fo:static-content>
      <fo:static-content flow-name="xsl-region-end">
      <fo:block text-align="left" margin-left="1cm">
      <fo:external-graphic content-width="100%"
      src="file:///E:/workspace/XSL_FOP_Test/reports/topics/img/background.png"/>
      </fo:block>
      </fo:static-content>
      <fo:flow flow-name="xsl-region-body">
      <fo:block font-family="Helvetica" text-align="left">
      <fo:block line-height="140%" font-weight="bold" font-size="30pt"/>
      <fo:block margin-bottom="1in" line-height="140%" font-weight="bold"
      font-size="24pt"/>
      </fo:block>
      <fo:block padding="6pt" font-family="Helvetica" margin-top="10px">
      <fo:block text-align="center" margin-right="10cm" margin-bottom="10px"
      margin-top="10px" line-height="100%" font-size="16pt">
      <fo:block>
      <fo:external-graphic content-width="40%"
      src="file:///E:/workspace/XSL_FOP_Test/reports/topics/img/logo.PNG"/>
      </fo:block>
      <fo:block font-size="18pt">SMS Inspector</fo:block>
      <fo:block>Report</fo:block>
      </fo:block>
      </fo:block>
      </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="cover">
      <fo:flow flow-name="xsl-region-body">
      <fo:block font-size="10pt" text-indent="0em" space-before="0.6em"
      space-after="0.6em" text-align="center" color="purple"/>
      </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence initial-page-number="1" format="i" master-reference="common-page">
      <fo:static-content flow-name="xsl-region-before">
      <fo:block line-height="8pt" font-size="8pt">Total Traffic per Message
      Type</fo:block>
      </fo:static-content>
      <fo:static-content flow-name="xsl-region-after">
      <fo:block font-family="Helvetica" font-weight="bold" font-size="10pt"
      text-align="center">
      <fo:page-number/>
      </fo:block>
      </fo:static-content>
      <fo:flow flow-name="xsl-region-body">
      <fo:block id="page1-1" font-family="Helvetica" font-size="10pt" line-height="12pt">
      <fo:block font-family="Helvetica" text-align="left">
      <fo:block>
      <fo:leader leader-length="2in" rule-thickness="3pt" leader-pattern="rule"
      color="black"/>
      </fo:block>
      <fo:block line-height="140%" font-weight="bold" font-size="20pt">
      Contents </fo:block>
      </fo:block>
      </fo:block>
      </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="chapter-master">
      <fo:static-content flow-name="xsl-region-before">
      <fo:block line-height="8pt" font-size="8pt">Total Traffic per Message
      Type</fo:block>
      </fo:static-content>
      <fo:static-content flow-name="xsl-region-after">
      <fo:block font-family="Helvetica" font-weight="bold" font-size="10pt"
      text-align="center">
      <fo:page-number/>
      </fo:block>
      </fo:static-content>
      <fo:flow flow-name="xsl-region-body">
      <fo:block break-before="page" font-family="Helvetica" font-size="10pt"
      text-align="left">
      <fo:block>
      <fo:block break-before="page" margin-top="0pc" margin-bottom="1.4pc"
      font-size="16pt" font-weight="bold" padding-top="1.4pc" id="N10011">
      <fo:block border-right-width="0pt" border-left-width="0pt" line-height="100%"
      border-top-width="3pt" border-top-color="black">
      <fo:block id="N20006"/>Total Traffic per Message Type</fo:block>
      </fo:block>
      <fo:block start-indent="72pt" font-size="10pt">
      <fo:block>
      <fo:table table-layout="fixed" width="100%" space-before="12pt"
      space-after="10pt" background-color="white" border-style="solid"
      border-width="1pt" border-color="black">
      <fo:table-header>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="1">
      <fo:block>Report 1</fo:block>
      </fo:table-cell>
      </fo:table-row>
      </fo:table-header>
      <fo:table-body>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#faf4fa" start-indent="2pt" column-number="1">
      <fo:block>
      Total Traffic over the report period.
      </fo:block>
      </fo:table-cell>
      </fo:table-row>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#faf4fa" start-indent="2pt" column-number="1">
      <fo:block>
      <fo:block font-size="10pt" text-indent="0em" space-before="0.6em"
      space-after="0.6em">
      <fo:external-graphic
      src="url(file:///E:\workspace\GenericJobScheduler\log\img\0hour_linechart.png)"
      content-width="scale-to-fit" width="100%"/>
      </fo:block>
      </fo:block>
      </fo:table-cell>
      </fo:table-row>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#faf4fa" start-indent="2pt" column-number="1">
      <fo:block>
      <fo:block font-size="10pt" text-indent="0em" space-before="0em" space-after="0.6em">
      Some Text
      <fo:block space-before="12pt">
      <fo:table table-layout="fixed" width="100%" space-before="10pt"
      space-after="10pt" background-color="white" border-style="solid"
      border-width="1pt" border-color="black">
      <fo:table-column/>
      <fo:table-column/>
      <fo:table-column/>
      <fo:table-column/>
      <fo:table-column/>
      <fo:table-column/>
      <fo:table-body>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="1">
      <fo:block font-size="10pt">messageType</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="2">
      <fo:block font-size="10pt">year</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="3">
      <fo:block font-size="10pt">month</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="4">
      <fo:block font-size="10pt">day</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="5">
      <fo:block font-size="10pt">hour</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      font-weight="bold" text-align="center" padding="2pt" background-color="silver"
      start-indent="2pt" column-number="6">
      <fo:block font-size="10pt">sumTotal</fo:block>
      </fo:table-cell>
      </fo:table-row>
      <fo:table-row>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="1">
      <fo:block font-size="9pt">SRISM</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="2">
      <fo:block font-size="9pt">2006</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="3">
      <fo:block font-size="9pt">2</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="4">
      <fo:block font-size="9pt">24</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="5">
      <fo:block font-size="9pt">12</fo:block>
      </fo:table-cell>
      <fo:table-cell border-style="solid" border-width="1pt" border-color="black"
      padding="2pt" background-color="#fafafa" start-indent="2pt" column-number="6">
      <fo:block font-size="9pt">10698</fo:block>
      </fo:table-cell>
      </fo:table-row>
      </fo:table-body>
      </fo:table>
      </fo:block>
      </fo:block>
      </fo:block>
      </fo:table-cell>
      </fo:table-row>
      </fo:table-body>
      </fo:table>
      </fo:block>
      </fo:block>
      </fo:block>
      </fo:block>
      </fo:flow>
      </fo:page-sequence>
      </fo:root>

        Activity

        Hide
        Jeremias Maerki added a comment -

        The NPE was ugly. I changed the whole thing so you at least get a file. Please
        note that the RTF output does not support an implicit column setup. Please
        explicitely define the table-column elements when you want to generate RTF output.

        http://svn.apache.org/viewvc?rev=407576&view=rev

        Show
        Jeremias Maerki added a comment - The NPE was ugly. I changed the whole thing so you at least get a file. Please note that the RTF output does not support an implicit column setup. Please explicitely define the table-column elements when you want to generate RTF output. http://svn.apache.org/viewvc?rev=407576&view=rev
        Hide
        Glenn Adams added a comment -

        batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

        Show
        Glenn Adams added a comment - batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

          People

          • Assignee:
            fop-dev
            Reporter:
            Marco
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development