A simple example – Step by step

This tour contains a very simple example for a layout created with XSLfast. We provide all information you'll need and lead you through the single steps. If you follow these steps closely, you should be able to achieve a good result even if you are an inexperienced user yet.

Please read the instructions carefully and follow each step before you turn to the next one. The images are intended to help you understand what you need to do.

Guided Tour 

Load Data source: XML file

This is XSLfast when you start it. The wizard indicates what you want to do - open an existing layout or create a new one.

Choose the option "Create new layout" and click "Ok"

Now what you need first is a data source, which is an XML file. XSLfast will ask you to set a data source when you open a new layout.

Load your XML file into XSLfast

After you have loaded the XML file, it is displayed in the XML window, showing nodes and subnodes.

You can close or open the nodes with the "directory" symbol by clicking the minus or plus symbol to see which nodes they contain.

Now you can see all the nodes the file is made of, like Report, ProductGroup, Product and Properties and the nodes they contain, like ProductGroupID or Name. The entire contents of the XML file are sorted into these nodes.

You do not see the actual contents of the file, though. Some XML files can have rather huge proportions and you only need the general structure of the file to work with in the first place.

Remember: XSLfast works with templates, not with documents; this means, you do not work with the actual content. Instead, you use anchors that will be automatically filled.

Working sheet

This is your actual working sheet. At the moment, it is still empty. After adding elements to the sheet, the inspector will display the corresponding properties for the selected elements.

Group the page to a node

First, the groupings have to be specified. XSLfast automatically retrieves the data from XML. The example requires the grouping of the page to the first node below Report. The node′s name is ProductGroup.

Right click the page and open the context menu Grouping

Now select the node ProductGroup and click OK.
You have made the first grouping which is now indicated on the page tab:

This is the first connection you established between the sheet and the XML file. It also serves as a page breaking marker which means that XSLfast will create a new page for every product group contained in the XML file. You will see the effect during the course of this example.

Place frames on the sheet

The next step is placing the needed frames on the sheet. To create the PDF page we want, we need:

  1. Text frames with static contents, which we will use for the headline, a field name and the copyright text in the footer of the page
  2. A static image frame in the header containing the logo
  3. A table frame with one row, seven columns and a header to name the columns
  4. Text frames with dynamic contents for the product data, e.g. in the table
  5. A dynamic image frame for the product images in the table
  6. These will be discussed on the following pages.

Static text frames

Place the frame in the header region above the blue line because we want to use it as the headline of the document and need it on every page of the PDF document. All elements placed in the header or footer or right and left regions appear on every page of the document. Move the blue line down to make the header region bigger.


Double click the frame to make it editable and enter the text "Hardware & Software II Monitors and Printers" (or any other text) in the right frame of the pop up window.

Don't be confused with the left frame with the XML tree, you don't need it for this frame but you will need it later during this tour. Now click the button "OK" at the bottom of the window.


Place another frame in the same way and enter the text "Product Group".


When the frame is selected, you can edit it if you double click on it to open the text editor or right click on it. This opens the property menu.

Use the commands font family, font size, font style, text color and background color to change the headline "Hardware & Software II Monitors and Printers" to the size of 20pt and use the font Arial for it. Also set the text color to white and the background color to black.


Change the text color in "Product Group" to white and the style to italics and bold, text size 14pt.

Now your header should look like this:

The white text is not visible on the white sheet but it will be visible on a colored background later.


And now add a copyright to the footer area of the page.

Static image frames

We want to display a logo on every page of the document. This is how you do it:


Place a static image frame into the right upper corner of the sheet and open a frame:


As this will be a static image, there is not much else to do. If you are not sure whether the image will fit into the frame you placed, mark "Fit in Frame" and "Keep aspect ratio" (these commands are displayed in the inspector window when the image frame is selected) to avoid distorsions in the image if it is resized.

To determine which image should be displayed in this frame, click the area beside "Image/Image node" in the inspector window which currently shows "No image" or double click the image frame itself.

A file dialog opens where you should select the correct image file. We have selected a company logo.


Now you should see the image on your sheet:

Because it is in the header, it will be displayed on every page of the document.

Table frames

Now create a table.


Click the button and enter the values:

We need seven columns, one row and a header to name the columns.

Click "OK".


Now open the table frame on the sheet, just the way you opened the other frames. You may have to resize the columns right away to keep them all inside the page body (within the blue lines), which is important. Size table and cells by moving the black lines.

As you see, the top row of cells belongs to the header, and in the row below that there are the seven table cells. The actual table is colored in blue. The table frame itself may be bigger than the actual table so that you can still access the table rows and the table columns. It may even extend the sheet boundaries. The table cells themselves, however, should all be completely inside the page body.


Now you need to specify what content the table should display in general. You should create a grouping between the table and a specified node of the XML file (like you created the grouping between the page and the XML file). Double click the table. Make sure you really double click the table and not just a row or a column. The best way is to double click in the white colored area at the right bottom of the table.

The XML file is always read from the top by the application, (from the node you linked the page to because the page is the base of your layout). The node "ProductGroup" contains the node "Product", as you see. As you have already linked the page to the node "ProductGroup", now you link the table to the node "Product" because this node contains the information we want to see in the table. This way you determine that the table will contain contents from the node "Product" and from its subordinate nodes. Now select the node "Product" and click "OK".

Dynamic text frames

The next step is to place another text frame in the header. It will be combining dynamic and static text which means it will show the static label "Product Group" as well as the dynamic name of the changing product groups (as they will change according to the product group which is presented in the page). We will also fill the table with text frames, both dynamic and static.


