Create labels: the report application (Swift)

A common use of reports is to create a page of labels, such as address labels. Creating labels requires you to create a report design document representing a single label and a report application that prints multiple labels on a page.

Create the report design document

The report design document (.4rp) contains the design for a single label. You can put anything you wish on the label, as long as it fits onto the page.

See Design labels for details on creating the single-label report design document (.4rp).

Create the Label report Swift application

The report design document defines the label. The Swift report application tells the report engine to output multiple labels onto a physical page. This is completed with these C APIs:
Configures the mapping from logical pages to physical pages. For the purpose of creating labels, this will be set to labels.
Sets the top, bottom, left, and right margins of the physical page.
Configures the physical layout of a label page, to include the paper size, the label size, and the number of labels per row and column.

These functions should be included after calling the selectDevice() function but before calling the createContentHandler() function.

This example modifies the OrderReportSwift.swift file, which you can find in the OrderReportSwift demo project, to output labels. The reportDesignFileName would need to specify the report design document for the label.
// Configure the report execution to output a report that is a label
let rcPtr = createRuntimeConfiguration(designFile)
setOutputFileName(rcPtr, outputFilename)
selectDevice (rcPtr, PDF)
configureDistributedProcessing(rcPtr, "", 7000)
guard let content_handler = createContentHandler(rcPtr)

For the full list of available functions, refer to the Genero Report Writer C API documentation.

Figure: Output of labels on a physical page

This figure shows an example of output from a report configured to create Labels.