pmartha
pmartha

Reputation: 87

.rtf file data is not rendering in a Jasper report

I created a .rtf file with below content with border.

cell 1  lots of text in cell two    cell 3

When I exported rtf file into jasper report using Markup as rtf, I got only text (below data)

cell 1lots of text in cell twocell 3

I am using TIBCO Jaspersoft Studio-6.1.1.final version jasper.

Below I am adding JRXML file.

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1  -->
<!-- 2015-11-16T12:10:05 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Test_RTF" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e4e612e9-7787-4540-a6b9-b2d362a29f32">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
    <queryString>
        <![CDATA[select '{\rtf1\ansi\deff0
\trowd
\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs
\cellx1000
\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs
\cellx2000
\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs
\cellx3000
cell 1\intbl\cell
lots of text in cell two\intbl\cell
cell 3\intbl\cell
\row
}' rtf_simple from dual]]>
    </queryString>
    <field name="RTF_SIMPLE" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="125" splitType="Stretch">
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="110" y="30" width="410" height="30" uuid="43e8a2fb-5db5-4290-8db7-51c93c330f22"/>
                <textElement markup="rtf"/>
                <textFieldExpression><![CDATA[$F{RTF_SIMPLE}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

Here I added rtf text code into select statement using dual. If I am adding same text into rtf file.

I am getting text with border, but when I am adding it into jasper report I am getting text only.

[update]

This is a simplified use-case. Our actual requirement is , we have .rtf documents stored in DB as blob. We want to insert content of these documents in between our big report. these rtf files contain Text, tables and images. When I am trying to read this rtf file, then only text is coming. Can someone please suggest any other alternative to achieve this?

Upvotes: 1

Views: 1307

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

I have a feeling that it is similar to markup="html" you should not expect jasper report to be able to format tables, images eccecc

<span style='border:5px solid red;color:red'>Test</span>

with markup="html" will only display a red text "Test", hence no red border

The textfield displays text (formatted text) so the markup (html and rtf) is for formatting the text (bold, italic, font, size,color) ecc.

Unfortunately, you need the box command to add border to your field es.

<box topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0">
  <topPen lineWidth="0.25"/>
  <leftPen lineWidth="0.25"/>
  <bottomPen lineWidth="0.25"/>
  <rightPen lineWidth="0.25"/>
</box>

Upvotes: 1

Related Questions