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

Problem with printing document

1 Answer 77 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
SPE
Top achievements
Rank 1
SPE asked on 13 Mar 2012, 03:03 AM
I have known that there is problem with printing a document including header or footer.
http://www.telerik.com/community/forums/silverlight/richtextbox/radrichtextbox-print-error-with-header-section-in-xaml-format.aspx 

But, the radrichtextbox in my solution makes header and footer automatically.

How do I delete auto-generated header and footer.

thank you.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 13 Mar 2012, 07:04 PM
Hi Sunmin,

As stated in the forum you have quoted, the printing issue when there are headers and footers in the document has been fixed in the latest 2012 Q1 version.

If you are using an older version of the controls, you can remove the headers and footers in the following way:

RadDocument originalDocument;
public MainPage()
{
    InitializeComponent();
    this.editor.CommandExecuting += editor_CommandExecuting;
    this.editor.PrintCompleted += editor_PrintCompleted;
}
 
void editor_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
    if (e.Command is PrintCommand && !e.CommandParameter.Equals("Html"))
    {
        originalDocument = this.editor.Document.CreateDeepCopy() as RadDocument;
        Section section = this.editor.Document.Sections.First; //In version 0920 the document can contain only one section
        this.editor.HeaderFooterUIContext.UpdateHeader(section, HeaderFooterType.Default, new Header());
        this.editor.HeaderFooterUIContext.UpdateHeader(section, HeaderFooterType.First, new Header());
        this.editor.HeaderFooterUIContext.UpdateHeader(section, HeaderFooterType.Even, new Header());
        this.editor.HeaderFooterUIContext.UpdateFooter(section, HeaderFooterType.Default, new Footer());
        this.editor.HeaderFooterUIContext.UpdateFooter(section, HeaderFooterType.First, new Footer());
        this.editor.HeaderFooterUIContext.UpdateFooter(section, HeaderFooterType.Even, new Footer());
    }
}
 
void editor_PrintCompleted(object sender, Telerik.Windows.Documents.UI.PrintCompletedEventArgs e)
{
    this.editor.Document = originalDocument;
}

I hope this helps.

Kind regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
SPE
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or