RadFlowDocument object instantiation causes my UI to break.

1 Answer 52 Views
Documentation
Sangeet
Top achievements
Rank 1
Sangeet asked on 25 Sep 2023, 08:54 AM

public void WriteToWordDocumentContinued(){

    m_document = new RadFlowDocument();
    m_editor = new RadFlowDocumentEditor(m_document);
    Section section = new Section(m_document);
    section.HasDifferentFirstPageHeaderFooter = true;
    section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(56.69, 94.49, 47.24, 66.14);
    m_document.Sections.Add(section);
    m_document.StyleRepository.AddBuiltInStyle(BuiltInStyleNames.GetHeadingStyleIdByIndex(1));


    Style MainTitle = new Style("MainTitle", StyleType.Character) { };
    MainTitle.CharacterProperties.UnderlinePattern.LocalValue = UnderlinePattern.Single;
    MainTitle.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
    MainTitle.CharacterProperties.FontSize.LocalValue = 32;
    MainTitle.CharacterProperties.FontWeight.LocalValue = System.Windows.FontWeights.Bold;
    m_document.StyleRepository.Add(MainTitle);

    Style HeaderParagraphStyle = new Style("HeaderParagraphStyle", StyleType.Paragraph) { };
    HeaderParagraphStyle.ParagraphProperties.LineSpacing.LocalValue = 16;
    HeaderParagraphStyle.ParagraphProperties.LineSpacingType.LocalValue = HeightType.Exact;
    HeaderParagraphStyle.ParagraphProperties.SpacingAfter.LocalValue = 0;
    HeaderParagraphStyle.ParagraphProperties.SpacingBefore.LocalValue = 0;

    Style HeaderTitleStyle = new Style("HeaderTitleStyle", StyleType.Paragraph) { };
    HeaderTitleStyle.ParagraphProperties.LineSpacing.LocalValue = 21.4;
    HeaderTitleStyle.ParagraphProperties.LineSpacingType.LocalValue = HeightType.Exact;
    HeaderTitleStyle.ParagraphProperties.SpacingAfter.LocalValue = 0;
    HeaderTitleStyle.ParagraphProperties.SpacingBefore.LocalValue = 0;
    HeaderTitleStyle.ParagraphProperties.TextAlignment.LocalValue = Alignment.Right;

    HeaderParagraphStyle.ParagraphProperties.TextAlignment.LocalValue = Alignment.Right;
    m_document.StyleRepository.Add(HeaderParagraphStyle);

    Style HeaderCharacterStyle = new Style("HeaderCharacterStyle", StyleType.Paragraph) { };
    HeaderCharacterStyle.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
    HeaderCharacterStyle.CharacterProperties.FontSize.LocalValue = 16;
    m_document.StyleRepository.Add(HeaderCharacterStyle);

    Style SubTitle = new Style("SubTitle", StyleType.Character) { };
    SubTitle.CharacterProperties.UnderlinePattern.LocalValue = UnderlinePattern.Single;
    SubTitle.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
    SubTitle.CharacterProperties.FontSize.LocalValue = 16;
    SubTitle.CharacterProperties.FontWeight.LocalValue = System.Windows.FontWeights.Bold;
    m_document.StyleRepository.Add(SubTitle);

    Style TopLines = new Style("TopLines", StyleType.Character) { };
    TopLines.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial");
    TopLines.CharacterProperties.FontSize.LocalValue = 16;
    TopLines.CharacterProperties.FontWeight.LocalValue = System.Windows.FontWeights.Bold;
    m_document.StyleRepository.Add(TopLines);

}

 

This is just minified version of the method where I am trying to instantiate my RadFlowDocument object. This method is being called in a parent class, even If I try to pass RadFlowDocument object from that class, it still causes the UI to break. 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Sep 2023, 04:46 AM

Hi, Sangeet, 

According to the described behavior, it seems that you hit a known situation in which the application becomes DPI aware once any classes from the Document Processing libraries got instantiated. Please have a look at the following KB article which is quite useful on this topic:

https://docs.telerik.com/devtools/winforms/knowledge-base/app-becomes-dpi-aware 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Documentation
Asked by
Sangeet
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or