Printouts – Technical documentation

Introduction

Printout definitions are stored in the c:\Retail\POS2\Printouts\ directory. Each definition is kept in a separate directory, the name of which is also the name of a given definition. At least three files defining the data source, the printout layout, and the printout formatting must be placed in the directory. Each of these files must be a valid xml file with a specified name. The exact structure of these files is described below.

Data source

The data source for a printout must be located in a file named Data.xml. The primary element of the file is data that needs to contain precisely one setf element. The setf element must contain one or more set elements.

Each set element represents one data set (the result of one SQL query). It must contain two subelements: name, defining the set’s name, and query, defining the SQL query.

Sample Data.xml file

Example

<?xml version="1.0" encoding="utf-8"?>
<data>
  <setf>
    <set>
      <name>SummaryAmount</name>
      <query>
        SELECT
        FORMAT(Value,'N2','pl-PL') as Amount, c.Symbol as Currency
        from Configuration.Currencies c, [Documents].[TradeDocuments] ts
        join Documents.Payments dp on dp.DocumentId = ts.Id
        where ts.Id = {0} and c.IsSystem = 1
      </query>
    </set>      
    <set>
      <name>DocumentRates</name>
      <query>
        SELECT cvr.Name as Name,
        FORMAT(dva.NetValue,'N2','pl-PL') as NetValue,
        FORMAT(dva.GrossValue,'N2','pl-PL') as GrossValue,
        FORMAT(dva.VatValue,'N2','pl-PL') as Vat
        FROM Documents.VATAggregates dva
        JOIN Configuration.VATRates cvr ON cvr.id = dva.VATRateId
        where DocumentId={0}
      </query>
    </set>
  </setf>
</data>>

The query may be a standard SQL query or the name of a stored procedure that returns the desired result. To use a stored procedure, add the type attribute with the StoredProcedure value to the query element.

Data source parameters

When queries from the Data.xml file are executed, parameters are passed to them that depend on the printout’s type and context. The example above uses one @DocumentId parameter.

Printout layout

The content and layout of a printout is defined in the Layout.xml file. The primary element of the file is document. It must include at least the body element that contains the main printout body. Additionally, the document element may contain the title element and multiple header and footer elements. The content of the body, header, and footer elements may be composed of elements described in the Printout layout chapter. These elements may be nested.

Printout formatting

Printout formatting may be adjusted in the Styles.xml file. The primary element of this file is style, that contains elements defining the formatting of particular printout elements defined in the Layout.xml file.

One of the subelements of the style element is fonts, that specifies all fonts to be used for a given printout. It may contain one or more font elements that define the typeface, size, appearance, and style of a given font.

Example

<font name="title" face="Arial" size="20" color="#9fc54c"/>

The attributes of the font element are:

  • name – it specifies the font’s name
  • face – it specifies the typeface’s name
  • size – size given in points
  • color
  • style – it defines a font’s styles. it can contain one or more of the following values (separated with a space character): bold, italic, underline.

The fonts element should also contain one font element with the name attribute omitted. This font will be used as the default font of a given printout.

Example

<fonts>
        <font face="Trebuchet MS" size="10"/>
        <font name="title" face="Arial" size="20" color="#9fc54c"/>
        <font name="header" face="Tahoma" size="8" color="#999999"/>
        <font name="summary_value" face="Trebuchet MS" size="15" color="#9fc54c" style="bold"/>
</fonts>

In addition to the fonts element, the Styles.xml file may contain elements in the following schema:

<selectpr>
        <rule/>
        <rule/>
        [...]
</selector>

In such a schema, selector determines whether rules subordinate to it are to be used for a given element. Most selectors have the same name as the element they style. For instance, to style a paragraph (p element in the Layout.xml file), the p selector should be used.

Example

<p>
        <margin top="5"/>
</p>

In the example below, all printout paragraphs will be assigned a 5-point upper margin.

Selectors may choose only some elements of a given type to be styled. To do so, it is necessary to add the class attribute to an element in the Layout.xml file and to a selector in the Styles.xml file. The selector will then choose only those elements that have the same value of the class attribute.

Example

<p>
        <text font="normal"/>
</p>
<p class="title">
        <text font="title"/>
</p>

The above example will set the font of all paragraphs to normal, but those whose class attribute is title will be assigned the title font.

The detailed description of other selector attributes and the list of styling rules may be found in the Printout formatting chapter. The list of selectors and rules that can be used for a given element may be found in the description of particular elements in the Printout layout section.

