The sample is named TFORMerSimpleX.c
The default installation location is /usr/local/share/TFORMer/SampleCode. It is installed by the tarball/RPM and generates a Repository-based FormLayout as PDF document.
/*===========================================================================*/ /* Copyright (C) 2006-2009 by */ /* */ /* -- TEC-IT Datenverarbeitung GmbH -- */ /* -- team for engineering and consulting in information technologies -- */ /* */ /* All rights reserved. */ /* */ /* This is a part of the TEC-IT Standard Software. */ /* */ /* This source code is only intended as a supplement to the References */ /* and related electronic documentation provided with the product. */ /* */ /* See these sources for detailed information regarding this product */ /*===========================================================================*/ /*============================================================================= This sample application shows how to use the TFORMer Runtime DLL API Documentation for TFORMer Runtime can be found in /usr/local/share/TFORMer/APIDocs/index.html. ---------------------------------------------------------------------------- History: (2006-05-01) : rebuilt and tested (2009-04-06) : ported to TFORMer 6 =============================================================================*/ /* define TECIT_DLLIMPORT before including TFormer6.h */ #define TECIT_DLLIMPORT /* enable a TFORMer Unix build using the two defines below */ #define _TEC_UNIX #define TEC_UNIX_BUILD /* Set the define according to the UNIX version you are using */ #define TEC_LINUX /* #define TEC_FREEBSD */ /* #define TEC_AIX */ /* #define TEC_HPUX */ /* #define TEC_SOLARIS */ /* #define TEC_OS400 */ /* #define TEC_SCO */ /* include the TECITStd header for required defines */ #include <TECITStd/TECITStd.h> /* include TFORMer6.h */ #include <TFormer6.h> /* undefine defines again as they are only required for TFORMer Header files */ #undef TECIT_DLLIMPORT #undef _TEC_UNIX #undef TEC_UNIX_BUILD /* standard includes */ #include <stdio.h> #include <ctype.h> /*============================================================================= forward declarations =============================================================================*/ void PrintErrorInfo (ERRCODE eCode, HTFORM hTForm); /*============================================================================= defines =============================================================================*/ #define TFORMER_REPOSITORY_PATH "/usr/local/share/TFORMer/Demo Repository/" #define TFORMER_REPOSITORY_FILE "Demos.tfr" #define TFORMER_PROJECT "TFORMer_Runtime_Examples" #define TFORMER_FORM "BarcodeLabels" #define SAMPLE_DATAFILE "importdata.txt" #define SAFE_OP(function) if ((eCode = function) != ErrOk) \ { \ printf(#function " caused Error!\n"); \ PrintErrorInfo (eCode, hTForm); \ if (hTForm) \ TFormer_Exit (hTForm); \ printf ("\nPress any key!"); \ nKey = getchar(); \ return eCode; \ } /*============================================================================= MAIN =============================================================================*/ int main(int argc, char* argv[]) { ERRCODE eCode; HTFORM hTForm = NULL; CHAR szPath[] = TFORMER_REPOSITORY_PATH TFORMER_REPOSITORY_FILE; int nKey; printf ("\n**************************************************************************"); printf ("\nSample Application: Printing Form : " TFORMER_FORM ); printf ("\n located in Project : " TFORMER_PROJECT ); printf ("\n of Repository : " TFORMER_REPOSITORY_FILE ); printf ("\n Programming Language : C++"); printf ("\n"); printf ("\n (c) 2006-2009 TEC-IT Datenverarbeitung GmbH"); printf ("\n www.tec-it.com"); printf ("\n office@tec-it.com"); printf ("\n**************************************************************************"); printf ("\n"); hTForm = TFormer_Init (NULL); if ( hTForm ) { /* ------------------- Repository Settings ------------------------ */ SAFE_OP (TFormer_SetRepositoryName (hTForm, szPath)); /* set the repository */ SAFE_OP (TFormer_SetProjectName (hTForm, TFORMER_PROJECT)); /* and the project */ SAFE_OP (TFormer_SetFormName (hTForm, TFORMER_FORM)); /* and the name of the form */ /* ------------------- Printer Settings --------------------------- */ SAFE_OP (TFormer_SetPrinterType (hTForm, ePrinterType_PDFFile )); /* set the printer type to pdf */ SAFE_OP (TFormer_SetOutputName (hTForm, "TFORMer.pdf" )); /* write to the file TFORMer.pdf */ SAFE_OP (TFormer_SetPrinterName (hTForm, NULL, NULL )); /* use the default printer of the system */ SAFE_OP (TFormer_SetNumberOfCopies (hTForm, 1)); /* set number of copies to be printed */ /* ------------------- Adding New Data Records -------------------- */ SAFE_OP (TFormer_NewRecord (hTForm)); /* add first data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021001")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Sound Blaster Audigy 2")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "175")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add second data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021002")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs X-Fi ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "130")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add third data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021003")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs Live!")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "29")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add fourth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021004")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Griffin Technology iMic ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "30")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add fifth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021005")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "MadDog MultiMedia Predator")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "30")); SAFE_OP (TFormer_NewRecord (hTForm)); /* add sixth data record */ SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleNo", "20021006")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticleName", "Creative Labs PCMCIA ")); SAFE_OP (TFormer_SetVarValue (hTForm, "ArticlePrice", "90")); /* or import the data from a text file (CSV format). SAFE_OP (TFormer_ResetData (hTForm)); SAFE_OP (TFormer_SetTxtDataFile (hTForm, SAMPLE_DATAFILE, ',', '\"')); */ /* ------------------ Start printing ------------------------- */ SAFE_OP (TFormer_Print (hTForm)); /* ------------------- Exit TFORMer -------------------------- */ /* we do not use SAFE_OP here cause we cannot read any Error Information from TFORMer after a call to TFormer_Exit since the hTForm is invalid afterwards */ eCode = TFormer_Exit (hTForm); /* hTForm is not valid anymore after a call to TFORMer_Exit */ hTForm = NULL; /* has Exit caused any error? */ if (eCode != ErrOk) { PrintErrorInfo (eCode, NULL); } else printf ("\nPrint job finished succesfully.\nPress any key!"); nKey = getchar(); } else { printf ("Error: Could not create dll instance.\n"); return ERROR_DLL_INIT_FAILED; } return 0; } /*============================================================================= Prints error information provided by TFORMer dll =============================================================================*/ void PrintErrorInfo (ERRCODE eCode, HTFORM hTForm) { LPCSTR pszErrDesc = NULL; LPCSTR pszErrInfo = NULL; LPCSTR pszErrSource = NULL; printf("ErrorCode: %i\n", eCode ); if (hTForm) { pszErrDesc = TFormer_GetLastErrorDescription (hTForm); pszErrInfo = TFormer_GetLastErrorInformation (hTForm); pszErrSource = TFormer_GetLastErrorSource (hTForm); if (pszErrDesc && pszErrDesc[0]) printf("TFError : %s\n", pszErrDesc); if (pszErrInfo && pszErrInfo[0]) printf("TFInformation : %s\n", pszErrInfo); if (pszErrSource && pszErrSource[0]) printf("TFSource : %s\n", pszErrSource); } }
© 2006-2009 - all rights reserved by TEC-IT Datenverarbeitung GmbH |
![]() |
Generated on Wed Sep 2 16:01:09 2009 for TFORMer Runtime DLL/Shared Library with doxygen 1.5.8 |