Install
TFORMer Designer and
TFORMer Runtime using the setup application. Besides
TFORMer Designer (the graphical layout editor) the setup-application installs
TFORMer Runtime.
TFORMer Runtime is available as DLL, as COM component, as .NET assembly and as stand-alone application (
tfprint
). Both the COM component and the .NET assembly of
TFORMer Runtime are registered automatically.
During the installation procedure, the Java package
JTFORMer60.jar is copied into the Bin directory: it includes all classes that you need to create a TFORMer application with the Java language.
- Note:
- The JAR file is compatible with version 1.5 and higher of the Java Runtime Edition (JRE).
Use
TFORMer Designer to create a FormLayout graphically.
In most cases your FormLayout contains dynamic data which is provided by your application during print-time (e.g. an article number for a product label or a ticket-number for an eTicket).
TFORMer uses DataFields as place-holders for such dynamic data. These DataFields are declared as well as used within the FormLayout.
For testing purposes
TFORMer Designer allows you to provide values for such DataFields manually or to import them from files or data-bases. Testing a FormLayout can therefore be done without any line of code.
Depending on your application choose between using stand-alone FormLayouts or Repository-based FormLayouts:
- Stand-Alone Form Layouts
A stand-alone FormLayout can be used on its own (TFORMer Designer creates stand-alone FormLayouts by default). Such a FormLayout contains all the necessary information which is required for printing (layout information, DataField definitions, JobTrayControl). - Repository-based Form Layouts
If you prefer to organize your FormLayouts and DataFields in a structured way or if you plan to create multiple form layouts which use the same data basis (same data-fields) the use of a so-called Repository is recommended. A Repository is a central database for FormLayouts, DataField definitions and JobTrayControl-settings. Form layouts and DataField definitions are stored within a Repository on a per Project base. A Project defines DataFields and holds (better: refers) FormLayouts. Each of the DataFields defined in a Project is accessible within every FormLayout contained in that Project. A Repository can contain multiple Projects and one special global Project. DataFields defined within the global Project may be used by all FormLayouts in all Projects.
Create a new Java project or at least a new Java source file.
Link your application with the JTFORMer60.jar (the TFORMer package).
To do so, either use the classpath list in your IDE or use java -cp %CLASSPATH%
For creating a Java program with the TFORMer Java API, you need to import a few TFORMer Packages:
import com.tecit.TFORMer.*;
import com.tecit.TFORMer.Repository.*;
import com.tecit.TFORMer.Printing.*;
Licensing is not required for evaluation purposes. For production use it is recommended to apply a license key to TFORMer Runtime before using any other properties or methods of TFORMer. This needs to be done only once, for example when initializing the application.
TFORMer.license("John Doe", LicenseKind.Workstation, 1, "00000000000000000000000000000000");
Printing is done with the help of a print job. Create a job and select the FormLayout by setting the appropriate properties:
When you use a stand-alone FormLayout:
Job printJob = new Job();
printJob.setRepositoryName("MyPath\\myFormLayout.tff");
A repository-based FormLayout requires two more properties to be set:
Job printJob = new Job();
printJob.setRepositoryName ("MyPath\\myRepository.tfr");
printJob.setProjectName ("MyProject");
printJob.setFormName ("MyForm");
A mentioned above a FormLayout usually contains DataFields which are used as place holders for dynamic data. Before printing a FormLayout you need to provide data for these DataFields. The required data is passed to
TFORMer using different methods:
This is the most direct method to pass data to TFORMer Runtime. In this case the developer provides names and values for the DataFields used in a FormLayout directly. The example below sets the values for the DataFields ArticleNo, ArticleName and ArticlePrice:
JobDataRecordSet myData = new JobDataRecordSet();
Record record = new JobDataRecordSet.Record();
record.setData("ArticleName", "Speaker System HF1");
record.setData("ArticleNo", "12001234");
record.setData("ArticlePrice", "498.98");
myData.add(record);
record = new JobDataRecordSet.Record();
record.setNumberOfCopies(2);
record.setData("ArticleName", "Record Box 12 CDs");
record.setData("ArticleNo", "12021231");
record.setData("ArticlePrice", "8.85");
myData.add(record);
- Note:
- TFORMer Runtime is able to import data from text files, XML-files and from a database (ODBC).
You can load data either from XML or CSV/TXT files:
JobDataCsv jobData = new JobDataCsv("path\\data.csv", ',', '"');
JobDataXml jobData = new JobDataXml("path\\data.xml");
Using the setPrinterName method you may specify the system printer to be printed to. Provide an empty string, if you want to send the output to the default printer.
printJob.setJobData(myData);
printJob.setPrinterName("YourPrinterName");
printJob.print();
Instead of sending the form directly to a printer, you can export the output as a PDF, PostScript, HTML, ASCII or image file. ZPL-II generation is supported too (the ZEBRA printer language). The procedure is the same as printing the form � but instead of setting a printer name, set the name and type of the output file:
printJob.setJobData (myData);
printJob.setOutputName ("C:\\temp\\myForm.pdf");
printJob.setPrinterType (EPrinterType.PDFFile);
printJob.print();
The Java package invokes the API of
TFORMer runtime via Java Native Interface (JNI). In order to free the resources allocated by
TFORMer Runtime, it's important to call the method
dispose
of the JTFormer classes.
For this reason, you should
always add the following code:
- Note:
- It's recommended to insert the source code that uses the
Job
instance into a try/catch
block and insert the dispose procedure into the finally
block. This tip helps you to dispose the instances even in case of exceptions. Job printJob = new Job();
try {
}
catch(TFormerException ex){
}
finally {
printJob.dispose();
printJob = null;
}