Rules from the Styles.xml file are applied from top to bottom, i.e. if two selectors adjust the same element and contain the same rules with different values, then the value occurring later will be applied.

Printout layout

All available elements that can be used when creating a printout layout are described in this chapter. Descriptions of each element include the following sections:

  • Contents – it describes which subelements can be placed within a given element
  • Parameters – it describes all available attributes that can be added to an element
  • Styling element – it contains the list of selectors that adjust a given element in the Styles.xml file
  • Subelements – it is an optional section describing elements that can be found only within a given element. The description of each subelement is structured similarly as in the case of primary elements.
  • Example – it presents a code snippet with an example of the use of a described element

Elements

Barcode

DescriptionBarcode
ContentsInside the barcode element, text data to be encoded by this code is placed.
type - it specifies a barcode type.

Available values include:

  • upc-a

  • upc-e

  • upc 2 digit ext.

  • upc 5 digit ext.

  • ean-13

  • jan-13

  • ean-8

  • itf-14

  • codabar

  • postnet

  • bookland/isbn

  • code 11

  • code 39

  • code 39 extended

  • code 39 mod 43

  • code 93

  • logmars

  • msi

  • interleaved 2 of 5

  • standard 2 of 5

  • code 128

  • code 128-a

  • code 128-b

  • code 128-c

  • telepen

  • fim

  • pharmacode

Styling elements

  • Barcode

Example<barcode type="Code 93"><data set="DocumentHeader" var="EAN" />

Body

DescriptionThe main printout body.
ContentsAny non-text element.
ParametersNone
Styling elements

  • Body

Example<?xml version="1.0" encoding="utf-8"?>
<document>
<title><data set="DocumentHeader" var="NumberString" /></title>
<body>
[printout contents]
</body>
</document>

Br

DescriptionLine break in the text.
ContentsThe element cannot contain any other elements.
ParametersNone
Styling elements

  • None

Example<p>Text<br/> in multiple<br/>lines</p>

Data

DescriptionIt returns data from a data source in text form.
ContentsThe element cannot contain any other elements.
Parameters

  • set - the name of a data set

  • var - a column name

  • index - a row index from a data source (default value:  0)

  • format - todo

Styling elementsNone
Example<barcode type="Code 93"><data set="DocumentHeader" var="EAN" /></barcode>
DescriptionPrintout footer.
ContentsAny non-text element.
Parameterspage - printout page. If this parameter is not specified, the footer is treated as the main footer.

Available values include:


  • first - the first page

  • last - the last page

  • even - an even page
Styling elements

  • Footer
Example
<?xml version="1.0" encoding="utf-8"?>
<document>
<footer page="last">
<p>Footer of the last page</p>
</footer>
DescriptionPrintout header
ContentsAny non-text element.
Parameterspage - printout page. If this parameter is not specified, the header is treated as the main header.

Available values include:

  • first - the first page

  • even - an even page

Styling elements

  • Header
Example<?xml version="1.0" encoding="utf-8"?>
<document>
<header>
<p>Header</p>
</header>
<body>
[...]

Horizontal and Section

Horizontal
DescriptionDivision into sections arranged horizontally.
ContentsOne or more section elements
ParametersNone
Styling elements

  • Header

Subelements

  • Section

Section
DescriptionSection.
ContentsAny non-text elements.
ParametersNone
Styling elementsweight - weight of column width. The default value is 1.
Subelements

  • Section

Example for Horizontal and Section
Example

<horizontal>
        <section><p class="sign">Document issued by</p></section>
        <section weight="0,1"></section>
        <section><p class="sign">Item(s) released by</p></section>
        <section weight="0,1"></section>
        <section><p class="sign">Date collected</p></section>
        <section weight="0,1"></section>
        <section><p class="sign">Item(s) collected by</p>
<p class="footer">Page <pageNumber/> of <numOfPages/></p></section>

</horizontal>

Hr

DescriptionHorizontal line
ContentsThe element cannot contain any other elements.
ParametersNone
Styling elements

  • Hr

Example<p>text1</p>
<hr />
<p>text2</p>

If

DescriptionA text element enabling the adjustment of a printout layout depending on any conditions.
ContentsThe test element and at least one of the elements true and false
ParametersNone
Styling elementsNone
Subelements

  • Test

  • True

  • False

