Providing Data
Providing Job Data
At runtime, your application supplies values for the data fields used by the form layout. Choose how to provide the job data:
- Imported data file. Import records from a flat text/CSV file or an XML file. Update the file before starting the output job; TFORMer reads the selected data source for printing.
- Configured data source. A form layout or repository can define an XML, text/CSV, or ODBC data source. Each data source has a unique name. Select that name at runtime and TFORMer queries the configured source.
- Direct ODBC input. Provide an ODBC connection string (typically
DSN=...) and an SQLSELECTstatement. A user name and password are optional and are required only when the connection requires them. Returned column names must match the form layout's data-field names; use SQL aliases when they differ. - Programming API. Create records and set data-field values through method or function calls. This in-memory input mechanism is not available through TFPrint.
For examples that create records and set field values in code, see the .NET, native C, Java, and COM basic workflows.
For a practical file-import example, see .NET: Import CSV or XML. For the shared data rules, choose:
- CSV and text files
- XML files
- Data sources defined in a layout
- Copies per record
- Data field handling
- Escape sequences in data field values
ZIP and Base64 Input
When importing XML or CSV job data, you can pass a ZIP filename or BASE64:<encoded-data> instead of the data filename. Encode either the original file bytes or a complete ZIP archive. Use an archive containing one input file with the extension .xml, .csv, or .txt, as appropriate for the selected import method; a raw compressed stream is not a ZIP archive.
This applies to JobDataXml and JobDataCsv in .NET, Java and COM, and to the native functions TFormer_SetXmlDataFile, TFormer_SetXmlDataFileEx (XML input parameter) and TFormer_SetTxtDataFile. It does not imply the same support for XSLT filenames or file parameters of data sources defined in a form layout.
ZIP and Base64 input may use temporary files; passing the contents as a string does not guarantee file-free processing.
Copies per Record
Use a record copy count when individual records require different quantities, for example three labels for one product and one label for another. This is separate from the job-level copy setting.
For records supplied through code, the default is one copy:
| API | Set the copy count for a record |
|---|---|
| .NET | Set Record.NumberOfCopies. |
| Java | Call setNumberOfCopies(...) on the JobDataRecordSet.Record object. |
| COM | Call IJobDataRecordSet.AddNewRecord(), then SetNumberOfCopies(...) for that record. |
For direct CSV, XML or ODBC input, select the input field containing the quantity, for example Quantity. Set RecordCopyDataField on the corresponding job-data object in .NET or COM, or call setRecordCopyDataField(...) in Java. Each record supplies its own count through that field.
For XML, the copy count can also come from an attribute: enable RecordCopyDataFieldIsXMLAttribute in .NET or COM, or call setRecordCopyDataFieldIsXMLAttribute(true) in Java. For internal TFORMer XML, the standard representation is the Copies attribute on each Record element.
For a source defined in the layout, see Set Copies per Record.