Issue) Rtf text having background color is not converted properly to Html / Pdf file. Its coming just as simple text without background color.
Below is the sample rtf text and its related image for reference.
Rtf text:
{\rtf1\ansi\deff0\uc1\ansicpg1252\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset1 Tahoma;}{\f2\fnil\fcharset1 Calibri;}{\f3\fnil\fcharset2 WingDings;}{\f4\fnil\fcharset2 Symbol;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red128\green128\blue0;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\pgbrdrhead\pgbrdrfoot\pgbrdropt32\endnhere\sectdefaultcl{\*\generator WPTools_7.000;}{\stylesheet
{\s1\li0\fi0\ri0\sb0\sa160\sl259\slmult1\ql\vertalt\f2\fs22\cf15 Normal;}
{\s2\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs22 Default Paragraph Font;}}
{\sl250\slmult1\plain\f2\fs22\cf0\cb1 Text with red background\par
\pard\plain\sl250\slmult1\plain\f0\fs22\par
}}
Sample Image:
1_RtfImageTextWithRedBackground.jpg (24.8 KB)
Sample java code used for reference:
Added following dependency and repository in pom.xml
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>20.3</version>
<classifier>jdk17</classifier>
</dependency>
........
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
============= Java code with input and output option ============
public static void main(String[] args) throws Exception {
License license = new License();
license.setLicense("C:\\Users\\pprajapati\\Desktop\\9122\\Aspose.Words.lic");
// with options
RtfLoadOptions rtfOptions = new RtfLoadOptions();
rtfOptions.setRecognizeUtf8Text(true);
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.setCompliance(PdfCompliance.PDF_17);
HtmlSaveOptions htmlOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlOptions.setPrettyFormat(true);
htmlOptions.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
Document doc = new Document("C:\\Users\\pprajapati\\Desktop\\9122\\program\\2_RedBackgroundDB.rtf", rtfOptions);
doc.save("C:\\Users\\pprajapati\\Desktop\\9122\\program\\outputAspose.pdf", pdfOptions);
doc.save("C:\\Users\\pprajapati\\Desktop\\9122\\program\\outputAspose.html", htmlOptions);
System.out.println("done");
}