Test
DescriptionIt contains a condition determining whether to add elements from the true or false section to a given printout. The condition may be any logical expression containing basic mathematical operations, comparisons.  It can also contain parentheses.
ContentsAny text elements.
ParametersNone
Styling elementsNone
True
DescriptionIt contains elements that will be used if a condition from the test section is met.
ContentsAny elements that may be placed in the parent of the test element.
ParametersNone
Styling elementsNone
False
DescriptionIt contains elements that will be used if a condition from the test section is not met.
ContentsAny elements that may be placed in the parent of the test element.
ParametersNone
Styling elementsNone
Example for If
Example

<if>
        <test><data set="DocumentsPositions" var="Id" /> &lt; 3123</test>
        <true>
                 <horizontal>
                         <section weight="2">
                                  <p><data set="DocumentsPositions" var="Name" /></p>
                                  <p><data set="DocumentsPositions" var="Barcode" /></p>
                         </section>                         <section weight="3">
                                  <p><data set="DocumentsPositions" var="Name" /></p>
                                  <p><data set="DocumentsPositions" var="Barcode" /></p>
                         </section>                 </horizontal>        
</true>        
<false>
                 <p><data set="Header" var="CompanyName" /></p>
        </false>
</if>

Image

DescriptionAn image from a database or disk.
ContentsThe element cannot contain any other elements.
Parameters

  • path - the path to a file or to the root directory of a printout definition. If the path parameter is set, other parameters will be ignored.

  • set - the name of a data source

  • var - a column name in the data source

  • index - a row index in the data source

Styling elements

  • Image

Example<image path="logowms.png" />
<image set="Header" var="Logo" />

PageNumber

DescriptionThe number of the current page.
ContentsThe element cannot contain any other elements.
ParametersNone
Styling elementsNone
Example<footer>
<p class=”footer”>Page<pageNumber/> of <numOfPages/></p>
</footer>

P

DescriptionA paragraph.
ContentsAny text element.
ParametersNone
Styling elements

  • P

Example<p class="date">Data di emissione: <data set="DocumentHeader"
var="DocumentCreationDate" /></p>

RowNumber

DescriptionThe number of the current table row.
ContentsThe element cannot contain any other elements.
ParametersNone
Styling elementsNone
Example<table set="DocumentPositions">
<column weight="2" description=”N." class="number">
<rowNumber />
</column>
<column weight="12" description=”[Code] Item name">
[<tableData var="Code" />] <tableData var="Name" />
</column></table>

StaticTable

DescriptionA static table with a set number of columns and rows.
ContentsThe head element and one or more row elements
Parameters

  • split- it defines whether a table can be divided into several pages. The parameter may be assigned the values true or false.

Styling elements

  • StaticTable

Subelements

  • Head

  • Column

  • Row

  • Cell

DescriptionAn element defining a table header.
ContentsOne or more column elements
ParametersNone
Styling elementsNone
Column
DescriptionAn element defining a single table column.
ContentsAny non-text elements.
Parametersweight - weight of column width. The default value is 1.
Styling elements

  • HeadCell

Row
DescriptionAn element defining a single table row.
ContentsOne or more cell elements
ParametersNone
Styling elementsNone
Cell
DescriptionAn element defining a single table row cell.
ContentsAny non-text elements.
Parameters

  • collspan - it determines how many columns a given cell should occupy (it allows merging table cells)

  • rowspan - it determines how many rows a given cell should occupy (it allows merging table cells)

Styling elements

  • Cell

Example
Example

<staticTable class="customer">
        <head>
                 <column weight="1"><p class="tableHead">Secondary Customer</p></column>
                 <column weight="1"><p class="tableHead">Customer</p></column>
        </head>
        <row>
                 <cell>
                         <p class="customer"><data set="DocumentHeader" var="CustomerName" /><br/>
                         <data set="DocumentHeader" var="Street" /><br/>
                         <data set="DocumentHeader" var="ZipCode" />&#160;<data set="DocumentHeader" var="City" /><br/>
                         IVA: <data set="DocumentHeader" var="Tin" /><br/>
                         </p>
                 </cell>
                 <cell>
                        <p class="customer"><data set="DocumentHeader2" var="CustomerName" /><br/>
                         <data set="DocumentHeader2" var="Street" /><br/>
                         <data set="DocumentHeader2" var="ZipCode" />&#160;<data set="DocumentHeader2" var="City" /><br/>
                         IVA: <data set="DocumentHeader2" var="Tin" /><br/>
                         </p>
                 </cell>
        </row>
        <row>
                <cell collspan="2">
                         <p>...</p>
                 </cell>
        </row>
</staticTable>

Table