There are several ways to create the "dynamic" text frames on the sheet:

1. drag and drop the correct node from the XML window to the sheet.

2. assign the node to the text element via the text editor. Double click the text element containing the white text.


Now you need the XML tree on the left side, we mentioned it earlier. The text you entered so far is static text, this means it is not depending on any XML content, therefore it will not change. But we want to display the name of the product group there as well, which will be dynamic text, changing according to the XML content. To achieve this, drag the node Report/ProductGroup/Name to the right of the static text (don't forget the blank space between them):

Now you have both, static and dynamic text parts combined.



Next you need to place more dynamic text frames into the table cells. We need the following nodes from the node Product: ProductNumber, Name, ProductPrice. Drag and drop these nodes into the first three table cells. (Please do not confuse the table cells with the header cells.)

Drag the nodes over the correct table cell. The cell will indicate by changing its color to red that you can drop the node now.



The next three cells should be filled with nodes from the node Properties, which is contained in the node Product. Place the nodes Resolution, Height and Manufacturer in exact the same way as you placed the other nodes, by drag and drop.

Please note that the text displayed in these three last frames differs from the text in the first placed frames:

The last three nodes belong to the node Properties which is contained in the node Product. To make sure the application displays the correct contents, and because the application reads the XML file from the top (as mentioned before) this fact must be considered, so the name of the "subnode" is also displayed in the path to the correct node, as you can see here.


Now we want to create the headers for each column. Open text frames in the table header, one for each column. The header cells will also indicate when to drop the frame by changing the color to red when you pull the frame over them or open it in them. We need the headers Product ID, Name, Price $, Resolution, Weight kg, and Manufacturer. Color the background of the frames black and the text color white with the context menu or the icons Text color and Background color from the icon bar. Also set the style to "bold".


Your layout should look like this now:

Dynamic image frames

We also want a product image in our table. The information which image should be displayed with which product is already contained in the XML file:

This is an excerpt from the XML file showing the contents of the Report/ProductGroup/Product/Properties node belonging to product 1.

..
<Resolution>1024 x 768</Resolution>
   <Weight>2.3</Weight>
   <Manufacturer>Maxdata</Manufacturer>
   <img>101705.jpg</img>
</Properties>
..


Placing a dynamic image frame is slightly different from XML text frames. It can be done by drag and drop, but you need to convert the dragged node afterwards. To achieve this you drag the node into place, open the context menu with the right mouse button and select the menu item Convert->Image/XML Data. This technique saves you the step of explicitly assigning a node to this image element because it had initially originated from the node.

Another way is to use place it like a static image. Just click and move the image in the last empty table cell:


Now use the commands in the inspector window. They are exactly the same as for static images:

Again, if you are not sure whether the images will fit into the frames, use "Fit in frame" and "Keep aspect ratio".

And now you need to make a connection. You need to group the image frame to the correct node of the XML file, which means you connect the frame to the node containing the image information. The complete path from the top of the XML file to that node is Report/ProductGroup/ Product/Properties/img. But this frame is part of the table (that you already grouped to the node Product) which means the first part of the path to the correct node is already determined: Report/ProductGroup/Product/ and only the missing part Properties/img must be considered. Double click the image frame and drag the correct node from the XML tree on the left to the right editor window as you did with the text frames. After that, make the cell a little bigger by dragging the lower rim down:




Now you need to specify the path to the directory containing the images, the image base. Click the area beside "Image base path" and select the directory containing all images. XSLfast will search for the images used in the XML file in this directory.

Complete layout

If you followed the steps, your complete layout should look like this now:

Next, we want to add a little color to the layout.

Colors, page, numbers and decoration

We want to have alternating table row colors

To do this, select the table and look at the properties in the inspector window:

Check "Use alternate colors" and click on the area next to "Alternate Colors":

Select the color bar and click "Change". Select your desired color in the color editor window. If you would like to have more than two alternating colors, click "Add" and select the color. In our example, we used white and a bright grey as the alternating table colors.

Next we want to add some color elements to the page

Open a square and place it in the header of the page. Give it the color RGB 153,153,255 and place it in the background by using the menu item "Arrange->To back" as many times as needed to see all other elements on top of it.

The square may even extend the layout, because the PDF will only show what's on the sheet:

Do the same in the footer area.

Give the table a border by selecting it and using the menu item Frame properties-> Border from the inspector window.

Make the border black and 1mm wide.

If you like, add a little padding to the frames so the text won't be so close to the border of the frame.

Select the frame and use Frame properties->Bounds-> Paddings from the inspector window.

Maybe you want to add another text element with the company's address below the company logo?

Add pagination by clicking the button and opening the frame in the footer

Font, style, text color and background color can be set like in all text frames or just be left as it is.

Confirm your settings with "OK"

We are finished creating our layout.

Now process the layout by clicking the icon "Process layout" and view the result.

The first page of the processed layout should look like this now:

Processed layout

This is the result:

Page 1

You already saw it on the previous page:

The name of the product group is displayed (Monitors), and all contained products with the information Product ID, Name, Price, Resolution, Weight, Manufacturer and the matching image.

At the bottom of the page there is the copyright and the pagination.

Page 2:

As you see, XSLfast displays the next product group (Printers) after the first one was finished and it also starts a new page for the new product group. This is the result of grouping the page to the node ProductGroup. All information belonging to the next product group are now displayed.

Page 3:

As there are too many products in the second product group to fit into one page, the third page of the PDF document shows the last products of the second product group.