Retrieving Data Fields Used in a Layout (TFORMer. NET API)

Data fields in a repository

Repository repository = new Repository ("C:\\Path\\Labels.tfr", false, false);
Project project = repository.GetProject("BarcodeLabels");
FormLayout formlayout = project.GetFormLayout("Label1");
 
// iterate through all DataFields in the project
for (DataField field = project.FirstDataField; field != null; field = field.Next)
{
// check if the DataField is used in the FormLayout
DataFieldUsage usage = formlayout.GetDataFieldUsage(field.Name);

  if (usage == DataFieldUsage.Normal)
  {
    // DataField used in the FormLayout
  }
}

Data fields in a TFF

// create a Repository-instance using a stand-alone FormLayout
Repository repo = new Repository("C:\\Path\\Label.tff", false, false);

// retrieves the global project
Project project = repo.GlobalProject;

// retrieves the one and only FormLayout (stand-alone form)
FormLayout formlayout = project.FirstFormLayout;

// retrieving the data fields:
// use the same code as with the repository (see above)

How Can I Adjust the Number of Copies for a Record Set?

TFORMer .NET

// record set data source 
DataSourceRecordSet recordSet = new DataSourceRecordSet(); 
Record record = new Record(); 
record.NumberOfCopies = 10; 
recordSet.Records.Add(record);

// CSV, ODBC and other data sources
DataSourceCsv dsCsv = new DataSourceCsv(csvFile, ',', '"'); 
Job printJob = new TECIT.TFORMer.Job(); 
printJob.DataSource = dsCsv; 
printJob.RecordCopyDataField = "Copies"; 

How Can I Import a CSV File via Program Code?

The following sample code shows how to use CSV import with a CSV data source defined in the TFF layout file (using TFORMer Designer). For more flexibility it has been configured with a parameter, which specifies the file path: parFilePath

TFORMer Java API

// create new job
job = new Job();

File file = new File ("c:\\Temp\\MyTemplate.tff");
job.setRepositoryName(file.getAbsolutePath());

// Select the Data Source named 'ImportFromCSV' (defined in the Form Layout)
JobDataDataSource jobData = new JobDataDataSource ("ImportFromCSV");

// Set the Data Source Parameter named 'parFilePath'
jobData.setParameterValues ("parFilePath", "C:\\Temp\\myImportFile.csv");   

// Set the output format:
// e.g. EPrinterType.PDFFile, EPrinterType.ZPLFile, EPrinterType.ImagePng
job.setPrinterType(EPrinterType.PDFFile);

// Output file name
job.setOutputName(System.getProperty("user.dir") + File.separator + "MyLabel.PDF");
System.out.println("Printing to " + job.getOutputName());

// Generate Output
 job.setJobData(jobData);
job.print();
The advantage with using a data source defined in the layout: The data source definition may contain the mapping between import fields and layout fields, in addition you can add calculated fields (on demand). Optional data source parameters give you the flexibility for programming or command line interaction.

How Can I Set the Resolution for a Zebra Printer?

Beside changing the resolution for Zebra (ZPL II) printers directly in the Designer (print dialog), you can adjust it also for the SDK or Quickprint as shown below.

The DPI can be permanently set / changed in the TFORMer.xml configuration file (per user and per system).

Location of TFORMer.xml on Microsoft Windows

  • The default (system-wide) TFORMer.xml resides in the directory
    C:\ProgramData\TEC-IT\TFORMer\8
  • In addition, TFORMer supports user specific files which override the default. TFORMer Designer creates this file automatically in a user specific folder:
    C:\Users\**USERNAME**\AppData\Local\TEC-IT\TFORMer\8

Editing the TFORMer.xml

  • Locate the <ZEBRA> node and edit the resolution attribute, which specifies the DPI of the Zebra printer.
  • After saving the file, restart your SDK application (e.g. Quickprint) to read in the new settings.

For further information, see Appendix C: Configuration File TFORMer.xml in the TFORMer Developer Manual.

SDK Option

  • In case you don't want to change the resolution permanently, you can change it also dynamically by program code (or command line) with the following SDK option: resolution=300

How Can I Change the Barcode Draw Mode to Quality?

In some cases you want to change the bar code draw mode for trouble shooting enlarged bars on thermal transfer printers like Printronix T4M or Zebra.

Beside changing the draw mode in the Designer print dialog (Options button), you can adjust it also for the SDK or Quickprint in the TFORMer.xml configuration file on a per user or system basis.

Location of TFORMer.xml on Microsoft Windows

  • The default (system-wide) TFORMer.xml resides in the directory
    C:\ProgramData\TEC-IT\TFORMer\8
  • In addition, TFORMer Designer maintains a user specific file which overrides the default file. This file is created in the user specific folder:
    C:\Users\**USERNAME**\AppData\Local\TEC-IT\TFORMer\8
  • If you deliver a local configuration file along with your application (EXE), it takes precedence over the standard files in the user or program data directories.

Changing the GDI Draw Mode to 'Quality'

  • Open the TFORMer.xml configuration file(s) as indicated above.
  • Locate the <WINGDI><TBARCODE> node.
  • Change the drawing-mode attribute to “2” <TBARCODE drawing-mode="2" />
  • After saving the file, restart your SDK application (e.g. Quickprint) to read in the new settings.

SDK Option

  • In case you don't want to change the drawing mode permanently, you can change it also dynamically by program code (or command line) with the following SDK option: tbarcode-drawing-mode=quality

