Let’s create the print layout

By now we’ve built the basic structure of our management software. It’s up to you to add the fields and calculations you need for your work.

In this chapter we’ll see how to create a print layout for orders, so we can print them and send them to our customers as PDF.

The program lets you create an unlimited number of print layouts linked to a data table, so you can have, for example, layouts in several languages, or layouts available only to certain types of users based on their permissions.

Open the Options and go to the Prints page. Open the File menu and select New print.

The program shows the window for selecting the table the print layout will use; for our example we choose Orders.

Selecting the table for a new print layout

Nios4 print layouts are made up of five sections. Each section is added to the print during processing.

  1. The Report Header section contains all the elements inserted at the start of the print, on the first page only.
  2. The Page Header section contains all the elements inserted at the top of every page except the first.
  3. The Detail section is repeated according to the number of data rows to print. This is where the rows of our order go: as long as there are rows to print, the Detail section is created and added to the final print. When there are no more data rows, the program keeps adding empty Detail sections if needed, to reach the end of the current page so the report footer can be attached.
  4. The Page Footer section contains all the elements inserted before the print moves to a new page and starts again with the Page Header section. It is used when the document has at least two pages: the Page Footer section is inserted at the end of the first page, while the Report Footer section goes at the end of the second.
  5. The Report Footer section contains all the elements inserted at the end of the last page of the print.

For example, if the print is a single page, the program inserts the Report Header section and then automatically the Detail sections with the data, so that the Report Footer section can be placed at the end of the page.

For the print to work correctly, all elements must be enclosed in a table. Place the cursor in the Detail section and right-click to open the menu. Open the Insert submenu and choose the table.

Inserting a table in the Detail section

Set the number of columns to 5 and the number of rows to 1: each column will hold one field of the orders_rows table. Click Ok and you should see a table inserted in the Detail section.

Table inserted in the Detail section

Now place the cursor in the first cell on the left and select the code from the field list, under orders_rows.

Then insert “Description”, “Qty”, “Price” and “Total price” in the other cells. The text between the angle brackets identifies the field name. When the program generates the final print, it replaces the field with its actual value.

Now insert a single-cell table in the Report Header section, and inside it put the Customer field, found under Orders.

Then insert another single-cell table in the Report Footer section and put the Total price field in it, also found under Orders.

Save, and our print layout is ready.

To try it, just create a test order, add some items and run the print.

Running the print from an order

As you can see, the program generates the print with the fields of our order, repeating the detail until the end of the page.

Generated order print