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.

HomeHomeScryberScryberIssues and Defe...Issues and Defe...Binding to the Width AttributeBinding to the Width Attribute
Previous
 
Next
New Post
1/6/2015 1:44 PM
 

Hi, 

 

Is it possible to bind to the width attribute using XPath? I have got it to work with the Item binding by adding an instance of PDFUnit to my object with the required value parameter. How would i go about doing this with XPATH binding. Unfortunately i need to use XPath binding as item binding does not support enumerating a list. 

Hopefully this is supported but if not, please can i suggest that when you try to bind, if the value passes as a numeric then you create a PDFUnit object with the value and no units. 

Many thanks, Mingo

 

 
New Post
1/6/2015 2:36 PM
 

Hi again Mingo

It is possible to bind PDFUnit values either with or without the unit extension to widths, 

(And just for info - you can with margins, colours, dashes etc. The required types all have a static Parse method and are decorated with the PDFParsableValue attribute so the reflector knows how to deal with them.)

Example I have used...

 

BindingWidthsData.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<Items>

  <Item border1="#FF0000" width1="54mm" text1="first row" border2="#FFFF00" width2="100mm" text2="wider cell" />

  <Item border1="#FF0000" width1="54mm" text1="second row" border2="#FF00FF" width2="120mm" text2="wider cell" />

</Items>


Document.pdfx

 

 

<?xml version="1.0" encoding="utf-8" ?>

<pdf:Document xmlns:pdf="Scryber.Components, Scryber.Components, Version=0.8.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              xmlns:style="Scryber.Styles, Scryber.Styles, Version=0.8.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              xmlns:data="Scryber.Data, Scryber.Components, Version=0.8.0.0, Culture=neutral, PublicKeyToken=872cbeb81db952fe"

              auto-bind="true">

  <Pages>

    <pdf:Section>

      <Content>

 

        <pdf:Table>

          <pdf:Header-Row>

            <pdf:Header-Cell>One</pdf:Header-Cell>

            <pdf:Header-Cell>Two</pdf:Header-Cell>

          </pdf:Header-Row>

          <data:ForEach datasource-id="WidthsData" select="Items/Item" >

            <Template>

              <pdf:Row>

                <pdf:Cell style:border-color="{xpath:@border1}" style:width="{xpath:@width1}">

                  <pdf:Label text="{xpath:@text1}" />

                </pdf:Cell>

                <pdf:Cell style:border-color="{xpath:@border2}" style:width="{xpath:@width2}">

                  <pdf:Label text="{xpath:@text2}" />

                </pdf:Cell>

              </pdf:Row>

            </Template>

          </data:ForEach>

        </pdf:Table>

      </Content>

    </pdf:Section>

 

    <data:XMLDataSource source-path="BindingWidthsData.xml" id="WidthsData" />

  </Pages>

</pdf:Document>


And you can apply transformations with parameters to your data if it makes it more effective. Also the mixing of item binding can be done without impact to the current xpath data context.

 
New Post
1/6/2015 2:57 PM
 

Superb, thanks.

 
Previous
 
Next
HomeHomeScryberScryberIssues and Defe...Issues and Defe...Binding to the Width AttributeBinding to the Width Attribute