Is there a full StyleSheet example? Including default ListStyle, Paragraph style

3 posts, 0 answers
  1. Art
    Art avatar
    33 posts
    Member since:
    Apr 2015

    Posted 19 Mar 2018 Link to this post

    Paragraphs within list items has different font settings than defined in the StyleSheet:

    <d:StyleDefinition DisplayName="Document Default Style" IsCustom="False" IsDefault="True" IsPrimary="True" Name="defaultDocumentStyle" Type="Default">
        <d:StyleDefinition.ParagraphStyle>
            <d:ParagraphProperties FirstLineIndent="0" LeftIndent="0" LineSpacing="1.15" LineSpacingType="AtLeast" RightIndent="0" SpacingAfter="0" SpacingBefore="0" TextAlignment="Justify" />
        </d:StyleDefinition.ParagraphStyle>
        <d:StyleDefinition.SpanStyle>
            <d:SpanProperties FlowDirection="LeftToRight" FontFamily="Times New Roman" FontSize="14.6666669845581" ForeColor="#FF000000" ThemeFontFamily="minor" />
        </d:StyleDefinition.SpanStyle>
    </d:StyleDefinition>

     

    When I trying to export document with HtmlFormatProvider, it sets properties for paragraph inside <li> as:

    p { margin-bottom: 12px;line-height: 1.15; } 
    body { font-family: 'Verdana';font-size: 16px; } 

    .p_23A62C69 { telerik-style-type: local;margin-right: 0px;margin-left: 24px;text-indent: 0px;font-family: 'Verdana';font-size: 16px;color: #000000; } 
    .li_796E334F { telerik-style-type: local;margin-left: 24px;text-indent: 0px;font-family: 'Lucida Sans Unicode';font-size: 14.6666669845581px;color: #000000; } 

    And it different from desired 11pt "Times New Roman". How to set it by default for entire StyleSheet? With all margins as 0 for Paragraph.

    Maybe you have an example of correct StyleSheet? Existing demo isn't helpfull. I use manual StyleSheet definition, which applies by default to all RadRichTextBoxes in my application...

  2. Art
    Art avatar
    33 posts
    Member since:
    Apr 2015

    Posted 19 Mar 2018 in reply to Art Link to this post

    public class StyledHtmlDataProvider : HtmlDataProvider
    {
        public StyledHtmlDataProvider()
        {
            FormatProvider = RichTextManager.GetHtmlFormatProvider();
            SetupDocument += OnSetupDocument;
        }
     
        public Padding PageMargin
        {
            get { return (Padding)GetValue(PageMarginProperty); }
            set { SetValue(PageMarginProperty, value); }
        }
     
        public static readonly DependencyProperty PageMarginProperty =
            DependencyProperty.Register("PageMargin", typeof(Padding), typeof(StyledHtmlDataProvider), new PropertyMetadata(new Padding(10, 15, 10, 15)));
     
        private void OnSetupDocument(object sender, SetupDocumentEventArgs e)
        {
            e.Document.SectionDefaultPageSize = PaperTypeConverter.ToSize(PaperTypes.A4);
            e.Document.SectionDefaultPageMargin = PageMargin;
     
            e.Document.LineSpacing = 1.15;
            e.Document.LineSpacingType = LineSpacingType.AtLeast;
            e.Document.ParagraphDefaultSpacingAfter = 0;
     
            var stream = Application.GetResourceStream(GetResourceUri("DocumentStyles/GenericDocumentStyles.xaml")).Stream;
            var stylesheet = XamlFormatProvider.LoadStylesheet(stream);
     
            stylesheet.ApplyStylesheetToDocument(e.Document);
        }
     
        private static Uri GetResourceUri(string resource)
        {
            var assemblyName = new AssemblyName(typeof(StyledHtmlDataProvider).Assembly.FullName);
            var resourcePath = "/" + assemblyName.Name + ";component/" + resource;
            var resourceUri = new Uri(resourcePath, UriKind.Relative);
     
            return resourceUri;
        }
    }
  3. Art
    Art avatar
    33 posts
    Member since:
    Apr 2015

    Posted 27 Mar 2018 Link to this post

    Any ideas for the default StyleSheet.xaml template? All of 11pt 'Times New Roman', line-spacing at 1.15 - for paragrpahs and lists...
Back to Top