Background Color:
 
Background Pattern:
Reset
Search

Forum

Please Log In

We want you to contribute! 

This forum is a moderated environment. 
We try to keep it neat and tidy. In order to access the forum content we would like you to either or register.

HomeHomeScryberScryberDevelopment Que...Development Que...Header and footer in C#Header and footer in C#
Previous
 
Next
New Post
10/11/2015 11:29 AM
 

Hi guys, just started trying out scryber,

Does anyone have any good examples of headers and footers being made in C# as I can only find the XML version on the help guide.

 

Thanks,

 

Matthew

 
New Post
10/12/2015 7:25 AM
 

Hi Matthew

 

Page Headers and Footers are a bit special in that they are only created at layout time, rather than parse or databind time - because there could be multiple instances.
However they are only expected to implement the IPDFTemplate interface, which is pretty simple.

So in your code you can create one or more classes that implement this interface and assign as a page header (or footer) value.

 

public class CustomTemplate : IPDFTemplate

    {

        public IEnumerable<IPDFComponent> Instantiate(int index, IPDFComponent owner)

        {

            PDFLabel lbl = new PDFLabel();

            lbl.Text = "This is the header on the page that has been assigned from a custom template";

            return new IPDFComponent[] { lbl };

        }

    }


Once you have done this you can assign to the page (or section) header

pg.Header = new CustomTemplate();


And then the 'Instantiate' method will be called for each header or footer needed. All returned components will be nested in a PDFPageHeader or PDFPageFooter instance which can also be styled (as can any instantiated and returned components).

 

Hope this helps

Richard

 
New Post
10/12/2015 7:52 AM
 

That's a great help,

 

Thanks

 
New Post
5/24/2016 10:01 PM
 

What if I wanted to pull in data for use during the Instantiation? Something like a dictionary, etc?

 
New Post
5/25/2016 8:30 AM
 

Not sure I understand the question Mophiematt. You would instantiate the controls at layout and assign any data you wanted to them? 

 
New Post
5/25/2016 1:39 PM
 

I mean for a header specifically. I want to, depending on what has been input, insert a specific set of values into the header, but those values have to come from the dictionary. Since the headers are only written at run time, I can't use a placeholder like I can for the main components. The instantiate inheritance is pretty picky and wont let me bring in a dictionary of values. I assume I'm just ignorant of some other way to pull them in and have the instantiate method work with the dictionary values?

 
Previous
 
Next
HomeHomeScryberScryberDevelopment Que...Development Que...Header and footer in C#Header and footer in C#