Free Support Forum - aspose.com

Untrusted rtf after converting from html in .NET C#

Hello,

i am using Aspose.Words (version 19.6.0.0) to convert html to rtf. After doing so i get the following message when opening the created rtf file in WordPad:
image.png (9.5 KB)
Only after clicking “Unblock” i get to see the full rtf. When clicking “Ok” the image is missing

I attached the original html file and the created rtf.Aspose Test.zip (1.8 KB)

Here is the code i use to convert the html:

var retStream = File.Open(rtfFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
var contentStream = new FileStream(htmlFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var laodOptions = new AsposeWords.LoadOptions(AsposeWords.LoadFormat.Html, null, null);
var doc = new AsposeWords.Document(contentStream, laodOptions);
var saveOpts = new AsposeWords.Saving.RtfSaveOptions();
saveOpts.ExportCompactSize = true;
saveOpts.ExportImagesForOldReaders = false;
doc.Save(retStream, saveOpts);
retStream.Close();

The message alone wouldn’t be much of a problem but i have an rtf-control in my application, which does not display the message and just shows the created rtf without images.

Regards,
Max

@MaxL

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19419. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

I just checked the issue status on my problem and it says “closed”. Does that mean my problem is solved? And if it does: Where do i get the fix?

Regards,
Max

@MaxL

We have good news for you i.e. WORDSNET-19419 has now been resolved. The fix of this issue will be included in the next version of Aspose.Words i.e. 19.12. We will inform you via this forum thread as soon as next version of Aspose.Words is available. Hopefully, it will be available by the end of this week.

So, starting from the next version “19.12”, please use RtfSaveOptions as shown below to get the desired output.

Document doc = new Document(@"source.docx");
 
RtfSaveOptions saveOpts = new RtfSaveOptions();
saveOpts.SaveImagesAsWmf = true;
 
doc.Save("output.rtf", saveOpts);

Thats great! Thanks for fixing and answering so fast.