using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class OutputSamples
{
Job CreateJobStandAloneForm ()
{
printJob.RepositoryName = "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff";
return printJob;
}
Job CreateJobRepositoryBasedForm ()
{
printJob.RepositoryName = "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Demo Repository/Demos.tfr";
printJob.ProjectName = "TFORMer_Runtime_Examples";
printJob.FormName = "BarcodeLabels";
return printJob;
}
void CsvDataSample ()
{
printJob.JobData = jobData;
printJob.OutputName = "/temp/out.pdf";
printJob.Print ();
}
void OdbcDataSample ()
{
printJob.RepositoryName = "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff";
JobData jobData =
new JobDataOdbc(
"DSN=TFORMer_Sample",
"",
"",
"SELECT FROM tbl_Example");
printJob.JobData = jobData;
printJob.OutputName = "/temp/out.pdf";
printJob.Print ();
}
void DataSourceDataSample ()
{
printJob.RepositoryName = "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/8/Templates/(6) Samples_Picking List.tff";
jobData.ParameterValues.Add ("PickingListParameter", "2");
printJob.JobData = jobData;
printJob.OutputName = "/temp/out.pdf";
}
void UseRecordSetData (
Job printJob)
{
record.
Data.Add(
"ArticleName",
"Speaker System HF1");
record.
Data.Add(
"ArticleNo",
"12001234");
record.
Data.Add(
"ArticlePrice",
"498.98");
record.NumberOfCopies = 2;
record.
Data.Add(
"ArticleName",
"Record Box 12 CDs");
record.
Data.Add(
"ArticleNo",
"12021231");
record.
Data.Add(
"ArticlePrice",
"8.85");
printJob.JobData = jobData;
}
void UseCsvData (
Job printJob)
{
printJob.JobData = jobData;
}
void UseXmlData (
Job printJob)
{
printJob.JobData = jobData;
}
void UseOdbcData (
Job printJob)
{
"DSN=TFORMer_Sample",
"",
"",
"SELECT * FROM tbl_Example"
);
printJob.JobData = jobData;
}
void UseOdbcDataSetDsn (
Job printJob)
{
jobDataOdbc.Dsn = "DSN=TFORMer_Sample";
printJob.JobData = jobDataOdbc;
}
void UseDataSourceData (
Job printJob)
{
jobData.ParameterValues.Add ("parFile", "/YourPath/InputData.txt");
printJob.JobData = jobData;
}
{
{
{
Console.WriteLine(field.Name);
}
}
}
void PrintToPrinter (
Job printJob)
{
printJob.PrinterName = null;
}
void PrintToPdf (
Job printJob)
{
printJob.OutputName = "/temp/out.pdf";
}
void SetPrinterTypePdf (
Job printJob)
{
printJob.PrinterName = "PDFFILE:/temp/out.pdf";
printJob.OutputName = "/temp/out.pdf";
}
void PrintToStream(
Job printJob)
{
using (FileStream streamOut = new FileStream("/temp/out.pdf", FileMode.Create))
{
printJob.PrintToStream (streamOut);
}
}
Stream CreateStream (string sName)
{
Stream stream = new FileStream (sName, FileMode.Create);
return stream;
}
void CloseStream(Stream stream)
{
stream.Close ();
}
void PrintToStreams(
Job printJob)
{
printJob.OutputName = "StreamToFileExample.png";
printJob.PrintToStreams (CreateStream, CloseStream);
}
static void Main(string[] args)
{
OutputSamples sample = new OutputSamples();
Console.WriteLine("Create Job for stand-alone FormLayout ...");
Job printJob = sample.CreateJobStandAloneForm();
try {
Console.WriteLine("Iterate used fields ...");
Console.WriteLine("Import data from ODBC ...");
sample.UseOdbcData (printJob);
Console.WriteLine("Print to default printer ...");
sample.PrintToPrinter (printJob);
Console.WriteLine("Use Stream API ...");
sample.PrintToStreams (printJob);
}
Console.WriteLine("Error");
}
finally {
printJob.Dispose ();
printJob = null;
}
Console.WriteLine();
Console.WriteLine ("Create Job for Repository based FormLayout ...");
printJob = sample.CreateJobRepositoryBasedForm();
try
{
Console.WriteLine ("Set some data ...");
sample.UseRecordSetData(printJob);
Console.WriteLine ("Generate PDF ...");
sample.PrintToPdf(printJob);
}
{
Console.WriteLine ("Error");
}
finally
{
printJob.Dispose();
printJob = null;
}
}
}
Provides access to DataField information.
Definition: DataField.cs:57
DataField Next
Gets the next DataField defined in the Project.
Definition: DataField.cs:416
Provides access to JobDataCsv (a CSV-file that serves as JobData for a Job).
Definition: JobDataCsv.cs:20
Provides access to a user-defined DataSource, which is defined in the FormLayout or a Repository.
Definition: JobDataDataSource.cs:18
Abstract base class for JobData.
Definition: JobData.cs:18
Provides access to JobDataOdbc (an ODBC connection that serves as JobData for a Job).
Definition: JobDataOdbc.cs:20
Provides access to JobDataRecordSet (a set of in-memory Record objects which serves as JobData for a ...
Definition: JobDataRecordSet.cs:18
List< Record > Records
Gets/Sets the list of Records.
Definition: JobDataRecordSet.cs:31
Provides access to JobDataXml (a XML file that serves as JobData for a Job).
Definition: JobDataXml.cs:20
This is the main class of TFORMer SDK for generating output.
Definition: Job.cs:266
string RepositoryName
Gets/Sets the filename of the Repository or the filename of the stand-alone FormLayout for this Job.
Definition: Job.cs:456
void Print()
Prints the Job using the selected FormLayout and the current JobData.
Definition: Job.cs:886
Provides access to Project information of a Repository or a stand-alone link FormLayout.
Definition: Project.cs:22
FormLayout FirstFormLayout
Gets the first FormLayout of the Project.
Definition: Project.cs:295
DataField FirstDataField
Gets the first DataField of the Project.
Definition: Project.cs:215
Provides access to a Record.
Definition: JobDataRecordSet.cs:66
Dictionary< string, string > Data
Gets/Sets the values for the Record.
Definition: JobDataRecordSet.cs:92
Opens or creates a Repository, opens a stand-alone FormLayout.
Definition: Repository.cs:24
Project GlobalProject
Gets the global Project of the Repository.
Definition: Repository.cs:478
Exceptions thrown by TFORMer SDK.
Definition: TFormerException.cs:17
Provides methods to query status information and to license TFORMer SDK.
Definition: TFormer.cs:81
static void License(string licensee, LicenseKind kind, int numberOfLicenses, string key)
Applies a license to this instance of the TFORMer SDK.
Definition: TFormer.cs:119
PrinterType
This enumeration specifies the type of output generated by TFORMer SDK.
Definition: Job.cs:26
DataFieldUsage
Describes the usage of a DataField within a FormLayout.
Definition: FormLayout.cs:15
LicenseKind
The license types for the TFORMer SDK.
Definition: TFormer.cs:24