Error during conversion - NotSupportedException "Preserved token with type 'NumberToken'

When we render a document to PDF with Viewer.View(PdfViewOptions, CancellationToken), GroupDocs.Viewer throws a System.NotSupportedException from its internal CSS parser. The problem looks like an inline style that Word generates for numbered lists: list-style-type gets a string value ("2) ").

Exception

System.NotSupportedException (HResult -2146233067)
Source: GroupDocs.Viewer
Message: Internal error - Preserved token with type 'NumberToken' and content '2' is not permitted
in declaration block. Overall content of input Simple block is
'color:black;mso-list:l3 level1 lfo3;list-style-type:"2) "'.

Stack trace (GroupDocs.Viewer frames, obfuscated as logged)

at \b\u0017\u001b.\u0002(\u0003\u0017\u001b \u0002, Boolean \b, \u000e\u0019\u0005 \u0005)
at \u0003\u0015\u0015.\u0002(List`1 \u0002, String \b, Int32 \u0005, Int32 \u0006, Boolean \u0003, Boolean \u000e, \u000e\u0019\u0005 \u000f)
at \u0003\u0015\u0015.\u0002(String \u0002, Int32 \b, Boolean \u0005, \u000e\u0019\u0005 \u0006)
at \b\u0016\u0015.\u0002(String \u0002, Int32 \b, \u0002 \u0005, \u000e\u0019\u0005 \u0006)
at \u000e\u0015\u0015.\u0002(String \u0002, IEnumerable`1 \b, \u000e\u0019\u0005 \u0005)
at \u000e\u001b\u0016\u0016.\u0002(BaseViewOptions \u0002)
at \u000e\u001b\u0016\u0016.\b(BaseViewOptions \u0002)
at \u000e\u001b\u0016\u0016.\u0002\u0003\u0019\u0003\u0016\u0002(BaseViewOptions \u0002)
at \b\u0003\u0019.\u0002\u0003\u0019\u0003\u0016\u0002(String \u0002, Stream \b, LoadOptions \u0005, BaseViewOptions \u0006, CancellationToken \u0003)
at GroupDocs.Viewer.Viewer.\u0002(LoadOptions \u0002, BaseViewOptions \b, CancellationToken \u0005)
at GroupDocs.Viewer.Viewer.\u0002(BaseViewOptions \u0002, CancellationToken \b)
at \u0006\u0010\u001b\u0016.\b\u0010\u001b\u0016\u0003\u0016\u0002(Func`3 \u0002, ViewOptions \b, CancellationToken \u0005)
at GroupDocs.Viewer.Viewer.View(ViewOptions options, CancellationToken cancellationToken)

Analysis

  • list-style-type: "2) " is valid CSS: CSS Lists Level 3 lets list-style-type take a <string> value, and MS Word writes it when a list uses the “2)” numbering format.
  • The block shown in the exception still has &quot; HTML entities. We think the style attribute isn’t HTML-decoded before it reaches the CSS tokenizer. That leaves &quot;2) &quot; as raw text, so 2 gets tokenized as a NumberToken instead of part of a string.
  • The parser throws on this one declaration and the whole document fails to render. We would expect it to skip or ignore a declaration it can’t handle.
1 Like

@AroXX

Hi Arek,

Can you please share a problematic Word file so we can reproduce this exceotion?

If this file has sensitive info, you can send it to us via email address developers@groupdocs.com

Thanks and waiting for your reply.

With best regards,
Denis Gvardionov