We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Loading RTF-file

I want to convert a RTF file to PDF, via following code:

string strFileName = @"C:\_Recotest2\test.rtf";

LoadOptions loadoptions = new LoadOptions();

loadoptions.LoadFormat = LoadFomat.Rtf;

Document doc = new Document(strFileName,loadoptions);

When I run ths code I get following exception:

Aspose.Words.UnsupportedFileFormatException: Unknown file format.

I have the test.rtf-file attached.

What is wrong here?

Hi
Philip,


Thanks for your inquiry.

I have found that the input document you provided here is not in RTF format instead it is a simple TXT file. Currently, Aspose.Words supports saving documents as plain text files, but does not directly support loading them. However, it is easy to write your own code to load plain text files into Aspose.Words. Please use the code suggested in the following article to load text files:
http://docs.aspose.com/display/wordsnet/How+to++Load+Plain+Text+%28TXT%29+Files

Please let me know if I can be of any further assistance.

Best Regards,