TFORMer SDK Has a Different Label Size than the Designer

That's because the DLL reads the Default Settings found in the Advanced tab, the Designer reads the Printing Preferences found in the General tab of the printer properties (driver settings).

Solution: Adjust the General Settings of the printer driver in a way that it has the same values as the Default Settings of TFORMer SDK or vice versa.

Licensing TFORMER SDK in MS-IE Through LPK File

LPK licensing is not supported in TFORMer V4.5, V5.0, V6.0. If required, please contact us!

How Can I Print a TFORMer Report with Python?

For printing a TFORMer report with Python you can use the following script as example:

 from ctypes import *

 FormFile     = "c:/pathto/formfile.tff"
 DataFile     = "c:/pathto/importdata.csv"

 TF_dll = oledll.LoadLibrary("TFormer60.dll")

 TF_dll.TFormer_LicenseMe("Your Licensee Name ", 4, 1,"Your Key" )
 htform =  TF_dll.TFormer_Init(0)
 rm = TF_dll.TFormer_SetRepositoryName(htform, FormFile)
 rm = TF_dll.TFormer_ResetData(htform)
 rm = TF_dll.TFormer_SetTxtDataFile(htform, DataFile, c_char(","), c_char(" "))
 rm = TF_dll.TFormer_SetCopies(htform,1)
 rm = TF_dll.TFormer_SetStartPosition(htform, 1, 0)
 rm = TF_dll.TFormer_SetPrinter(htform, "", 0)
 rm = TF_dll.TFormer_PrintForm(htform)

print 'finished'

DllNotFoundException (0x800703E6), Could Not Load DLL "TFormer75x64.dll"

Problem (.NET API): One of the required dependencies is missing or could not be found.

Search Order for Dependencies:

  • Local path of assembly
  • Path of executable
  • Path contained in PATH environment variable

Make sure that the TFORMer DLLs (see section deployment and distribution in the developer manual) are in one of these locations.

Using TFORMer .NET in a Web Application (IIS)

There are two possibilities:

  • Install as local assembly (no GAC): Copy all TFORMer files into the bin sub folder of your web application - you need the TFORMer Assembly + dependency DLLs + TFORMer.xml. Make sure that there is no TFORMer Assembly installed in the GAC: Uninstall TFORMer SDK setup if already installed. Restart IIS application pool(s) to reload the assemblies. Afterwards all DLLs should be found.
  • Install as global assembly (GAC): Use our TFORMer SDK setup, which installs TFORMer .NET in the GAC and extends the PATH environment variable so that all dependencies are found. Note that updating the PATH environment variable may require an IIS restart (iisreset on admin console) or a system reboot, otherwise the DLLs are still not found.
If you don't use our setup make sure that the Visual Studio Runtime Libraries are installed (the required Runtime Version depends on the TFORMer Release - see developer manual).

Exception: Required Permissions Cannot Be Acquired

If you run your application from a network location (UNC path) you may get the above exception when your application tries to load the native compiled TFORMer DLLs.

This is an issue with the .NET Framework's trust level settings on your local machine. The default trust level for the local machine is "Full Trust", whereas for the network share it is not.

Either install the TFORMer SDK on the local workstation(s) and avoid loading them from a network path - or lower the security settings on your machine(s). You can give a specific network path full trust with the Caspol command (for details see the Caspol documentation from Microsoft). The following command would give the local intranet zone full trust (not recommended):

Caspol –m –cg LocalIntranet_Zone FullTrust

Programming TFORMer5 COM (Visual C/C++, ODBC)

TFORMer5 COM with Visual C/C++ 6 MFC

ITFORMer* tf = new ITFORMer ();
tf->CreateDispatch("TFORMer5Lib.TFormer");

IJob job = tf->CreateJob (); 

job.SetRepositoryName ("C:/../Repository/Demos.tfr");
job.SetProjectName("TFORMer_Runtime_Examples");
job.SetFormName("BarcodeLabels");
job.SetPrinterName("pdffile:c:\\testit.pdf");

IDataSourceRecordSet records = job.NewDataSourceRecordSet();
records.AddNewRecord();
records.SetDataField("ArticleName", "Mac Adapter");
records.SetDataField("ArticleNo", "12001234");
records.SetDataField("ArticlePrice", "39,00");

job.PrintForm();

tf->DetachDispatch();

ODBC with TFORMer COM

Dim tf As TFORMer5Lib.TFormer
Dim printjob As TFORMer5Lib.IJob
Dim datasource As TFORMer5Lib.IDataSourceOdbc

Dim dsn
Dim uid
Dim password
Dim sql

dsn = "DSN=TFORMer_Sample"
uid = ""
password = ""
sql = "SELECT * FROM tbl_Example;"

Set tf = CreateObject("TFORMer5Lib.TFormer")
Set printjob = tf.CreateJob

printjob.RepositoryName = "R:\ODBCTest\TFORMer1.tff"
Set datasource = 
printjob.NewDataSourceOdbc(dsn, uid, password, sql)

printjob.PrinterName = "PDF:R:\ODBCTest\out.pdf"
printjob.PrintForm

TFORMer5 Can't Use JPEG Images via HTTP-Link

When TFORMer Layouts use images which are loaded from an external http-source the user must take care that the link is using a correct file extension.

For example:

Wrong URL: BaseUrl + Thumbnail?file=label-me
Correct URL: BaseUrl + Thumbnail?file=label-me.jpg