DescriptionA dynamic table with a fixed or dynamic number of columns.
ContentsOne or more elements:

  • column

  • dynamic-columns

  • if (it can only contain the elements column, dynamic-columns, or if)
Parameters

  • split - it defines whether a table can be divided into several pages. The parameter may be assigned the values true or false.

  • set - the name of a data set.

Styling elements
Subelements
Column
DescriptionAn element defining a table column.
ContentsAny text elements.
Parameters

  • description - a column header

  • weight - the weight of column width. The default value is 1

Styling elements

  • DataCell

  • HeadCell

Dynamic-columns
DescriptionAn element defining the series of columns with a name defined by a regular expression.
ContentsAny text elements.
Parameters

  • names- a regular expression selecting columns from a data source

Styling elements

  • DataCell

  • HeadCell

If

A conditioning element making it possible to hide or show selected columns.

See the generic If element.

TableData
DescriptionAn element returning a text value from a data set, based on a table data set, a column indicated in the var parameter, and the current table row.
ContentsThe element cannot contain any other elements.
Parameters

  • var- a column name from a data set

Styling elementsNone
Example 1 – Static and conditional columns
Example

<table set="DocumentPositions">
        <column weight="2" description="N." class="number">
                 <rowNumber />
        </column>
        <column weight="12" description="[Code] Item name">
                 [<tableData var="Code" />] <tableData var="Name" />
        </column>
                 <if>
                         <test>
                                  <hasColumn var="Column15" /> = 1
                         </test>
                         <true>
                                  <column weight="2" description="Test" class="number">
                                          <tableData var="Column15" />
                                  </column>
                         </true>
                 </if>
        <column weight="4" description="Quantity" class="number">
                 <tableData var="RealizedQuantity" />
        </column>
        <column weight="4" description="UOM (base)">
                 <tableData var="BasicUnitSymbol" />
        </column>
        <column weight="4" description="Quantity" class="number">
                 <tableData var="SecondaryQuantityRealized" />
        </column>
        <column weight="4" description="UOM (additional)">
                 <tableData var="SecondaryUnitSymbol" />
        </column>
</table>

Example 2 – Dynamic columns
Example

<table set="DocumentPositions">
        <column weight="2" description="N." class="number">
                <rowNumber />
        </column>
        <column weight="12" description="[Code] Item name">
                 [<tableData var="Code" />] <tableData var="Name" />
        </column>
        <dynamic-columns weight="4" description="Currency {{1}}" names="Currency(.+)">
                 <tableData var="{{0}}" /> {{1}}
</dynamic-columns>

Title

DescriptionA document title used to name a PDF file.
ContentsAny text element.
ParametersNone
Styling elementsNone

Printout formatting

This chapter describes all styling elements (selectors) and rules. The description of each selector contains the list of elements a given selector styles and the list of rules that can be placed within the selector.
The description of each rule contains the list of attributes that can be used for it.

Narrowing attributes

Each selector may be narrowed down with the class attribute. Additionally, element selectors related to tables may be narrowed down with the index attribute that can contain an integer or an expression in the form An+B, where A and B are integers. Such a selector adjusts an element if it is consistent with a table row index (table rows are numbered from 0, from top to bottom).

Example

  • index=”0″ – it adjusts the first table row
  • index=”first” – it adjusts the first table row
  • index=”last” – it adjusts the last table row
  • index=”5″ – it adjusts the sixth table row
  • index=”2n” – it adjusts even table rows, i.e. those with indexes equal to 0, 2, 4…, i.e. the first, third, fifth… row
  • index=”3n+1″ – it adjusts rows with indexes equal to 1, 4, 7…
  • index=”3n+2″ – it adjusts rows with indexes equal to 2, 5, 8…

Selectors

Barcode

