Hi
I want to append the content of a .RTF document to a .DOC document file. I also want to preserve the formatting of the RTF content while appending to DOC. But I get the following text in the .DOC file after appending:
<span style=“font-size:10.5pt;font-family:“Courier New”;
mso-fareast-font-family:“Courier New”;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>
Avionics equipment
change
<span style=“font-size:10.5pt;font-family:“Courier New”;
mso-fareast-font-family:“Courier New”;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>
But the Output should be:
Avionics equipment change
Kindly help me with this issue.
Regards
Prabhaker Kr
Hi Prabhaker,
Thanks for your inquiry. First off, please upgrade to latest version of Aspose.Words (15.4.0) from the following link:
Secondly, please refer to the articles mentioned in the following links to achieve this:
In case the problem still remains, please attach related Word documents to be able to reproduce the exact same issue on our end.
Best regards,
Hi Awais,
I upgraded to the latest version Aspose.Words, but no luck. I still face the same issue.
I have attached the RTF file in which I am getting the issue.
Even saving the RTF document to DOC or DOCX format does not help.
Document sourceDoc = new Document(“SampleRTF.rtf”);
sourceDoc.save(“SampleRTF.docx”,ImportFormatMode.KEEP_SOURCE_FORMATTING);
It brings the content of the RTF file with the etc tags.
Kindly check.
Thanks & Regards,
Prabhaker Kr.
Hi Prabhaker,
Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem. For the sake of correction, I have logged this problem in our issue tracking system as
WORDSNET-11916. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.
Best regards,
Hi Awais,
Thank you for logging the issue in your system. Did you find any resolution for the issue ?
I tried other API’s also to copy the content from the RTF file but had no luck.
Regards,
Prabhaker Kr
Hi Prabhaker,
Thanks for your inquiry. Unfortunately, this issue is not resolved yet. This issue is pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.
Best regards,
Hi Prabhaker,
Thanks for being patient. WORDSNET-11916 does not seem to be an issue in Aspose.Words API. Your input document with RTF extension is actually HTML document. Is it essential for you that this file has .RTF extension because once you rename document to .HTML, it will be loaded properly.
Best regards,
Hi Awais,
Yes. I used the following code to resolve the issue:
FileFormatInfo info = FileFormatUtil.detectFileFormat(temporaryDir.getAbsolutePath() + File.separator + filePath);
LoadOptions options = new LoadOptions();
switch (info.getLoadFormat()) {
case LoadFormat.DOC:
LOGGER.debug("\tMicrosoft Word 97-2003 document.");
options.setLoadFormat(LoadFormat.DOC);
break;
case LoadFormat.RTF:
LOGGER.debug("\tRTF format.");
options.setLoadFormat(LoadFormat.RTF);
break;
case LoadFormat.UNKNOWN:
default:
LOGGER.warn("\tFile {} : Unknown format.", filePath);
xmlLogger.warn(“File “+filePath+” : Unknown format.”);
options.setLoadFormat(LoadFormat.HTML);
break;
}
com.aspose.words.Document subDoc = new com.aspose.words.Document(temporaryDir.getAbsolutePath() + File.separator + filePath, options);
Now I get the correct content from RTF file to the DOC file.
Thanks,
Prabhaker
Hi Prabhaker,
Thanks for your inquiry. It is great you were able to find what you were looking for. Please let us know any time you have any further queries.
Best regards,