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:
selectLogicalPageMapping()
- Configures the mapping from logical pages to physical pages. For the purpose of
creating labels, this will be set to
labels
. setPaperMargins()
- Sets the top, bottom, left, and right margins of the physical page.
configureLabelOutput()
- 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.
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)
selectLogicalPageMapping(rcPtr,labels)
setPaperMargins(rcPtr,"5mm","5mm","4mm","4mm")
configureLabelOutput(rcPtr,"a4width","a4length",nil,nil,2,6)
configureDistributedProcessing(rcPtr, "127.0.0.1", 7000)
guard let content_handler = createContentHandler(rcPtr)
For the full list of available functions, refer to the Genero Report Writer C API documentation.