DescriptionA selector for barcodes.
Styled elements

  • Barcode

    Narrowing parameters

    • class

      Rules

      • fit

      • margin

      • text

      • border

      Body

      DescriptionA selector for the main printout element.
      Styled elements

      • Body

        Narrowing parameters

        • class

          Rules

          • page

          • margin

          Cell

          DescriptionA selector for a cell in a static table.
          Styled elements

          • Cell

            Narrowing parameters

            • class

            • index

              Rules

              • border

              • background

              • text

              DataCell

              DescriptionA selector for a cell in a dynamic table.
              Styled elements

              • Column

                Narrowing parameters

                • class

                • index

                  Rules

                  • border

                  • background

                  • text

                  DescriptionA selector for a document footer.
                  Styled elements

                  • Footer

                    Narrowing parameters

                    • class

                      Rules

                      • margin

                      • border

                      • background

                      • text

                      HeadCell

                      DescriptionA selector for a header cell in a dynamic table.
                      Styled elements

                      • Column

                        Narrowing parameters

                        • class

                          Rules

                          • border

                          • background

                          • text

                          DescriptionA selector for a document header.
                          Styled elements

                          • Header

                            Narrowing parameters

                            • class

                              Rules

                              • margin

                              • border

                              • background

                              • text

                              Hr

                              DescriptionA selector for a horizontal line.
                              Styled elements

                              • Hr

                                Narrowing parameters

                                • class

                                  Rules

                                  • border

                                  Image

                                  DescriptionA selector for an image.
                                  Styled elements

                                  • Image

                                  Narrowing parameters

                                  • class

                                  Rules

                                  • fit

                                  P

                                  DescriptionA selector for a paragraph.
                                  Styled elements

                                  • P

                                  Narrowing parameters

                                  • class

                                  Rules

                                  • margin

                                  • text

                                  • border

                                  • background

                                  Section

                                  DescriptionA selector for a section.
                                  Styled elements

                                  • Section

                                  Narrowing parameters

                                  • class

                                  Rules

                                  • text

                                  • border

                                  • background

                                  StaticTable

                                  DescriptionA selector for a static table.
                                  Styled elements

                                  • StaticTable

                                  Narrowing parameters

                                  • class

                                  Rules

                                  • width

                                  • text

                                  • border

                                  • background

                                  Table

                                  DescriptionA selector for a dynamic table.
                                  Styled elements

                                  • Table

                                  Narrowing parameters

                                  • class

                                  Rules

                                  • width

                                  • text

                                  • border

                                  • background

                                  Rules

                                  Background

                                  A rule defining an element’s background.

                                  Attributes

                                  • color – an element background color. It can be entered in the #RRGGBB or 0xRRGGBB or 0xAARRGGBB format.

                                  Border

                                  A rule defining an element’s border.

                                  Attributes

                                  • left – the width of the left border.
                                  • right – the width of the right border.
                                  • top – the width of the top border.
                                  • bottom – the width of the bottom border.
                                  • color – the color of an element’s border. It can be entered in the #RRGGBB or 0xRRGGBB or 0xAARRGGBB format.
                                  • borderStyle – a border’s style. It accepts the following values:
                                    • dashdot
                                    • dashdotdot
                                    • dashlargegap
                                    • dashsmallgap
                                    • dot
                                    • none
                                    • single

                                  Border width can be entered in different units, including cm, in, mm, pt. The default unit is pt.

                                  Styling a selected border element

                                  It is possible to style only a selected part of a border, e.g. only the left edge of an element. To do so, use one of the following selectors:

                                  • borderLeft
                                  • borderRight
                                  • borderTop
                                  • borderBottom

                                  Each of these selectors can contain the following rules:

                                  • width – a border’s width
                                  • color – a border’s color
                                  • borderStyle – a border’s style

                                  Fit

                                  A rule defining the size of an element.

                                  Attributes

                                  • width – an element’s width
                                  • height – an element’s height

                                  Width and height can be entered in different units, including cm, in, mm, pt. A styled element retains its proportions, taking the smaller of the specified dimensions.

                                  Margin

                                  A rule defining an element’s margins.

                                  Attributes

                                  • left – the left margin
                                  • right – the right margin
                                  • top – the top margin
                                  • bottom – the bottom margin

                                  Margin width can be entered in different units, including cm, in, mm, pt.

                                  Page

                                  Special rules for a page.

                                  Attributes

                                  • orientation – page orientation
                                  • size – page size
                                  • width – page width
                                  • footer-distance – distance of the footer from the bottom of a page
                                  • header-distance – distance of the header from the top of a page

                                  Text

                                  A rule defining a text style.

                                  Attributes

                                  • align – text alignment. It accepts the following values:
                                    • right – right alignment
                                    • left – left alignment
                                    • justify – text justification
                                    • center – text centering
                                  • indent – the indentation of the first line of text.
                                  • leftIndent – left indentation of text.
                                  • rightIndent – right indentation of text.
                                  • font – a font name defined earlier in the fonts section.
                                  • color – text color. It can be entered in the #RRGGBB or 0xRRGGBB or 0xAARRGGBB format.

                                  Width

                                  A rule defining an element’s width.

                                  Attributes

                                  • percentage – the percentage width of an element based on the width of its parent element.

                                  Czy ten artykuł był pomocny?