XamlFormatProvider import fails

2 posts, 0 answers
  1. Richard
    Richard avatar
    1 posts
    Member since:
    Jul 2015

    Posted 18 May Link to this post

    Hi

    Apologies if this thread is in the wrong place, I wasn't sure which sub-category was appropriate.

    Basically I have a client moving from another system and they have thousands of RadDocuments in there database stored in Xaml and I need to be able to convert them to DocX format.

    I thought this would be a simple process but I have hot a wall.

    As a test I created a simple WinForm app with the following code:

    1.var xaml = textBox1.Text;
    2.var xamlProvider = new XamlFormatProvider();
    3.var radDoc = xamlProvider.Import(xaml);

    However, this throws an exception on the third line:

    Cannot create unknown type '{clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents}RadDocument'.

     

    Here is the Xaml I'm trying to import:

    <t:RadDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns:s="clr-namespace:Telerik.Windows.Documents.Model.Styles;assembly=Telerik.Windows.Documents" xmlns:r="clr-namespace:Telerik.Windows.Documents.Model.Revisions;assembly=Telerik.Windows.Documents" xmlns:n="clr-namespace:Telerik.Windows.Documents.Model.Notes;assembly=Telerik.Windows.Documents" xmlns:th="clr-namespace:Telerik.Windows.Documents.Model.Themes;assembly=Telerik.Windows.Documents" version="1.2" LayoutMode="Paged" LineSpacing="1" LineSpacingType="Auto" ParagraphDefaultSpacingAfter="0" ParagraphDefaultSpacingBefore="0" SelectedBibliographicStyleName="\APA.XSL" StyleName="defaultDocumentStyle">
      <t:RadDocument.Captions>
        <t:CaptionDefinition IsDefault="True" IsLinkedToHeading="False" Label="Figure" LinkedHeadingLevel="0" NumberingFormat="Arabic" SeparatorType="Hyphen" />
        <t:CaptionDefinition IsDefault="True" IsLinkedToHeading="False" Label="Table" LinkedHeadingLevel="0" NumberingFormat="Arabic" SeparatorType="Hyphen" />
      </t:RadDocument.Captions>
      <t:RadDocument.ProtectionSettings>
        <t:DocumentProtectionSettings EnableDocumentProtection="False" Enforce="False" HashingAlgorithm="None" HashingSpinCount="0" ProtectionMode="ReadOnly" />
      </t:RadDocument.ProtectionSettings>
      <t:RadDocument.Styles>
        <s:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="False" IsPrimary="True" Name="defaultDocumentStyle" Type="Default">
          <s:StyleDefinition.ParagraphStyle>
            <s:ParagraphProperties LineSpacing="1" SpacingAfter="0" />
          </s:StyleDefinition.ParagraphStyle>
          <s:StyleDefinition.SpanStyle>
            <s:SpanProperties FontFamily="Verdana" FontSize="16" FontStyle="Normal" FontWeight="Normal" />
          </s:StyleDefinition.SpanStyle>
        </s:StyleDefinition>
        <s:StyleDefinition DisplayName="Normal" IsCustom="False" IsDefault="True" IsPrimary="True" Name="Normal" Type="Paragraph" />
        <s:StyleDefinition DisplayName="TableNormal" IsCustom="False" IsDefault="True" IsPrimary="True" Name="TableNormal" Type="Table">
          <s:StyleDefinition.TableStyle>
            <s:TableProperties CellPadding="5,0,5,0">
              <s:TableProperties.TableLook>
                <t:TableLook />
              </s:TableProperties.TableLook>
            </s:TableProperties>
          </s:StyleDefinition.TableStyle>
        </s:StyleDefinition>
      </t:RadDocument.Styles>
      <t:Section>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:FieldRangeStart AnnotationID="1">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="Provider" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" Text="Aviva Life" />
          <t:FieldRangeEnd AnnotationID="1" />
          <t:Span FontFamily="Arial" FontSize="16" Text=" & Pensions" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" Text="One Park Place" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" Text="Hatch Street" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" Text="Dublin 2" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0" TextAlignment="Right">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:FieldRangeStart AnnotationID="2">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="Date" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" ForeColor="#FF000000" Text="24 April 2014" />
          <t:FieldRangeEnd AnnotationID="2" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text="Re : " />
          <t:FieldRangeStart AnnotationID="3">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="Provider" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text="Aviva Life" />
          <t:FieldRangeEnd AnnotationID="3" />
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text=" " />
          <t:FieldRangeStart AnnotationID="4">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="ProductType" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text="ARF" />
          <t:FieldRangeEnd AnnotationID="4" />
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text=" " />
          <t:FieldRangeStart AnnotationID="5">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="PolicyNumber" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text="91445684" />
          <t:FieldRangeEnd AnnotationID="5" />
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Italic" FontWeight="Bold" ForeColor="#FF000000" Text=" " />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" Text="I wish to take a one off withdrawal of €10,000 NET from the above policy." />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" Text="Please forward payment at your earliest convenience." />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" ForeColor="#FF000000" Text="I trust you will find the above in order but please contact me should you have any queries." />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" ForeColor="#FF000000" Text="Kind regards" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="16">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:Span FontFamily="Arial" FontSize="16" ForeColor="#FF000000" Text="_________________________________" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:FieldRangeStart AnnotationID="6">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="ClientName" />
          </t:FieldRangeStart>
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Normal" FontWeight="Bold" ForeColor="#FF000000" Text="Mr Barry Donnellan" />
          <t:FieldRangeEnd AnnotationID="6" />
          <t:Span FontFamily="Arial" FontSize="16" FontStyle="Normal" FontWeight="Bold" ForeColor="#FF000000" Text=" " />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="2" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
          <t:FieldRangeStart AnnotationID="7">
            <t:MergeField DateTimeFormatting="" DisplayMode="Result" GeneralFormatting="" NumericFormatting="" PropertyPath="ConsultantTitle" />
          </t:FieldRangeStart>
          <t:FieldRangeEnd AnnotationID="7" />
        </t:Paragraph>
        <t:Paragraph FontSize="16" LeftIndent="0" LineSpacing="1" LineSpacingType="Auto" SpacingAfter="0">
          <t:Paragraph.ParagraphSymbolPropertiesStyle>
            <s:SpanProperties FontFamily="Arial" FontSize="16" />
          </t:Paragraph.ParagraphSymbolPropertiesStyle>
        </t:Paragraph>
        <t:Paragraph />
      </t:Section>
    </t:RadDocument>

    Appreciate any help you can give me to get this working.

    Thanks.

     

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 19 May Link to this post

    Hello Richard,

    Thank you for contacting us.

    The document was created with the RichTextBox from our WPF suite. Xaml documents created with this control are not usable with the RadRichtextEditor for WinForms. So in this case, you will need to create a WPF application and convert the files with it. 

    The file cannot be imported because of the "&" character in the following line:
    <t:Span FontFamily="Arial" FontSize="16" Text=" & Pensions" />

    In order, this to work you should remove this character or escape it: SecurityElement.Escape Method (String) (System.Security)

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top