I then pulled Telerik source code and ran. I found that the error is in the Telerik.Windows.Documents.dll file. The error is in Paragraph.cs. The error is at line 409. As you can see by the photo, the Levels only contains one item, yet it's trying to reference Item[1] which would be impossible. Should be Item[0].
I can attach a DOCX file if no one else has this issue.
5 Answers, 1 is accepted
The problem is that the paragraph is associated with a level of the list style that is missing. The question is why this level is missing and if the paragraph should be connected to this level.
We would appreciate it if you could open a support ticket and attach the file in question, so that we can investigate the case. It would also help if you could give us more information on how you created the file.
Looking forward to your reply.
Mihail
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I had the same problem with opening docx file containing custom list style.
Add custom style:
Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles.Add("CustomListStyle", customListStyle);
Using custom style:
customDocList= new Telerik.Windows.Documents.Lists.DocumentList(Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles("CustomListStyle"), doc)
customDocList.Add(paragraph, level)
Export document to Docx
FormatProviders.OpenXml.Docx.DocxFormatProvider docxFormatter;
docxFormatter.Export(doc);
After exporting to docx, then it will have that problem.
Best,
Tuo
The issue you have encountered is related to the way you add custom styles. There is a help article on the subject which will be useful for you. If you follow the approach for registering and applying a custom style outlined there, there must not be any problems with the export.
Mihail
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I Copied the example provided here to test the Custom ListStyle by adding it programmatically.
The way I did is as follows:
ListStyle myListStyle = CustomListStyle.CreateCustomListStyle(); // copy the code from the example to generate ListLevels
ListStyle customListStyle = this.richTextBox.Document.AddCustomListStyle(myListStyle);
The problem is that the ListLevels is empty in the returned "customListStyle", .
Is there any point missed? Thanks.
Best,
Tuo
This is expected behavior. You already have a reference to your list style named "myListStyle" and you can use it if you want to modify the style. If you want to apply the style pragmatically, you should read the section "Applying List Style Programmatically" from the help article you posted in order to understand how you can apply your custom list style to a paragraph.
The logic is rather complex as it has compatibility with older types of list styles provided mainly from MS Word.
I hope this is helpful!
Mihail
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.