Error importing RTF

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Mar 2016

    Posted 28 Sep Link to this post

    Hello, I am not sure whether to post this in the RichTextEditor forum or the Telerik Document Processing forum as this problem exists in both import/export methods.

    This is the code that triggers the error:

    using Telerik.WinForms.Documents.FormatProviders.Rtf;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                var rtf = @"{\rtf1\ansicpg1252{\fonttbl{\f0Arial ;}{\f1Tahoma ;}}{\colortbl;\red0\green0\blue0;}\sectd{\*\footer}{\*\header}\paperw12240\paperh15839\margl1439\margr1439\margt1439\margb1439\pgbrdropt40\pgbrdrt\pgbrdrb\pgbrdrl\pgbrdrr{{\trowd\trautofit\irow0\lastrow\clnowrap\cellx9360{\ql{\pard{\trowd\trautofit\trkeep\irow0\intbl\itap2{\ql{\pard{\trowd\trrh-1727\trkeep\irow0\lastrow\intbl\itap3{\ql{\plain\f0\fs20\cf1 Aaron Fitz Electrical, your invoice(s) are past due. The total remaining amount is $29120.06.}\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-1727\trkeep\irow0\lastrow\clpadt39\clpadft3\clpadr39\clpadfr3\cellx9360\nestrow}{\nonesttables\par}}\trowd\trautofit\trkeep\irow0\clnowrap\cellx9360}\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trautofit\trkeep\irow0\clnowrap\cellx9360\nestrow}{\nonesttables\par}}{\trowd\trautofit\trkeep\irow1\intbl\itap2{\ql{\pard{\trowd\trrh-1188\irow0\intbl\itap3{\ql{\pard{\trowd\trrh-724\trkeep\irow0\intbl\itap4{\ql{\plain\f1\fs20\cf1 Invoice Num}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Transaction Description}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Purchase Order Num}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Amount}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Doc Date}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Due Date}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs20\cf1 Total Amount Due}\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-724\trkeep\irow0\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx1151\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx2303\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx3455\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx4607\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx5759\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx6911\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\clvertalc\cellx8063\nestrow}{\nonesttables\par}}{\trowd\trrh-434\trkeep\irow1\lastrow\intbl\itap4{\ql{\plain\f1\fs18\cf1 SVC1000              }\nestcell{\nonesttables\par}}{\ql\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs18\cf1                      }\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs18\cf1 4322.98000000}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs18\cf1 6/12/2013 12:00:00 AM}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs18\cf1 7/12/2013 12:00:00 AM}\nestcell{\nonesttables\par}}{\ql{\plain\f1\fs18\cf1 468.70000000}\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-434\trkeep\irow1\lastrow\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx1151\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx2303\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx3455\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx4607\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx5759\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx6911\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clpadt39\clpadft3\clpadr39\clpadfr3\cellx8063\nestrow}{\nonesttables\par}}\trowd\trrh-1188\irow0\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clnowrap\cellx8093\clnowrap\cellx9360}\nestcell{\nonesttables\par}}{\ql\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-1188\irow0\clbrdrt\brdrs\brdrw14\brdrcf1\clbrdrb\brdrs\brdrw14\brdrcf1\clbrdrl\brdrs\brdrw14\brdrcf1\clbrdrr\brdrs\brdrw14\brdrcf1\clnowrap\cellx8093\clnowrap\cellx9360\nestrow}{\nonesttables\par}}{\trowd\trrh-1691\irow1\lastrow\intbl\itap3{\ql\nestcell{\nonesttables\par}}{\ql\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-1691\irow1\lastrow\clnowrap\cellx8093\clnowrap\cellx9360\nestrow}{\nonesttables\par}}\trowd\trautofit\trkeep\irow1\clnowrap\cellx9360}\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trautofit\trkeep\irow1\clnowrap\cellx9360\nestrow}{\nonesttables\par}}{\trowd\trrh-1440\trkeep\irow2\lastrow\intbl\itap2{\ql\nestcell{\nonesttables\par}}{\*\nesttableprops\trowd\trrh-1440\trkeep\irow2\lastrow\clnowrap\cellx9360\nestrow}{\nonesttables\par}}\trowd\trautofit\irow0\lastrow\clnowrap\cellx9360}\cell}\row}}\sect}";
                var inProvider = new RtfFormatProvider();
                var document = inProvider.Import(rtf);
            }
        }
    }

     

    I get a NullReferenceException

       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfImportContext.FlushTableRowsIntoTable(List`1 rowStackItems)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfImportContext.FlushStructureStack()
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfImportContext.HandleSectionEnd()
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfHandlers.RtfTagHandlers.SectionEndHandler(RtfTag tag, RtfImportContext context)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfDocumentImporter.DoVisitTag(RtfTag tag)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfElementIteratorBase.VisitElement(RtfElement element, Boolean recursive)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfElementIteratorBase.VisitGroupChildren(RtfGroup group, Boolean recursive)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfDocumentImporter.ImportRoot(RtfGroup rtfGroup)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.Import.RtfDocumentImporter.Import(Stream input, RtfImportSettings settings)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider.Import(Stream input)
       at Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider.Import(String input)
       at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Daniel Flaws\Desktop\temp\ConsoleApplication1\Program.cs:line 10

    I am pretty sure that this RTF is well-formatted; it opens correctly in Microsoft Word, and it came directly from an export of a Telerik Report.

    Is there anything I can do to fix this?

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 29 Sep Link to this post

    Hi Daniel,

    It appears that this is a known issue wich is already logged in our Feedback Portal. I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comment to it here.

    Unfortunately due to the nature of the issue I cannot provide you with a workaround for it. 

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top