Style formatting gets lost when working with the Clipboard

Hi

When I create an Aspose.Words document with styles, everything works perfectly when saving the document as docx, doc, rtf, and so on. However, when I copy the same rtf to the clipboard and paste it into Word, there is a problem: although my custom styles are defined correctly, all text is formatted as “Normal”. Is this a problem of the rtf generated by Aspose.Words or is it a bug in MS Word?

Thanks for your help,
Thomas

Hi Thomas,

Thanks for your inquiry. Do you copy/paste your RTF document through the code or just using MS Word? Could you please attach sample documents (before and after processing using Aspose.Words) here for testing? Also, please provide me step by step instructions, which will help me to reproduce the problem on my side. I will check the issue and provide you more information.
Best regards,

Hi Alexey

I have produced the attached RTF with Aspose.Words. When I open it from Word 2007, styles are assigned correctly (see picture RTFStyles.png). When I paste the same RTF via the Clipboard in a blank Word File, the style “JournalFullName” is defined, but not applied to the appropriate paragraphs (see picture ClipboardStyles.png).

I have tested it with the following trivial code:

using(var streamReader = new System.IO.StreamReader(@""))
{
    string test = streamReader.ReadToEnd();
    Clipboard.SetText(test, TextDataFormat.Rtf);
}

Well, it the meantime, I have continued digging for the reasons of this behaviour. I have found that Word does behave the same way if I save an RTF file directly from Word and copy it to the clipboard with the above code. My conclusion is therefore that this is a Word bug, not an Aspose.Words problem. Sorry for bothering you.

Not your problem exactly, but just for my information: Do you have an idea how I could work around this bug? I have tried to put docx code to the clipboard, but this doesn’t seem to work.

Best regards,
Thomas

Hi

Thank you for additional information. Yes, you are right it is not a bug in Aspose.Words. However, I think, it is also not a bug in MS Word or in Oo Writer. I think, it is something wrong with Clipboard class.
Unfortunately, I have no ideas how to work around this problem. Please let us know if you find a workaround.
Best regards.