Concepts - Printing


Preparation

Install TFORMer Designer (the graphical layout editor) and TFORMer SDK (the reporting and label printing core) using the setup applications. TFORMer SDK is available as DLL, as COM component, as .NET assembly, as JAVA class and as stand-alone application (TFPrint). Both the COM component and the .NET assembly of TFORMer SDK are registered automatically. The .NET assembly is automatically placed in the GAC and in the Bin directory of the installation folder.

Design and Test a Form Layout

Use TFORMer Designer to create a form layout graphically.

Most likely a form layout contains dynamic data which will be 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 data fields as place-holders for such dynamic data. These data fields are declared as well as used within the form layout.

For testing purposes TFORMer Designer allows you to provide values for such data fields manually or to import them from files or data-bases. Testing a form layout can therefore be done without any line of code.

Depending on your application choose between using stand-alone form layouts or repository-based form layouts:

Stand-Alone Form Layouts

A stand-alone form layout can be used on its own (TFORMer Designer creates stand-alone form layouts with the file extension *.tff by default). Such a form layout contains all the necessary information which is required for printing (layout information, data field definitions, JobTrayControl, data source definitions).

Repository-based Form Layouts

If you prefer to organize your form layouts and data fields in a structured way or if you plan to create multiple form layouts which use the same data basis (e.g. same data field definitions), the use of a so-called repository is recommended. A repository is a central database for form layouts, data field definitions, job/tray control settings and data source definitions. A repository is a central database for form layouts, data field definitions, JobTrayControl-settings and data source definitions. Form layouts, data field- and data source- definitions are stored within a repository on a per "project" base. A project defines data fields, data sources and holds (better: refers) form layouts. Each of the data fields defined in a project is accessible within every form layout contained in that project. A repository can contain multiple projects and one special global project. Data fields defined within the global project may be used by all form layouts in all projects. A repository uses the file extension *.tfr.

Create a .NET Project

Create a new .NET based project. In Visual Studio right-click on your project in the Solution Explorer window and select Add Reference. Open the .NET tab and select TFORMer 7.0 SDK. Alternatively open the Browse tab and select the TFORMer .NET assembly called TECIT.TFORMer.dll.

Add the namespace TECIT.TFORMer in each source file that uses TFORMer SDK:

using TECIT.TFORMer;

License TFORMer SDK

Licensing is not required for evaluation purposes. For production use it is a must to apply a license key to TFORMer SDK 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");

Select the Form Layout to be Used

Printing is done with the help of a print job. Create a job and select the form layout by setting the appropriate properties:

When you use a stand-alone form layout:

Job printJob = new Job();
printJob.RepositoryName = @"MyPath\myFormLayout.tff";

A repository-based form layout requires two more properties (for the name of the project and the name of the form layout) to be set:

Job printJob = new Job();
printJob.RepositoryName = @"MyPath\myRepository.tfr";
printJob.ProjectName = "MyProject";
printJob.FormName = "MyForm";

Note: See Methods for Passing Files for additional methods for passing a form layout or a repository to TFORMer SDK.

Provide Dynamic Data

As mentioned above a form layout usually contains data fields which are used as place holders for dynamic data. Before printing a form layout you need to provide data for these data fields. The required data can be passed to TFORMer using different methods:

Pass Data via Program Code

This is the most direct method to pass data to TFORMer SDK. In this case the developer provides names and values for the data fields used in a form layout directly. The example below sets the values for the data fields ArticleNo, ArticleName and ArticlePrice:

// Supply some record sets
JobDataRecordSet myData = new JobDataRecordSet();

myData.Records.Add(new Record());
myData.Records[0].Data.Add("ArticleName", "Speaker System HF1");
myData.Records[0].Data.Add("ArticleNo", "12001234");
myData.Records[0].Data.Add("ArticlePrice", "498.98");

myData.Records.Add(new Record());
myData.Records[1].NumberOfCopies = 2;
myData.Records[1].Data.Add("ArticleName", "Record Box 12 CDs");
myData.Records[1].Data.Add("ArticleNo", "12021231");
myData.Records[1].Data.Add("ArticlePrice", "8.85");

Load Data from Files or Databases

TFORMer SDK is able to import data from text-/XML-files or from a database (ODBC). The filenames, DSNs or SQL-SELECT statements are specified directly. Take care, that the field names available in the data source (e.g. the column names returned by a SQL-SELECT statement) are equal to the names of the data fields used in a form layout.

Load Data from Files:

You can load data either from XML or CSV/TXT files:

// load a XML file
JobDataXml myData1 = new JobDataXml(@"path\data.xml");

// load a CSV file
JobDataCsv myData2 = new JobDataCsv(@"path\data.csv", ',', '"');

Load Data from Database:

You can load data from an ODBC database:

// load data via an ODBC connection
JobDataOdbc myData3 = new JobDataOdbc("DSN ", "Username", "Password", "SQL select statement");

Load Data from a User-Defined Data Source

Data sources can also be defined by the user with TFORMer Designer as part of a form layout. Such a data source defines how data is retrieved (e.g. from an ODBC database), the field-mappings and optional data source parameters. If you want to use such a data source, select it by name as shown below. Use optional data source parameters to control certain aspects during runtime (e.g. filenames, SQL statement or an ODBC-DSN).

// retrieve data using the predefined data source myTextDataSource
JobDataDataSource myData4 = new JobDataDataSource("myTextDataSource");

// set the value of the user-defined data source parameter parFile (defined in myTextDataSource)
myData4.ParameterValues.Add("parFile", "/YourPath/InputData.txt");

Methods for Passing Files

If properties are requesting filenames (e.g. form layouts or file-based data sources (like XML or CSV)), these may be passed in the following ways:
Note: BASE64 encoded strings must start with the sequence BASE64:. When passing a zipped file TFORMer expects a real WinZip compatible format. A zipped stream is not suitable! For more details please refer to TFORMer Developer Manual.
 

Print or Export the Form Layout (Printer, PDF, PostScript, HTML, ...)

Print the Form Layout on a Printer

Using the PrinterName property 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.

// Set the JobData that contains the data to be printed:
printJob.JobData = myData;

// Select the printer:
printJob.PrinterName = "YourPrinterName";

// Print the form:
printJob.Print();

Export as PDF, PostScript, HTML, ZPL-II or as an Image

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.

// Set the JobData that contains the data to be printed:
printJob.JobData = myData;

// Select the output file and type:
printJob.OutputName = @"C:\temp\myForm.pdf";
printJob.PrinterType = TECIT.TFORMer.PrinterType.PdfFile;

// Print the form:
printJob.Print();

Generate Output as an In-Memory Stream

Starting with TFORMer version 7 it is possible to generate the output as an in-memory stream. No output or temporary files are required, the performance for creating the output is dramatically improved. Currently PDF- and image-output (excluding multi-page TIFF) are generated completely in-memory. If the output results in a single stream (this is true for Postscript, PDF, multi-page TIFF and ZPL output) use . If the generated output results in several streams (e.g. generating multiple labels as single PNG images) use . For a brief description and a sample, please refer to and .


© 1998-2012
TEC-IT Datenverarbeitung GmbH
Hans-Wagner-Strasse 6
A-4400 Austria
t +43 (0)7252 72720
f +43 (0)7252 72720 77
http://www.tec-it.com
office@tec-it.com