Background Color:
Background Pattern:


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.

HomeHomeScryberScryberIssues and Defe...Issues and Defe...Item Binding IssueItem Binding Issue
New Post
1/6/2015 9:48 AM

Hi i am evaluating using your product for my client however i have run into a problem. 

Item binding does not seem to work on elements only attributes for example;

Consider an instance of an object called MyItem which has a string property Test with the value "Does it bind"

<pdf:Label text ="{item:MyItem.Test}"/>

Will render "Does it bind"



will render "{item:MyItem.Test}" which is undesirable. Am i doing something wrong or is this a known issue. 

 MyItem myItem = new MyItem(){

                Test = "Does it bind"


 using (Scryber.Components.PDFDocument doc = Scryber.Components.PDFDocument.ParseDocument("../Templates/TestTemplate.pdfx"))


                    doc.Items["MyItem"] = myItem;


                    //perform any actions on the document content required here 

                    doc.ProcessDocument(memoryStream, true);


I am using version installed via Nuget.

Would really appreciate a speedy answer as will need to look elsewhere if this does not work. 


New Post
1/6/2015 10:56 AM

Hi Mingo

The content of a span is a collection rather than a property, so it cannot be bound to - the parser needs to bind to specific properties on the underlying classes that the elements represent.

You can nest a label within the span and set the text value there, if that works for you.

New Post
1/6/2015 12:43 PM



Thanks for the swift reply, that should work for me, although this seems a bit odd for Para and Pre types as forcing the sub text into labels could change the desired behaviour.

Also i have one more quick question, are there plans to support foreach and condition in item binding soon. That would be really helpful. I know i can achieve this by serialising my object and then using XPATH but seems like an unnecessary step. 

E.g. something like this for the xml 

<data:ForEach select="{item:MyItem.People}" >


                <data:If test="{item:Age} > 20" >

                  <pdf:Div id="titles" style:margins="10pt">

                    <pdf:H1 id="heading" text="{item:Name}" />

                    <pdf:H3 id="subhead" text="{item:Age}" />







var data = new MyItem()



                Title = "People",


                People = new List<Person>() {

                    new Person(){Name ="Jon", Age = 21},


                    new Person(){Name ="Barry", Age = 23},


                    new Person(){Name ="Roger", Age = 19}




            using (var memoryStream = new MemoryStream())


                using (Scryber.Components.PDFDocument doc = Scryber.Components.PDFDocument.ParseDocument("../PDF Templates/Test.pdfx"))


                    doc.Items["MyItem"] = data;


                    //perform any actions on the document content required here 

                    doc.ProcessDocument(memoryStream, true);




                var result = new HttpResponseMessage(HttpStatusCode.OK)


                    Content = new ByteArrayContent(memoryStream.ToArray())



                result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

                result.Content.Headers.ContentLength = memoryStream.Length;


                return result;


public class MyItem



    public string Title { get; set; }


    public List<Person> People { get; set; }



public class Person



    public string Name { get; set; }


    public int Age { get; set; }



Many thanks, Mingo





New Post
1/6/2015 1:51 PM

Glad it works for you Mingo - I know where you are going with the Para and Pre elements, and perhaps what we are missing is a ValueOf or Text component - that is converted into a literal.

As for the binding enumerators - have thought about it, and it is the complex expressions that XPath does so well that are the issue. What we are investigating is integrating the razor engine into the files. This would give all the power needed (and more) before we start parsing the template. And would also achieve the desired result.

What would be your thoughts on this? It's way off in the future, but code behind / controllers / inline code is definitely on the cards.

New Post
1/6/2015 2:41 PM

Razor sounds sensible it would save you having to implement all this yourself as whilst a simple version for basic types and IEnumerable would be easy to add, there would no doubt be loads of complex edge cases and type checking issues to fix. 

I have another question but will post separately. 


Thanks, Ed




HomeHomeScryberScryberIssues and Defe...Issues and Defe...Item Binding IssueItem Binding Issue