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

Header issue

1 Answer 48 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gerardo
Top achievements
Rank 1
Gerardo asked on 07 May 2012, 10:23 AM
Hi,
  I tried to put two lines in header. The first page´s header its ok when i print it, but the next pages the header changes like this:

first page´s header: 

---------------------------------------------------------------------------------------
Title
                                                                                                      date
---------------------------------------------------------------------------------------

next page´s header:
---------------------------------------------------------------------------------------
date
                                                                                                      Title
---------------------------------------------------------------------------------------


This is the code:
RadDocument headerDoc = new RadDocument();
RadDocument footerDoc = new RadDocument();
 
Section hSection = new Section();
hSection.PageOrientation = PageOrientation.Landscape;
 
headerDoc.DefaultPageLayoutSettings = new PageLayoutSettings(PaperTypes.A4);
headerDoc.SectionDefaultPageOrientation = PageOrientation.Landscape;
headerDoc.Sections.Add(hSection);
headerDoc.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(5, 5, 5, 5);
 
Paragraph hparagraph = new Paragraph();
hSection.Blocks.Add(hparagraph);
 
Span hspan = new Span("Title");
hspan.FontSize = 20;
if (!string.IsNullOrEmpty("Title"))
    hparagraph.Inlines.Add(hspan);
 
Paragraph h2paragraph = new Paragraph();
h2paragraph.TextAlignment = RadTextAlignment.Right;
hSection.Blocks.Add(h2paragraph);
var fecha = DateTime.Now;
Span h2span = new Span(fecha.ToString());
h2span.FontSize = 10;
h2paragraph.Inlines.Add(h2span);
 
Section fSection = new Section();
fSection.PageOrientation = PageOrientation.Landscape;
 
footerDoc.DefaultPageLayoutSettings = new PageLayoutSettings(PaperTypes.A4);
footerDoc.SectionDefaultPageOrientation = PageOrientation.Landscape;
footerDoc.Sections.Add(fSection);
footerDoc.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(5, 5, 5, 5);
 
Paragraph fparagraph = new Paragraph();
fSection.Blocks.Add(fparagraph);
 
Span fspan = new Span("Footer");
fspan.FontSize = 30;
if(!string.IsNullOrEmpty("Footer"))
    fparagraph.Inlines.Add(fspan);
 
Header header = new Header();
Footer footer = new Footer();
header.Body = headerDoc;
footer.Body = footerDoc;
 
Section section = new Section();
section.PageOrientation = PageOrientation.Landscape;
section.Headers.Default = header;
section.Footers.Default = footer;
 
return section;


Thank you, for your service.

1 Answer, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 10 May 2012, 09:29 AM
Hello,

Your approach seems to be the right one. We tried the code you've posted, but we were unable to reproduce the described behavior. When printing a document, with a section create with your method, all pages have the same headers and footers. 
Can you please provide provide more details on how you are printing the document or sent us a sample project that reproduces the problem so we can investigate it. 

Just a side note: we noticed in the code you've posted, that you set the DefaultPageLayoutSettings and SectionDefaultPageOrientation on the header and footer documents, which has no effect. The right way is to set these properties on the section itself:

section.PageOrientation = PageOrientation.Landscape;
section.PageSize = PaperTypeConverter.ToSize(PaperTypes.A4);

Regards,
Alex
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Gerardo
Top achievements
Rank 1
Answers by
Alex
Telerik team
Share this question
or