This is a migrated thread and some comments may be shown as answers.

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

2 Answers 110 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Art
Top achievements
Rank 1
Art asked on 19 Mar 2018, 09:37 AM

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 Answers, 1 is accepted

Sort by
0
Art
Top achievements
Rank 1
answered on 19 Mar 2018, 09:49 AM
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;
    }
}
0
Art
Top achievements
Rank 1
answered on 28 Mar 2018, 04:24 AM
Any ideas for the default StyleSheet.xaml template? All of 11pt 'Times New Roman', line-spacing at 1.15 - for paragrpahs and lists...
Tags
RichTextBox
Asked by
Art
Top achievements
Rank 1
Answers by
Art
Top achievements
Rank 1
Share this question
or