T168_Debug222\appl\Barcode\Two\MPDF文件:PDFAPI.C

/*********************************************************************
* Module Header
*
*  Identification:   PDFAPI - PDF Encoder Library Entry Points
*  Copyright (c) 1993-1997 Symbol Technologies, Inc.
*
* Edit History:      
*  $Log: PDFAPI.C $
*  Revision 1.10  1997/12/19 23:33:38  Anne
*  Added function  to disable Macro Character Substitution 
*  feature of MicroPDF, and default value of FALSE for the new field which
*  holds that information.
*  Revision 1.9  1997/11/27 00:50:06  Anne
*  Bumped rev to 2.37 - last rev released was 2.34 
*  Revision 1.8  1997/11/25 18:15:50  Anne
*  Added enum for default code  128 emulation mode of emulation off.
*  Added function to set the code 128 emulation mode.
*  Added line to PDFSet Defaults to set the code 128 emulation mode.
*  Added undocumented function to GetMicroPDFCodewords for testing
*  Removed include for micropdf.h - its contents are now in pdfapi.h
*  Revision 1.7  1997/08/14 20:12:06  toml
*  Bump rev number to 2.36
*  Revision 1.6  1997/06/12 20:27:36  toml
*  Bumped version tag to 2.35 for microPDF 4x4 size addition
*  Revision 1.5  1997/04/30 19:17:20  toml
*  Updated rev to 2.34: See PDFOBJ.C (32 bit macro encode bug)
*  Revision 1.4  1997/04/29 19:35:14  toml
*  Bumped rev to 2.33 for ECI format encoder error (see ENCDATA)
*  Revision 1.3  1997/04/23 18:43:22  toml
*  Added PDFECIEncode API routine
*  Revision 1.2  1997/04/18 19:38:06  toml
*  Bump minor rev number for change to MicroPDF. Also, change
*  data codeword detail count since change to MicroPDF was the
*  removal of the symbol length descriptor codeword
*  Revision 1.1  1997/02/19 22:28:48  toml
*  Initial revision
*
*  Description:       Encoder API entry points.
*
*  Call Tree:         
*
**********************************************************************/

/*********************************************************************
                                 Include Files
*********************************************************************/
/* #include <stdio.h>    */
#include "pdfapi.h"
#include "apienc.h"
#include "pdfobj.h"
#include "ecc.h"
#include "memfunc.h"
#include "tcmap.h"
#include "session.h"

/*lint -library  :Main library module with unreferenced functions */
/*********************************************************************
                                 Local Defines
*********************************************************************/
#define  DEF_ROWS          90
#define  DEF_COLS          30
#define  DEF_DIMTYPE       USE_LIMITS
#define  DEF_ASPECT        50    /* 0.50 or 1:2 */
#define  DEF_MODULEHEIGHT  3
#define  DEF_MODULEWIDTH   1
#define  DEF_ECCLEVEL      0
#define  DEF_ECCPERCENT    10
#define  DEF_ISECCFIXED    FALSE
#define  DEF_SYMTYPE       STYLE_MICRO 
#define  DEF_C128EMULATION PDF128_EMUL_OFF 
#define  DEF_MACROCHAR_SUB FALSE   /* field is disable_macro_char_sub - default is enabled */ 
#define  DEF_ISBINARYONLY  FALSE
#define  DEF_OUTFILTER     PDFNullFormatter
#define  DEF_LPARAM        0L
#define  DEF_WPARAM        0
#define  DEF_PADWITHECC    TRUE
#define  DEF_MICRO_SIZE    0
#define  DEF_MICRO_ECC     0

#define  GetMicroRow( opt )         ( abMicroRowMap[ opt ] )
#define  GetMicroCol( opt )         ( abMicroColMap[ opt ] )

/*********************************************************************
                                  Global Data
*********************************************************************/
PDFSTATUS PDFAPI PDFNullFormatter( int16 nCmd, LPPDFObject lpObj, LPVOID lpGeneric, uint32 l, uint16 w);
#define  VER_MAJOR      2
#define  VER_MINOR      38

/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 static const uint16 g_nVersion = (uint16)((VER_MAJOR << 8) + VER_MINOR);                */
/* // 98.04.14                                                     */
/* // 98.04.14 static const char g_aszCopyright[] = "\                                */
/* // 98.04.14 Copyright (c) Symbol Technologies, Inc. 1993-1997. All rights reserved.";            */
/* // 98.04.14                                                     */
/* // 98.04.14 static const char g_aszTimestamp[] = __DATE__ " - " __TIME__;                    */
/* // 98.04.14 #endif                                                */

const char g_acDigitsStr[17] = "0123456789ABCDEF";

#ifndef NO_MICROPDF
const uint16 abMicroRowMap[ MICRO_INDEXCOUNT ] = {
   11,14,17,20,24,28,8,11,14,17,20,23,26,6,8,10,12,15,20,26,32,38,44,
   6,8,10,12,15,20,26,32,38,44,4
};
const uint16 abMicroColMap[ MICRO_INDEXCOUNT ] = {
   1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4
};
const uint16 anMicroECCMap[ MICRO_INDEXCOUNT ] = {
   0,0,0,1,1,1,1,2,2,3,4,6,8,5,7,9,10,11,12,13,14,15,16,5,7,9,10,11,12,
   13,14,15,16,1
};
#endif
/*
* For static library, initialize all encode session settings at loadtime
*/
#if (LIBTYPE == PDF_L_STATIC)
/*lint -e785 :We don't initialize all memebers */
AppParamsRec g_recAppParams;
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14  = {                                                */
/* // 98.04.14    DEF_ROWS, DEF_COLS,                                        */
/* // 98.04.14    DEF_DIMTYPE,                                            */
/* // 98.04.14    DEF_ASPECT,                                            */
/* // 98.04.14    DEF_MODULEHEIGHT, DEF_MODULEWIDTH,                                */
/* // 98.04.14    DEF_ISECCFIXED,                                        */
/* // 98.04.14    DEF_PADWITHECC,                                        */
/* // 98.04.14    DEF_ECCLEVEL,                                            */
/* // 98.04.14    DEF_ECCPERCENT,                                        */
/* // 98.04.14    DEF_SYMTYPE,                                             */
/* // 98.04.14    DEF_C128EMULATION,                                         */
/* // 98.04.14    DEF_MACROCHAR_SUB,   */ /* is macro character substitution disabled -> no */
/* // 98.04.14    DEF_ISBINARYONLY,                                        */
/* // 98.04.14    FALSE,               */ /* is encode active - no */
/* // 98.04.14    DEF_OUTFILTER,                                        */
/* // 98.04.14    DEF_LPARAM, DEF_WPARAM,                                    */
/* // 98.04.14    DEF_MICRO_SIZE, DEF_MICRO_ECC,                                */
/* // 98.04.14    (LPCWRec)0,                                            */
/* // 98.04.14    (struct s_mpdfrec FAR *)0,                                    */
/* // 98.04.14 };                                                */
/* // 98.04.14 #endif                                                */
/*lint -restore */
#endif /* LIBTYPE */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      NullOutputFilter
*
* Description:       Default output formatter installed for 
*                    PDFSetDefaults().
*
*  Returns:          Returns zero.
*
**********************************************************************/
PDFSTATUS PDFAPI PDFNullFormatter( int16 nCmd, LPPDFObject lpObj, LPVOID lpGeneric, uint32 l, uint16 w)
{
   PDFSTATUS nStatus;
/* // 98.04.14 #ifdef _lint                        */
/* // 98.04.14    lpObj=lpObj, lpGeneric=lpGeneric, l=l, w=w;        */
/* // 98.04.14 #endif                            */
   switch( nCmd ) {
      case DRIVER_ISTYPE:
         nStatus = DRIVERTYPE_NULL;
      break;
      case DRIVER_VERIFYWPARAM:
      case DRIVER_VERIFYLPARAM:
         nStatus = (PDFSTATUS)TRUE;
      break;
      default:
         nStatus = ERR_NOERROR;
      break;
   }
   return nStatus;
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      CalcPDFBitwidth
*
* Description:       Return width of PDF symbol in elements. No scaling
*                    for output is applied.
*
* Synopsis:          uint16 CalcPDFBitwidth( PdfSymbolType type, uint16 cols );
*
*  Parameters:       type - PDF type to calculate for (normal/trunc/naked)
*                    cols - number of data columns in data region
*
*  Returns:          Width of symbol in elements; zero if unknown type.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
* Calculate width
* End Pseudocode *****************************************************
**********************************************************************/
uint16 CalcPDFBitwidth( uint16 fSymbolStyle, uint16 cols )
{
/* // 98.04.14 #ifndef PDF_NOBARPATTERN                                        */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14                                                     */
/* // 98.04.14    uint16 width = cols * 17;     *//* all types have at least a data region */
/* // 98.04.14                                                     */
/* // 98.04.14    switch( fSymbolStyle ) {                                    */
/* // 98.04.14       case STYLE_NORMAL:                                        */
/* // 98.04.14          width += (17 + 17 + 17 + 18);    *//* row indicators and start/stop */
/* // 98.04.14       break;                                            */
/* // 98.04.14       case STYLE_TRUNCATED:                                    */
/* // 98.04.14          width += (17 + 17 + 1);          *//* start, left row and stop element */
/* // 98.04.14       break;                                            */
/* // 98.04.14       case STYLE_NAKED:                                        */
/* // 98.04.14          width += 1;                      *//* stop element */
/* // 98.04.14       break;                                            */
/* // 98.04.14       case STYLE_BARE:                                        */
/* // 98.04.14          width += (17 + 1);               *//* left row and stop element */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #ifndef NO_MICROPDF                                        */
/* // 98.04.14       case STYLE_MICRO:                                        */
/* // 98.04.14          width += (10 + 11);                                    */
/* // 98.04.14          *//* For those styles with a center pattern we increase width */
/* // 98.04.14          if ( lpApp->nMicroSize >= 13 )                                */
/* // 98.04.14             width += 10;                                        */
/* // 98.04.14       break;                                            */
/* // 98.04.14 #endif                                                */
/* // 98.04.14       default:                                            */
/* // 98.04.14          width = 0;                                        */
/* // 98.04.14       break;                                            */
/* // 98.04.14    }                                                */
/* // 98.04.14    return width;                                            */
/* // 98.04.14 #else                                                */
   return 1;
/* // 98.04.14 #endif                                                */
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      CalcPDFBitheight
*
* Description:       Calculate the height of the PDF symbol in number
*                    of scanlines (bit rows). The application specified
*                    aspect ratio of row height to module width is
*                    used to calculate height.
*                    Note that without actual scale used to produce
*                    actual symbol, rounding errors can be introduced
*                    into height returned. 
*
* Synopsis:          uint16 CalcPDFBitheight( uint16 rows, uint16 height, 
*                       uint16 width, uint16 scale )
*
*  Parameters:       rows - number of rows in symbols
*                    height - row height ratio value
*                    width - module width ratio value
*                    scale - scaling factor applied to x/y
*
*  Returns:          Height of symbol in elements.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
* Calculate height
* End Pseudocode *****************************************************
**********************************************************************/
#define CalcPDFBitheight( rows, height, width, scale )    \
   (uint16)( ( (rows) * (height) * (scale) ) / (width) )

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeMemoryObject
*
* Description:       Creates an input/output memory object for use with
*                    encoder library.
*
* Synopsis:          Bool MakeMemoryObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPVOID lpBase )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*                    lpBase - base address of memory block
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Create memory object
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MakeMemoryObject( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase )
{
   if ( lpObj == NULL )
      return FALSE;

   PDFObjNewMem( lpObj, ioDirection, lpBase, NULL );

   return TRUE;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeHugeMemoryObject
*
* Description:       Creates an input/output memory object for use with
*                    encoder library.
*
* Synopsis:          Bool MakeHugeMemoryObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPVOID lpBase )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*                    lpBase - base address of memory block
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Create memory object
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MakeHugeMemoryObject( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase )
{
#ifdef HUGE_PTRS
   if ( lpObj ) {
      PDFObjNewMem( lpObj, ioDirection, lpBase, NULL );
      PDFObjSetHuge( lpObj );

      return TRUE;
   }
#endif /* HUGE_PTRS */

   return FALSE;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeCallbackObject
*
* Description:       Creates an input/output function object for use with
*                    encoder library.  All encoder reads/writes are
*                    directed through the applications function.
*
*                    The callback function must react to the following
*                    commands from the encoder library:
*
*                       PDFIO_READ - (input objects) return data to library
*                       PDFIO_WRITE - (output object) accept output 
*                       PDFIO_REWIND - (input objects) reset to beginning
*                                      of input stream
*
* Synopsis:          LPPDFObject MakeCallbackObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPFNPDFIO lpfnCallback, LPVOID lpArg )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*                    lpfnCallback - I/O function address
*                    lpArg - application defined argument passed to callback
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Create function object
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI MakeCallbackObject( LPPDFObject lpObj, uint16 ioDirection, LPFNPDFIO lpfnCallback,    */
/* // 98.04.14                   LPVOID lpArg )                                    */
/* // 98.04.14 {                                                */
/* // 98.04.14    if ( lpObj == NULL )                                        */
/* // 98.04.14       return FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    PDFObjNewCallback( lpObj, ioDirection, lpfnCallback, lpArg, NULL );                */
/* // 98.04.14                                                     */
/* // 98.04.14    return TRUE;                                            */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeFileObject
*
* Description:       Creates an input/output function object for use with
*                    encoder library.  All encoder reads/writes are
*                    directed through this open file.
*
* Synopsis:          LPPDFObject MakeFileObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, int hFile )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*                    hFile - handle to open file
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Setup file object record
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MakeFileObject( LPPDFObject lpObj, uint16 ioDirection, FILEHANDLE hFile )
{
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14    if ( lpObj ) {                                        */
/* // 98.04.14       PDFObjNewFile( lpObj, ioDirection, hFile, NULL );                        */
/* // 98.04.14                                                     */
/* // 98.04.14       return TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */

   return FALSE;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeFilenameObject
*
* Description:       Creates an input/output function object for use with
*                    encoder library.  All encoder reads/writes are
*                    directed through this file. The file will be openned
*                    and closed by the encoder library.
*
* Synopsis:          LPPDFObject MakeFilenameObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, LPCSTRING lpcszFile )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*                    lpcszFilen - filename to open/create
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Setup file object record
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MakeFilenameObject( LPPDFObject lpObj, uint16 ioDirection, 
      LPCSTRING lpcszFile )
{
/* // 98.04.14 #ifndef PDF_NOFILEIO                                        */
/* // 98.04.14    if ( lpObj ) {                                        */
/* // 98.04.14       return PDFObjNewFilename( lpObj, ioDirection, lpcszFile, NULL );                */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif *//* PDF_NOFILEIO */
   return FALSE;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MakeClipboardObject
*
* Description:       Creates an input/output function object for use with
*                    encoder library.  All encoder reads/writes are
*                    directed through Windows clipboard
*
* Synopsis:          void AssignClipboardObject( LPPDFObject lpObj, 
*                       uint16 ioDirection, VOID NEAR *dummy )
*
*  Parameters:       lpObj - object to initialize
*                    ioDirection - direction of object (input/output)
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Setup clipboard object record
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MakeClipboardObject( LPPDFObject lpObj, uint16 ioDirection, GENHANDLE dummy )
{
/* // 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                                */
/* // 98.04.14    if ( lpObj ) {                                        */
/* // 98.04.14       PDFObjNewClipboard( lpObj, ioDirection, NULL );                        */
/* // 98.04.14                                                     */
/* // 98.04.14       return TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif                                                */
   return FALSE;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MPDFDisable
*
* Description:       Disable the generation of Macro PDF barcodes.
*
* Synopsis:          Bool MPDFDisable( void )
*
*  Returns:          Returns a TRUE if successful in disabling; FALSE if
*                    currently encoding an MPDF sequence.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Disable macro PDF
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MPDFDisable( void )
{
/* // 98.04.14 #ifdef PDF_NOMACROPDF                                        */
   return TRUE;
/* // 98.04.14 #else                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    Bool status = FALSE;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14       make sure we are not currently encoding an MPDF sequence                    */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( lpApp && !lpApp->fEncodeActive ) {                            */
/* // 98.04.14       if ( lpApp->lpMpdf ) {                                    */
/* // 98.04.14                                                      */
/* // 98.04.14          * Get rid of memory associated with macro PDF state buffer - this            */
/* // 98.04.14          * buffer was allocated for the duration of the encode session                */
/* // 98.04.14          * through the macro PDF module: MPDF.C. The memory reference is                */
/* // 98.04.14          * maintained by the session memory management module: SESSION.C                */
/* // 98.04.14                                                      */
/* // 98.04.14          ReleaseSessionMPDFBuf();                                */
/* // 98.04.14          lpApp->lpMpdf = NULL;                                    */
/* // 98.04.14       }                                                */
/* // 98.04.14       status = TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( status );                                        */
/* // 98.04.14 #endif                                                */
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      IsParamChangeOk
*
* Description:       This routine returns a go/no-go status for effecting
*                    the symbol paramters. Normally it is acceptable to
*                    make changes at any time during a macro PDF symbol
*                    sequence generation -- except for one case. When
*                    a block count is being added to the symbols then any
*                    change to symbol size could effect the overall
*                    generated symbol count, thereby invalidating the
*                    block count value placed in all symbols.
*
* Synopsis:          Bool IsParamChangeOk( LPAppParamsRec lpApp )
*
*  Parameters:       lpApp - application paramter settings record
*
*  Return Value:     Returns a true if acceptable to change symbol
*                    parameters; false otherwise.
*
**********************************************************************/
static Bool IsParamChangeOk( LPAppParamsRec lpApp )
{
   Bool fIsOkay = TRUE;
   /*
   * This only concerns us when macro PDF has been enabled
   */
/* // 98.04.14 #ifndef PDF_NOMACROPDF                                        */
/* // 98.04.14    if ( lpApp->lpMpdf ) {  *//* is macro enabled? */
/* // 98.04.14       if ( lpApp->fEncodeActive && MPDFIsAddBlockCount( lpApp ) ) {                */
/* // 98.04.14          fIsOkay = FALSE;                                    */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14 #endif                                                */
   return fIsOkay;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      getnum
*
* Description:       Translate the string number to an integer equivalent.
*                    The returned value is a fixed decimal value, accurate
*                    to two decimal places; 0.50 == 50. It will never allow
*                    a number greater than 9999 (or 99.99) or equal to zero.
*
* Synopsis:          uint16 getnum( LPCSTRING start, LPCSTRING end )
*
*  Parameters:       start - beginning of fixed decimal place string
*                    end - end of fixed decimal number
*
*  Return Value:     Returns the integer value to two decimal places; zero
*                    if value out of range.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Build 
* End Pseudocode *****************************************************
**********************************************************************/
static uint16 getnum( LPCSTRING lpszStart, LPCSTRING lpszEnd )
{
   uint16 num;
   uint16 places = 2;      /* only allow 2 decimal places */
   Bool decimal = FALSE;
   /*
      scan ASCII number string  and convert to fixed decimal place value
   */
   for( num=0; lpszStart != lpszEnd; lpszStart++ ) {
      /*
         if we found a decimal point then set flag so we only take the
         next 2 places
      */
      if ( *lpszStart == '.' ) {
         if ( !decimal ) {
            decimal = TRUE;
            continue;
         }
         else
            /*
               two decimal points!? -- error
            */
            num = 0, lpszStart = lpszEnd;
      }
      if ( isNUM( *lpszStart ) ) {  /* verify it's a digit */
         /*
            bump our running number and add in new digit
         */
         num = (num * 10) + (uchar)(char)(*lpszStart - '0');
         /*
            if we gathered the 2 decimal places then we're done
         */
         if ( decimal && !--places )
            break;
         /*
            if we exceed our max value then abort
         */
         if ( num >= 10000 )
            break;
      }
      else {
         num = 0;    /* found a non-number value, flag as error */
         break;
      }
   }
   while( places-- )
      num *= 10;

   return( (0 < num) && (num <= 9999) ? num : 0 );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFBinaryMode
*
* Description:       Force the use of binary mode encodiny by enabling
*                    this --  assiging TRUE. Otherwise we pick the
*                    optimal mode for encoding data.
*
* Synopsis:          Bool PDFBinaryMode( Bool flag )
*
*  Parameters:       flag - TRUE to force binary mode encoding; FALSE
*                           for API chosen mode.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set binary encode mode flag
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMNT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFBinaryMode( Bool flag )                                */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    Bool fStatus;                                            */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14       lpApp->fBinaryOnly = (flag ? TRUE : FALSE);                        */
/* // 98.04.14       fStatus = TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14    else                                                */
/* // 98.04.14       fStatus = FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    return fStatus;                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
 * Routine Header *****************************************************
*
* Routine Name:      PDFSetAspect
*
* Description:       Assign a PDF barcode aspect ratio.  The aspect
*                    ratio is defined as the ratio of barcode height
*                    to width.  Valid range for aspect ratio is: 0.1
*                    to 10.0.
*
* Synopsis:          Bool PDFSetAspect( LPCSTRING str )
*
*  Parameters:       str - pointer to string formatted as: "<h>:<w>", where
*                          these values can be specified to 2 decimal places.
*
*  Return Value:     Returns a TRUE if aspect ratio was set; FALSE
*                    is invalid.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set pdf aspect ratio field
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetAspect( LPCSTRING lpszAspect )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool isok = FALSE;
   LPCSTRING lpszColon;
   uint16 height, width, aspect;

   if ( !lpszAspect || !lpApp )
      return FALSE;

   if ( !IsParamChangeOk( lpApp ) )    /* macro PDF restricted */
      return FALSE;

   lpszColon = STRCHR(lpszAspect, ':');
   if ( lpszColon ) {
      height = getnum( lpszAspect, lpszColon );
      width = getnum( lpszColon+1, lpszAspect + STRLEN(lpszAspect) );
      if ( height && width ) {
         aspect = (uint16)( (uint32)(height * 100L) / width);

         isok = (0 < aspect) && (aspect <= 1000) ? TRUE : FALSE; /* no more than 10:1 */
         if ( isok )
            lpApp->pdf_aspect = aspect;
      }
   }
   return( isok );
}
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetModuleAspect
*
* Description:       Assign a module aspect ratio. The module aspect
*                    ratio is defined as the height of a barcode
*                    row in relation to the X element dimension. The
*                    valid range is: 1 thru 10.
*
* Synopsis:          Bool PDFSetModuleAspect( int modaspect )
*
*  Parameters:       modaspect - module aspect ratio (integer multiple)
*
*  Return Value:     Returns a TRUE if aspect ratio was set; FALSE
*                    is invalid.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set module aspect ratio (multiplier) field
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetModuleAspect( uint16 modaspect )
{
/* // 98.04.14 #ifndef PDF_NOBARPATTERN                                        */
/* // 98.04.14    Bool isok = FALSE;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( (1 <= modaspect) && (modaspect <= 10) ) {                        */
/* // 98.04.14       LPAppParamsRec lpApp = GetSessionSettings();                        */
/* // 98.04.14                                                     */
/* // 98.04.14       if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14          lpApp->module_height = (uint16)modaspect;                        */
/* // 98.04.14          lpApp->module_width = 1;                                */
/* // 98.04.14                                                     */
/* // 98.04.14          isok = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( isok );                                        */
/* // 98.04.14 #else                                                */
   return FALSE;
/* // 98.04.14 #endif                                                */
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetRowHeight
*
* Description:       
*                    If no 'width' ratio is defined, then a one is
*                    assumed -- identical to calling PDFSetModuleAspect().
*
* Synopsis:          BOOL PDFSetRowHeight( LPCSTRING setting )
*
*  Parameters:       setting - row height and width aspect ratio of
*                              the following format: "<height>[:<width>]"
*
*  Return Value:     Returns a TRUE if aspect ratio was set; FALSE
*                    is invalid.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set module row height:width aspect ratio field
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifndef PDF_NOBARPATTERN                                        */
/* // 98.04.14 Bool PDFAPI PDFSetRowHeight( LPCSTRING lpszAspect )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    Bool isok = FALSE;                                        */
/* // 98.04.14    LPCSTRING lpszColon;                                        */
/* // 98.04.14    uint16 height, width;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( !lpszAspect )                                        */
/* // 98.04.14       return FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( (lpszColon = STRCHR( lpszAspect, ':' )) != (LPCSTRING)0 ) {                */
/* // 98.04.14       height = getnum( lpszAspect, lpszColon ) / 100;                        */
/* // 98.04.14       width = getnum( lpszColon+1, lpszAspect + STRLEN(lpszAspect) ) / 100;            */
/* // 98.04.14    }                                                */
/* // 98.04.14    else {                                            */
/* // 98.04.14       height = getnum( lpszAspect, &lpszAspect[ STRLEN(lpszAspect) ] ) / 100;            */
/* // 98.04.14       width = 1;                                            */
/* // 98.04.14    }                                                */
/* // 98.04.14    if ( (0 < height && height <= 25) && (0 < width && width <= 25) ) {                */
/* // 98.04.14       LPAppParamsRec lpApp = GetSessionSettings();                        */
/* // 98.04.14                                                     */
/* // 98.04.14       if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14          lpApp->module_height = height;                                */
/* // 98.04.14          lpApp->module_width = width;                                */
/* // 98.04.14                                                    */
/* // 98.04.14          isok = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( isok );                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetRowCol
*
* Description:       Assign row and column limits for barcode. The
*                    actual interpretation of these values is determined
*                    by the current setting of 'dimtype'. Either the
*                    the values represent fixed dimensions or are 
*                    ceiling values.  Their interpretation affects how
*                    they are validated by the routine.  Cieling values
*                    must both fall into the valid ranged for row and
*                    columns. Fixed values, however, are allowed to
*                    assign one zero length which implies a variable
*                    dimension,
*
* Synopsis:          Bool PDFSetRowCol( int rows, int cols )
*
*  Parameters:       rows - row dimension
*                    cols - column dimension
*
*  Return Value:     Returns a TRUE if row and col were valid; FALSE
*                    otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set row and column counts
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetRowCol( uint16 rows, uint16 cols )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool ok = TRUE;

   if ( !lpApp )
      return FALSE;

   if ( !IsParamChangeOk( lpApp ) )    /* macro PDF restricted */
      return FALSE;
   /*
      validate ranges of arguments first
   */
   if ( rows )
      ok = ((3 <= rows) && (rows <= 90));

   if ( ok && cols )
      ok = ((1 <= cols) && (cols <= 30 ));

   if ( ok ) {
      if ( lpApp->dimtype == USE_LIMITS ) {
         ok = (rows && cols);    /* both must be defined */
      }
      else {
         if ( rows && cols )           /* if both are fixed then... */
            ok = (rows * cols) <= 928; /* ...they must make a valid size */
         else
            ok = rows || cols;         /* at least one has to be defined */
      }
   }
   if ( ok ) {
      lpApp->rows = rows;
      lpApp->cols = cols;

      ok = TRUE;
   }
   return( ok );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetECCPercent
*
* Description:       Assign the ECC level for the barcode based on
*                    a percentage of the data codeword count. Valid
*                    range is: 0 thru 400
*
*                    This function will automatically clear the fixed
*                    ECC interpretation field: fECCFixed
*
* Synopsis:          Bool PDFSetECCPercent( int percentage )
*
*  Parameters:       percentage - ECC as a percentage of data codewords
*
*  Return Value:     Returns a TRUE if percentage was valid; FALSE
*                    otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set percentage ECC flag
*  Set ecc percentage field
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFSetECCPercent( uint16 percentage )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    Bool isok = FALSE;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( percentage <= 400 ) {                                    */
/* // 98.04.14       LPAppParamsRec lpApp = GetSessionSettings();                        */
/* // 98.04.14                                                     */
/* // 98.04.14       if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14          lpApp->nEccPercent = percentage;                            */
/* // 98.04.14          lpApp->fEccFixed = FALSE;                                */
/* // 98.04.14          lpApp->fPadWithECC = TRUE;                                */
/* // 98.04.14                                                     */
/* // 98.04.14          isok = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( isok );                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetECCLevel
*
* Description:       Assign a fixed ECC level for barcode. Valid
*                    range is: 0 thru 8.
*
*                    This function will automatically set the fixed ECC
*                    interpretation flag: fECCFixed.
*
* Synopsis:          Bool PDFSetECCLevel( int level )
*
*  Parameters:       level - ECC level to assign.
*
*  Return Value:     Returns a TRUE if level was valid; FALSE otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set fixed ECC flag
*  Set ecc level field
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetECCLevel( uint16 level )
{
   Bool isok = FALSE;
   
   if ( level <= 8 ) {
      LPAppParamsRec lpApp = GetSessionSettings();

      if ( lpApp && IsParamChangeOk( lpApp ) ) {
         lpApp->nEccLevel = level;
         lpApp->fEccFixed = TRUE;
         lpApp->fPadWithECC = FALSE;

         isok = TRUE;
      }
   }
   return( isok );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFUseStrictECC
*
* Description:       The encoder can either pad a symbol with the 
*                    standard pad codeword (900) or fill extra space
*                    by automatically boosting the ECC level. The
*                    user can control this effect by enabling or
*                    disabling the strict interpretation of ECC
*                    values specified through PDFSetECCLevel and
*                    PDFSetECCPercent.
*
* Synopsis:          Bool PDFUseStrictECC( Bool fUseStrict )
*
*  Parameters:       fUseStrict - if TRUE then symbol is padded with
*                                 900; else it's padded with ECC
*
*  Return Value:     Returns a TRUE if change affected; FALSE otherwise
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set fixed ECC flag
*  Set ecc level field
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFUseStrictECC( Bool fUseStrict )                            */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    Bool fDidChange;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14       lpApp->fPadWithECC = fUseStrict ? FALSE : TRUE;                        */
/* // 98.04.14       fDidChange = TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14    else {                                            */
/* // 98.04.14       fDidChange = FALSE;                                    */
/* // 98.04.14    }                                                */
/* // 98.04.14    return fDidChange;                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFOutputFilter
*
* Description:       Assign an ouput filter to be used during PDF
*                    barcode rendering: through PDFMakeImage().
*                    At the time of installation, we also assign the
*                    two filter parameters, lparam and wparam.
*
* Synopsis:          Bool PDFOutputFilter( LPFNPDFFILTER lpfnFilter, 
*                       uint32 lparam, uint16 wparam )
*
*  Parameters:       lpfnFilter - output filter to install
*                    lparam - 32 bit filter parameter
*                    wparam - 16 bit filter parameter
*
*  Return Value:     Returns a TRUE if filter installed; FALSE otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Assign output filter fields
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMNT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFOutputFilter( LPFNPDFFILTER lpfnFilter, uint32 lparam, uint16 wparam )        */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14    * Assert non-NULL formatter and applications buffer                        */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( !lpfnFilter )                                        */
/* // 98.04.14       return FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    lpApp = GetSessionSettings();                                    */
/* // 98.04.14    if ( !lpApp )                                            */
/* // 98.04.14       return FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14                                                    */
/* // 98.04.14    * Before assigning fields in lpApp, verify the wParam and lParam                */
/* // 98.04.14    * value with the driver                                    */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( DriverVerifyWParam( lpfnFilter, wparam ) && DriverVerifyLParam( lpfnFilter, lparam ) ) {    */
/* // 98.04.14       lpApp->lpfnFilter = lpfnFilter;                                */
/* // 98.04.14       lpApp->lparam     = lparam;                                */
/* // 98.04.14       lpApp->wparam     = wparam;                                */
/* // 98.04.14                                                     */
/* // 98.04.14       return TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14    return FALSE;                                            */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetFilterWord
*
* Description:       Re-assign the 16 bit output filter parameter.
*
* Synopsis:          Bool PDFSetFilterWord( uint16 w )
*
*  Parameters:       wparam - 16 bit filter parameter
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Assign output filter word parameter field
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFSetFilterWord( uint16 wparam )                            */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    Bool fStatus = FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp ) {                                        */
/* // 98.04.14       if ( DriverVerifyWParam( lpApp->lpfnFilter, wparam ) ) {                    */
/* // 98.04.14          lpApp->wparam = wparam;                                    */
/* // 98.04.14          fStatus = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return fStatus;                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetFilterLong
*
* Description:       Re-assign the 32 bit output filter parameter.
*
* Synopsis:          Bool PDFSetFilterLong( uint32 lparam )
*
*  Parameters:       lparam - 32 bit filter parameter
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Assign output filter long parameter field
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFSetFilterLong( uint32 lparam )                            */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    Bool fStatus = FALSE;                                        */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp ) {                                        */
/* // 98.04.14       if ( DriverVerifyLParam( lpApp->lpfnFilter, lparam ) ) {                    */
/* // 98.04.14          lpApp->lparam = lparam;                                    */
/* // 98.04.14          fStatus = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return fStatus;                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetSymbolStyle
*
* Description:       Define the type of PDF symbol style to build:
*                       STYLE_NORMAL      Standard PDF symbol
*                       STYLE_TRUNCATED   Strip the right row indicator
*                                         and stop pattern and replace 
*                                         with a single element bar
*                       STYLE_NAKE        Strip start/stop patterns and
*                                         left/right row indicators
*                       STYLE_BARE        Strip start/stop and right row
*                                         indicator
*
* Synopsis:          Bool PDFSetSymbolStyle( uint16 fSymbolStyle );
*
*  Parameters:       type - specifies style of PDf symbol to create
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set pdf style flag
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetSymbolStyle( uint16 fSymbolStyle )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool fStatus;

   if ( lpApp && IsParamChangeOk( lpApp ) ) {
      fStatus = TRUE;

      switch( fSymbolStyle & STYLE_MASK ) {
         case STYLE_TRUNCATED:
         case STYLE_NAKED:
         case STYLE_BARE:
         case STYLE_NORMAL:
            lpApp->symtype = fSymbolStyle & STYLE_MASK;
            lpApp->c128Emulation = PDF128_EMUL_OFF;
         break;
#ifndef NO_MICROPDF
         case STYLE_MICRO: {
            uint16 nMicroSize = (fSymbolStyle & MICRO_MASK) >> 8;

            if ( nMicroSize < MICRO_INDEXCOUNT ) { 
               lpApp->nMicroSize = nMicroSize;
               lpApp->nMicroECC = anMicroECCMap[ lpApp->nMicroSize ];
               lpApp->symtype = fSymbolStyle & STYLE_MASK;
               /*
               * Set characteristics which are preferred for Micro but
               * that can be overriden by user
               */
               PDFSetModuleAspect( 2 );

            }
            else {
               fStatus = FALSE;
            }
         }
         break;
#endif
         default:
            fStatus = FALSE;
         break;
      }
   }
   else
      fStatus = FALSE;

   return fStatus;
}                  

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetCode128EmulationMode
*
* Description:       Assign a Code128 emulation mode for barcode. Valid
*                    range is: PDF128_EMUL_OFF - PDF128_EMUL_LINKEDC1.
*
*
* Synopsis:          PDFSetCode128EmulationMode( int16 EmulMode )
*
*  Parameters:       EmulMode - mode to assign.
*
*  Return Value:     Returns a TRUE if mode was valid; FALSE otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Check for valid input
*  Set code128 emulation mode field to input value
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFSetCode128EmulationMode( int16 EmulMode )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    Bool isok = FALSE;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( (EmulMode >= PDF128_EMUL_OFF) && (EmulMode <= PDF128_EMUL_LINKEDC1)) {            */
/* // 98.04.14       LPAppParamsRec lpApp = GetSessionSettings();                        */
/* // 98.04.14                                                     */
/* // 98.04.14       if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14          lpApp->c128Emulation = EmulMode;                            */
/* // 98.04.14          isok = TRUE;                                        */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( isok );                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFNoMacroCharSubstitution
*
* Description:       Disable/Enable the macro character substitution 
*                    feature of MicroPDF                                  
*
*
* Synopsis:          PDFNoMacroCharSubstitution( Bool fDisable )
*
*  Parameters:       fDisable
*
*  Return Value:     Returns a TRUE if change is ok, FALSE otherwise.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  
*  Set disable macro character substitution field to disabled if the input parameter is true
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFNoMacroCharSubstitution( Bool fDisableIt )                    */
/* // 98.04.14 {                                                */
/* // 98.04.14    Bool isok = FALSE;                                        */
/* // 98.04.14                                                    */
/* // 98.04.14                                                    */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp && IsParamChangeOk( lpApp ) ) {                            */
/* // 98.04.14          lpApp->fNoMacroCharSub = fDisableIt;                            */
/* // 98.04.14          isok = TRUE;                                        */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( isok );                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */


/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:     PDFAbort 
*
* Description:       Abort the current encode. This will only apply
*                    to macro PDF. Without this action, the application
*                    would be required to fully encode the input stream
*                    until a new data set could be begun.
*
* Synopsis:          Bool PDFAbort( LPPDFObject lpObj )
*
*  Parameters:       lpObj - input object in use for MPDF data source
*
* External Calls:    PDFObjAbortInput(), MPDF.C::Abort()
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Abort input object and clear active barcode record
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFAbort( LPPDFObject lpObj )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool fStatus;

   if ( lpApp ) {
      PDFObjAbort( lpObj );      /* reset input state to uninitialized */
      lpApp->fEncodeActive = FALSE;
   
      lpApp->lpCw = (LPCWRec)0;    /* clear active codeword data set */

#ifndef PDF_NOMACROPDF   
      if ( lpApp->lpMpdf )
         (*lpApp->lpMpdf->pfnAbort)( lpApp->lpMpdf );
#endif
      fStatus = TRUE;
   }
   else
      fStatus = FALSE;

   return fStatus;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetDimType
*
* Description:       Set the row and column count interpretation
*                    flag. Row and column values can either be
*                    considered fixed values or ceiling limits.
*
*                    As a side effect, the row and column value are
*                    reset to their defaults, based upon the mode:
*                       FIXED:  rows <-- 58, cols <-- 16
*                       LIMITS: rows <-- 90, cols <-- 30
*
* Synopsis:          Bool PDFSetDimType( DIMTYPE dimType )
*
*  Parameters:       type - fixed or ceiling interpretation on row
*                           column counts
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Assign fixed/limits for row/col flag
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetDimType( uint16 fDimType )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool fStatus = FALSE;

   if ( lpApp && IsParamChangeOk( lpApp ) ) {

      if ( (fDimType == USE_LIMITS) || (fDimType == USE_FIXED) ) {
         lpApp->dimtype = fDimType;
         fStatus = TRUE;
      
         if ( fDimType == USE_LIMITS ) {
            lpApp->rows = 90;
            lpApp->cols = 30;  /* maximums for row/col */
         }
         else { /*  fDimType == USE_FIXED */
            lpApp->rows = 58;
            lpApp->cols = 16;  /* 928 codeword barcode matrix */
         }
      }
   }
   return fStatus;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFSetDefaults
*
* Description:       Reverts the state of the encoder to its "loadtime"
*                    settings. All prior settings, output formatter and
*                    macro PDF settings, will be reset.
*
* Synopsis:          void PDFSetDefaults( void )
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Set defaults for all options
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFSetDefaults( void )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool fStatus;

   if ( lpApp && !lpApp->fEncodeActive ) {
      lpApp->rows          = DEF_ROWS;
      lpApp->cols          = DEF_COLS;
      lpApp->dimtype       = DEF_DIMTYPE;
      lpApp->pdf_aspect    = DEF_ASPECT;
      lpApp->module_height = DEF_MODULEHEIGHT;
      lpApp->module_width  = DEF_MODULEWIDTH;
      lpApp->fEccFixed     = DEF_ISECCFIXED;
      lpApp->fPadWithECC   = DEF_PADWITHECC;
      lpApp->nEccLevel     = DEF_ECCLEVEL;
      lpApp->nEccPercent   = DEF_ECCPERCENT;
      lpApp->symtype       = DEF_SYMTYPE; 
      lpApp->c128Emulation = DEF_C128EMULATION;
      lpApp->fNoMacroCharSub = DEF_MACROCHAR_SUB;
      lpApp->fBinaryOnly   = DEF_ISBINARYONLY;
      lpApp->lpfnFilter    = DEF_OUTFILTER;
      lpApp->lparam        = DEF_LPARAM;
      lpApp->wparam        = DEF_WPARAM;
      lpApp->nMicroSize    = DEF_MICRO_SIZE;
      lpApp->nMicroECC     = DEF_MICRO_ECC;
      lpApp->lpCw          = (LPCWRec)0;

      (void)MPDFDisable();

      fStatus = TRUE;
   }
   else
      fStatus = FALSE;

   return fStatus;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFEncode
*
* Description:       This routine will attempt to encode
*                    a single barcodes worth of data.
*
*                    On a successful return, the application is free
*                    to query barcode details and change physical
*                    characteristics prior to rendering.
*
* Synopsis:          int PDFEncode( LPPDFObject lpObj, uint32 nInputLen )
*
*  Parameters:       lpObj - defines data source to encode
*                    nInputLen - number of bytes to encode
*
*  Return Value:     Returns a signed integer completion status:
*                       > 0 : PDF barcode successfully encoded
*                       = 0 : no more MPDF barcodes exist for data
*                       < 0 : errors detected during encode
*
* External Calls:    
*
* Local Calls:       PDFAbort()
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  If macro PDF Then
*     Encode macro barcode
*  Else
*     Encode normal barcode
*  EndIF
*  Return status
* End Pseudocode *****************************************************
**********************************************************************/

static PDFSTATUS PDFEncodeHelper( LPPDFObject lpObjIn, PDFSIZET nInputLen )
{
   LPAppParamsRec lpApp = GetSessionSettings();
   SEQSTATE seqstatus;
   PDFSTATUS nErrCode;

   if ( !lpApp )
      return( ERR_FATALINTERNAL );

#ifndef NO_MICROPDF
   if ( lpApp->symtype == STYLE_MICRO ) {
      /*
      *  Setup fixed size based on parameter passed
      */
      PDFSetDimType( USE_FIXED );
      PDFSetRowCol( GetMicroRow(lpApp->nMicroSize), GetMicroCol(lpApp->nMicroSize) );
      /*
      * It make no sense to set the ECC level since they are specific
      * to MicroPDF: they range in ECC codewords from 6 up to 38. But we
      * want to make sure we do not pad with ECC since this makes no sense
      * to us here
      */
      lpApp->fPadWithECC = FALSE;
   }
#endif

   nErrCode = ERR_NOERROR;
   lpApp->lpCw = (LPCWRec)0;             /* clear libraries codeword data set */

/* // 98.04.14 #ifndef PDF_NOMACROPDF                                        */
/* // 98.04.14    if ( lpApp->lpMpdf ) {                                    */
/* // 98.04.14       LPMPDFRec lpMpdf = lpApp->lpMpdf;                                */
/* // 98.04.14                                                       */
/* // 98.04.14       * Encode input stream as a Macro PDF Sequence                        */
/* // 98.04.14                                                       */
/* // 98.04.14       switch( seqstatus = PDFObjSyncInput( lpObjIn, nInputLen ) ) {                */
/* // 98.04.14          case SEQ_BEGIN:                                        */
/* // 98.04.14             lpApp->fEncodeActive = TRUE;                                */
/* // 98.04.14                                                         */
/* // 98.04.14                fall thru!!                                    */
/* // 98.04.14                                                         */
/* // 98.04.14          case SEQ_MID:                                        */
/* // 98.04.14             if ( seqstatus == SEQ_BEGIN )                            */
/* // 98.04.14                nErrCode = (*lpMpdf->pfnSetup1st)( lpMpdf, lpObjIn, (LPCWRec)lpApp->cw_buf );    */
/* // 98.04.14             else if ( !(*lpMpdf->pfnSetupNext)( lpMpdf ) )   *//* bump to next BlockIndex */
/* // 98.04.14                nErrCode = ERR_TOOMANYMPDF;                            */
/* // 98.04.14                                                         */
/* // 98.04.14                encode a single barcodes worth of data                        */
/* // 98.04.14                                                         */
/* // 98.04.14             if ( nErrCode == ERR_NOERROR )                            */
/* // 98.04.14                nErrCode = encode_data( lpObjIn, lpApp, (LPCWRec)lpApp->cw_buf );            */
/* // 98.04.14             if ( nErrCode == ERR_NOERROR ) {                            */
/* // 98.04.14                                                            */
/* // 98.04.14                   assign the 'cw' field to the valid codeword record to                */
/* // 98.04.14                   be used by PDFMakeImage()                            */
/* // 98.04.14                                                            */
/* // 98.04.14                lpApp->lpCw = (LPCWRec)lpApp->cw_buf;                        */
/* // 98.04.14                                                            */
/* // 98.04.14                   check to see if more data in sequence -- if end of data            */
/* // 98.04.14                   then tell MPDF module so it can append the 922 in the MPCB            */
/* // 98.04.14                                                            */
/* // 98.04.14                if ( PDFObjIsEOF( lpObjIn ) )                            */
/* // 98.04.14                   (*lpMpdf->pfnFlagAsLast)( lpMpdf );                        */
/* // 98.04.14                                                       */
/* // 98.04.14                nErrCode = STATUS_ENCODEOK;                            */
/* // 98.04.14             }                                            */
/* // 98.04.14          break;                                            */
/* // 98.04.14          case SEQ_EOF:                                        */
/* // 98.04.14             nErrCode   = STATUS_NOMOREBARCODES;                            */
/* // 98.04.14             lpApp->fEncodeActive = FALSE;                            */
/* // 98.04.14                                                     */
/* // 98.04.14             (*lpMpdf->pfnEndMPDFSeq)( lpMpdf );                            */
/* // 98.04.14             PDFObjEndIO( lpObjIn );          *//* end input from lpObjIn source */
/* // 98.04.14          break;                                            */
/* // 98.04.14          default:    *//* error returned by pdfinput_reenter() */
/* // 98.04.14             nErrCode = seqstatus;                                */
/* // 98.04.14          break;                                            */
/* // 98.04.14       }                                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    else                                                */
/* // 98.04.14 #endif *//* PDF_NOMACROPDF */
   {  /* Single, non-macro PDF symbol */
      seqstatus = PDFObjSyncInput( lpObjIn, nInputLen ) ;
      if ( seqstatus == SEQ_BEGIN ) {

         lpApp->fEncodeActive = TRUE;
         /*
            encode user data to fill a single barcode
         */
         nErrCode = encode_data( lpObjIn, lpApp, (LPCWRec)lpApp->cw_buf );
         if ( nErrCode == ERR_NOERROR ) {
            /*
               assign the 'cw' field to the valid codeword record to
               be use by PDFMakeImage
            */
            lpApp->lpCw = (LPCWRec)lpApp->cw_buf;
            /*
               check to see if more data left -- if so then error
            */
            nErrCode = PDFObjIsEOF( lpObjIn ) ? STATUS_ENCODEOK : ERR_TOOMUCHDATA;
         }
         lpApp->fEncodeActive = FALSE;
         /*
         * Cancel input from lpObjIn since input should have been exhausted
         * through this non-macro PDF encode pass
         */
         PDFObjEndIO( lpObjIn );
      }
      else if ( seqstatus < 0 )
         nErrCode = seqstatus;
   }
   if ( nErrCode < 0 ) /* if any errors were detected then abort barcode */
      (void)PDFAbort( lpObjIn );

   return( nErrCode );
}

PDFSTATUS PDFAPI PDFEncode( LPPDFObject lpObjIn, PDFSIZET nInputLen )
{
   if ( !lpObjIn )
      return( ERR_NULLDATASOURCE );

   PDFObjSetECIFormat( lpObjIn, FALSE ); 

   return PDFEncodeHelper( lpObjIn, nInputLen );
}
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 PDFSTATUS PDFAPI PDFECIEncode( LPPDFObject lpObjIn, PDFSIZET nInputLen )                */
/* // 98.04.14 {                                                */
/* // 98.04.14    if ( !lpObjIn )                                        */
/* // 98.04.14       return( ERR_NULLDATASOURCE );                                */
/* // 98.04.14                                                     */
/* // 98.04.14    PDFObjSetECIFormat( lpObjIn, TRUE );                                 */
/* // 98.04.14                                                     */
/* // 98.04.14    return PDFEncodeHelper( lpObjIn, nInputLen );                            */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFMakeImage
*
* Description:       This routine will complete the creation of the
*                    active barcode by invoking bcbuild(). This routine
*                    will calculate the ECC codewords for the active
*                    barcode and then render the image using the installed
*                    output driver.
*
* Synopsis:          int PDFMakeImage( LPPDFObject lpObjOut, 
*                          LPUINT32 lpnBytesWritten )
*
*  Parameters:       lpOutObj - destination for rendered image
*                    lpnBytesWritten - returned length of output image
*
*  Return Value:     Returns zero if successfule; a negative error code if 
*                    unable to render image.
*
*                    If the application supplied a non-NULL size parameter
*                    then the output image length is returned through
*                    the pointer.
*
* External Calls:    
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Build barcode image from output filter
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef PDF_NOBARPATTERN                                        */
/* // 98.04.14 PDFSTATUS PDFAPI PDFMakeImage( LPPDFObject lpObjOut, LPPDFSIZET lpnBytesWritten )        */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPEncodeInfoRec lpBarcode;                                    */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14    PDFSTATUS nErrCode = ERR_NOERROR;                                */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( !lpApp )                                            */
/* // 98.04.14       return( ERR_FATALINTERNAL );                                */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpnBytesWritten != NULL )                                */
/* // 98.04.14       *lpnBytesWritten = 0;                                    */
/* // 98.04.14                                                     */
/* // 98.04.14    lpBarcode = (LPEncodeInfoRec)lpApp->if_buf;                            */
/* // 98.04.14                                                    */
/* // 98.04.14    * Calculated the symbol characteristics and build the codeword structure            */
/* // 98.04.14    * based on these -- construct row indicators, data region codewords and            */
/* // 98.04.14    * ECC codewords                                        */
/* // 98.04.14                                                    */
/* // 98.04.14    if ( (nErrCode = bcbuild( lpApp->lpCw, lpBarcode, lpApp )) == ERR_NOERROR ) {            */
/* // 98.04.14                                                       */
/* // 98.04.14       * If user supplies a NULL lpObjOut then just return the number of bytes            */
/* // 98.04.14       * the output formatter expects to write into it to render object                */
/* // 98.04.14                                                       */
/* // 98.04.14       if ( !lpObjOut ) {                                        */
/* // 98.04.14          if ( lpnBytesWritten != NULL)                                */
/* // 98.04.14             nErrCode = DriverQueryLen( lpApp, lpnBytesWritten );                    */
/* // 98.04.14          else                                            */
/* // 98.04.14             nErrCode = ERR_ARGUMENT;                                */
/* // 98.04.14       }                                                */
/* // 98.04.14       else if ( PDFObjInitOutput( lpObjOut ) ) {                            */
/* // 98.04.14          nErrCode = DriverBuildImage( lpApp, lpObjOut );                        */
/* // 98.04.14                                                     */
/* // 98.04.14          PDFObjEndIO( lpObjOut );                                */
/* // 98.04.14                                                     */
/* // 98.04.14          if ( (nErrCode == ERR_NOERROR) && (lpnBytesWritten != NULL) )                */
/* // 98.04.14             *lpnBytesWritten = PDFObjGetLen( lpObjOut );                        */
/* // 98.04.14       }                                                */
/* // 98.04.14       else                                            */
/* // 98.04.14          nErrCode = ERR_OUTPUTDEVICE;                                */
/* // 98.04.14    }                                                */
/* // 98.04.14    return( nErrCode );                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetCodewords **Undocumented**
*
* Description:       This routine provides access to the internal API
*                    codeword structure. Any changes made to the codeword
*                    set, through additions or deletions, must be 
*                    reflected in the symbol length descriptor member:
*                    cw->n.
*
*                    This routine was added to provide the ability to
*                    simply pass the encoded codeword stream to the
*                    DOS high-level decoder. Decoding codeword streams
*                    was necessary for encoder testing.
*
* Synopsis:          LPCWRec PDFGetCodewords( void )
*
* Returns:           Returns access to the internal API codeword structure
*                    for an encoded data stream.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return characteristics of active barcode
* End Pseudocode *****************************************************
**********************************************************************/
LPCWRec PDFAPI PDFGetCodewords( void )
{
   LPAppParamsRec lpApp = GetSessionSettings();

   if ( lpApp && lpApp->lpCw ) {
/* Comment Out By TEC
      lpApp->lpCw->data[0] = lpApp->lpCw->n;
*/
      return lpApp->lpCw;
   }
   else
      return (LPCWRec)0;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetMicroPDFCodewords **Undocumented**
*
* Description:       This routine provides access to the internal API
*                    codeword structure. Any changes made to the codeword
*                    set, through additions or deletions, must be 
*                    reflected in the symbol length descriptor member:
*                    cw->n.
*
*                    This routine was added to provide the ability to
*                    simply pass the encoded codeword stream to the
*                    DOS high-level decoder. Decoding codeword streams
*                    was necessary for encoder testing.
*
* Synopsis:          LPCWRec PDFGetMicroPDFCodewords( void )
*
* Returns:           Returns access to the internal API codeword structure
*                    for an encoded data stream.
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return characteristics of active barcode
* End Pseudocode *****************************************************
**********************************************************************/

LPCWRec PDFAPI PDFGetMicroPDFCodewords( void )
{
   LPAppParamsRec lpApp = GetSessionSettings();

   if ( lpApp && lpApp->lpCw ) {
      return lpApp->lpCw;
   }
   else
      return (LPCWRec)0;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFRenderCodewords **Undocumented**
*
* Description:       This routine provides access to the internal API
*                    codeword structure. It differs from PDFGetCodewords
*                    as this routine will fill the codeword 
*
* Synopsis:          LPCWRec PDFGetCodewords( void )
*
* Returns:           Returns access to the internal API codeword structure
*                    for an encoded data stream.
*
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 LPEncodeInfoRec PDFAPI PDFRenderCodewords( void )                        */
/* // 98.04.14 {                                                */
/* // 98.04.14    LPAppParamsRec lpApp = GetSessionSettings();                            */
/* // 98.04.14                                                     */
/* // 98.04.14    if ( lpApp ) {                                        */
/* // 98.04.14                                                       */
/* // 98.04.14       * Calculated the symbol characteristics and build the codeword structure            */
/* // 98.04.14       * based on these -- construct row indicators, data region codewords and            */
/* // 98.04.14       * ECC codewords                                        */
/* // 98.04.14                                                       */
/* // 98.04.14       if ( bcbuild( lpApp->lpCw, (LPEncodeInfoRec)lpApp->if_buf, lpApp ) == ERR_NOERROR )    */
/* // 98.04.14          return (LPEncodeInfoRec)lpApp->if_buf;                            */
/* // 98.04.14    }                                                */
/* // 98.04.14    return (LPEncodeInfoRec)0;                                    */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFCalcECC **Undocumented**
*
* Description:       Provides the ability to supply a stream of 
*                    codewords the low level add_ecc_poly(). The
*                    ECC polynomial coeficient are placed into the
*                    lpcwEcc array supplied.
*
* Synopsis:          uint16 PDFCalcECC( LPCCW lpcwSrc, uint16 nNumCWs,
*                       uint16 nEccLevel, LPCW lpcwEcc )
*
* Returns:           Returns total number of coeficients written to
*                    lpcwEcc; just 2**(nEccLevel+1).
*
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 uint16 PDFAPI PDFCalcECC( LPCCW lpcwSrc, uint16 nNumCWs, uint16 nEccLevel, LPCW lpcwEcc )    */
/* // 98.04.14 {                                                */
/* // 98.04.14    add_ecc_poly( lpcwSrc, nNumCWs, nEccLevel, lpcwEcc );                        */
/* // 98.04.14                                                     */
/* // 98.04.14    return ECCLEN( nEccLevel );                                     */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      FillDetailRec
*
* Description:       Fill in the PDF detail record with information
*                    related to previously encoded symbol. The data
*                    available is:
*                       Row and column counts, height and width in 
*                       elements, estimated output image length, aspect
*                       ratio, codeword counts for ECC, MPCB, data and 
*                       padding and ECC level.
*
* Synopsis:          Bool FillDetailRec( LPPDFDetailRec lpRec, uint16 nScale )
*
*  Parameters:       lpRec - record to fill with barcode data
*                    nScale - output scaling factor used for height and
*                           width calculations
*
* External Calls:    
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return characteristics of active barcode
* End Pseudocode *****************************************************
**********************************************************************/
static Bool FillDetailRec( LPPDFDetailRec lpRec, uint16 nScale )
{
   LPEncodeInfoRec lpBarcode;
   LPAppParamsRec lpApp = GetSessionSettings();
   Bool fStatus = FALSE;

   if ( lpRec ) {

      MEMSET( lpRec, 0, sizeof(PDFDetailRec) );

      if ( lpApp ) {
         lpBarcode = (LPEncodeInfoRec)lpApp->if_buf;
         /*
         * Actually build the codeword array - complete with ECC poly. Since
         * some formatters compress the data they need an accurate pattern
         * array to determine memory requirements for image
         */   
         if ( bcbuild( lpApp->lpCw, lpBarcode, lpApp ) == ERR_NOERROR ) {
            /*
               fill in barcode detail record
            */
            lpRec->nRows     = lpBarcode->dmatrix.rows;
            lpRec->nCols     = lpBarcode->dmatrix.cols;
            lpRec->nWidth    = CalcPDFBitwidth( lpBarcode->symtype, lpRec->nCols ) * nScale;
            lpRec->nHeight   = CalcPDFBitheight( lpRec->nRows, lpBarcode->mod_height,
                                               lpBarcode->mod_width, nScale );
            lpRec->nPadCW    = lpBarcode->pad_cws;
            lpRec->nMpdfCW   = lpBarcode->mpdf_cws;
            /*
            * Do not include the symbol length codeword in data count
            */
            lpRec->nDataCW   = lpBarcode->data_cws - 1;
#ifndef NO_MICROPDF
            /*
            * Since MicroPDF does not have a symbol length descriptor, we
            * do not want to descrement the data_cws count
            */
            if ( lpApp->symtype == STYLE_MICRO ) {
               lpRec->nDataCW++;
            }
#endif
            /*
            * The AIM specification includes EDC (detection codewords) as
            * part of the error correction codeword count
            */
#ifndef NO_MICROPDF
            if ( lpApp->symtype == STYLE_MICRO ) {
               lpRec->nEccCW = MICROECCLEN( lpApp->nMicroECC );
               lpRec->nEccLevel = lpApp->nMicroECC;
            }
            else
#endif
            {

               lpRec->nEccCW    = ECCLEN( lpBarcode->ecc_level );
               lpRec->nEccLevel = lpBarcode->ecc_level;
            }
            lpRec->nStyle    = lpBarcode->symtype;

            //if ( DriverQueryLen( lpApp, &lpRec->nSizeEstimate ) != ERR_NOERROR )
            if(DriverQueryLen(lpApp, &lpRec) != ERR_NOERROR)
               lpRec->nSizeEstimate = 0;

            fStatus = TRUE;
         }
      }
   }
   return fStatus;
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetDetails
*
* Description:       Fill in the PDF detail record with information
*                    related to previously encoded symbol.
*
* Synopsis:          void PDFGetDetails( LPPDFDetailRec lpDetailRec )
*
*  Parameters:       lpRec - record to fill with barcode data
*
* Local Calls:       FillDetailRec()
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return characteristics of active barcode
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI PDFGetDetails( LPPDFDetailRec lpDetailRec )
{
   return FillDetailRec( lpDetailRec, 1 );
}

/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetScaledDetails
*
* Description:       Fill in the PDF detail record with information
*                    related to previously encoded symbol. The scaling
*                    factor supplied is used to calculate extact width
*                    and height members.
*
* Synopsis:          Bool PDFGetScaledDetails( LPPDFDetailRec lpRec
*                          uint16 nScale )
*
*  Parameters:       lpRec - record to fill with barcode data
*                    nScale - scaling factor to apply to height and width
*
* Local Calls:       FillDetailRec()
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return characteristics of active barcode
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 Bool PDFAPI PDFGetScaledDetails( LPPDFDetailRec lpDetailRec, uint16 nScale )            */
/* // 98.04.14 {                                                */
/* // 98.04.14    return FillDetailRec( lpDetailRec, (uint16)(nScale ? nScale : 1) );                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetVer
*
* Description:       Return the current version number for the PDF
*                    encoder. The major and minor version numbers are
*                    returned in the single word - the high-order byte
*                    contains the major version number and the low-order
*                    byte the minor.
*
* Synopsis:          uint16 PDFGetVer()
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return string
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMENT_OUT                                        */
/* // 98.04.14 uint16 PDFAPI PDFGetVer( void )                                    */
/* // 98.04.14 {                                                */
/* // 98.04.14    return g_nVersion;                                        */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetCopyrightString
*
* Description:       Return the copyright notice for enoder.
*
* Synopsis:          LPCSTRING PDFGetCopyrightString( void )
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return string
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMNT_OUT                                        */
/* // 98.04.14 LPCSTRING PDFAPI PDFGetCopyrightString( void )                            */
/* // 98.04.14 {                                                */
/* // 98.04.14    return (LPCSTRING)g_aszCopyright;                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      PDFGetTimestamp
*
* Description:       Return the timestamp of the encoder build.    
*
* Synopsis:          LPCSTRING PDFGetTimestamp( void )
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return string
* End Pseudocode *****************************************************
**********************************************************************/
/* // 98.04.14 #ifdef COMMNT_OUT                                        */
/* // 98.04.14 LPCSTRING PDFAPI PDFGetTimestamp( void )                                */
/* // 98.04.14 {                                                */
/* // 98.04.14    return (LPCSTRING)g_aszTimestamp;                                */
/* // 98.04.14 }                                                */
/* // 98.04.14 #endif                                                */
/*********************************************************************                      
* Routine Header *****************************************************
*
* Routine Name:      MPDFIsEnabled
*
* Description:       Return enabled/disabled state of macro PDF.
*
* Synopsis:          Bool MPDFIsEnabled( void )
*
**********************************************************************/
/*********************************************************************
* Pseudocode:
*  Return status of macro PDF enabled/disabled
* End Pseudocode *****************************************************
**********************************************************************/
Bool PDFAPI MPDFIsEnabled( void )
{
/* // 98.04.14 #ifdef PDF_NOMACROPDF                                        */
   return FALSE;
/* // 98.04.14 #else                                                */
/* // 98.04.14    return GetSessionSettings()->lpMpdf != (LPMPDFRec)0;                        */
/* // 98.04.14 #endif                                                */
}

以下为.h文件:PDFAPI.H

/****************************************        B-N(伀)            *********************************/
/****************************************        B-N(仾)            *********************************/
/*********************************************************************
* Module Header
*
*  Identification:   PDFAPI.H - Library API Include File
*  Copyright (c) 1993-1997 Symbol Technologies, Inc.
*
* Edit History:      
*  $Log: PDFAPI.H $
*  Revision 1.6  1997/12/31 17:23:56  Anne
*  Added function  prototype to disable Macro Character Substitution 
*  feature of MicroPDF
*  Revision 1.5  1997/11/26 01:09:20  Anne
*  Added method to set the Code 128 Emulation Mode and the defines 
*  for the modes.  Removed micropdf.h and moved the contents of micropdf.h
*  into  this file. 
*  Revision 1.4  1997/04/23 18:41:04  toml
*  Added PDFECIEncode entry point
*  Revision 1.3  1997/04/01 07:30:00  toml
*  Masked shave count field beforing or'ing into wParam in macros
*  Revision 1.2  1997/03/13 20:23:46  toml
*  Removed metafile stuff from PDFObject record.
*  Revision 1.1  1997/02/19 22:28:42  toml
*  Initial revision
*
*  Description:      Main include file for PDF encoder API.
*
**********************************************************************/
#ifndef  __PDFAPI_H__
#define  __PDFAPI_H__

#include "machine.h"    /* defines basic data types and sizes */

#ifdef __cplusplus
extern "C" {
#endif

/*
* Define generic types used throughout API
*/
typedef uint16 CW;         /* data type capable of holding a single codeword */
typedef uint8 BUFDATA;     /* input/output basic unit */

/* 98.04.14  #if (ENVTYPE & PDF_E_WINMASK) != 0  *//* Win16/32 system */
/* 98.04.14                                                */
/* 98.04.14    * For windows environments, we know we have already included the         */
/* 98.04.14    * windows.h header file so we have all definitions we already need. We        */
/* 98.04.14    * just map the windows definitions to ours                    */
/* 98.04.14                                                */
/* 98.04.14    typedef LONG   FILEPOS;                                  */ /* file position indicator */
/* 98.04.14                                             */
/* 98.04.14 #  if (ENVTYPE == PDF_E_WIN32)                            */
/* 98.04.14       typedef HANDLE    FILEHANDLE;                            */
/* 98.04.14       typedef HANDLE    GENHANDLE;                            */
/* 98.04.14 #  else                                        */
/* 98.04.14       typedef HFILE     FILEHANDLE;                            */
/* 98.04.14       typedef HANDLE    GENHANDLE;                            */
/* 98.04.14 #  endif                                        */
/* 98.04.14 #else                                            */ /* DOS/other environments */
   typedef int16  FILEHANDLE;    /* open file handle for O/S */
   typedef long   FILEPOS;      /* file position indicator */
   typedef int16  GENHANDLE;
/* 98.04.14 #endif                                        */

/* 
   Pointer definitions: 
      LP -     full-size address specification prefix
      C  -     constant data prefix
      LPC -    full-size address specification to constant data
*/
/****************************************        B-N(伀)            *********************************/
/* typedef char FAR *LPSTRING;                                            */
/* typedef const char FAR *LPCSTRING;  *//* non-changing string */
/* typedef BUFDATA FAR *LPBUF;         *//* source data buffer type */
/* typedef const BUFDATA FAR *LPCBUF;                                        */
/* typedef void FAR *LPVOID;           *//* generic buffer pointer */
/* typedef const void FAR *LPCVOID;                                        */
/* typedef uint32 FAR *LPUINT32;                                        */
/* typedef uint16 FAR *LPUINT16;                                        */
/* typedef CW FAR *LPCW;               *//* symbol codeword buffer pointer */
/* typedef const CW FAR *LPCCW;                                            */

/* typedef uint32 PDFSIZET, FAR *LPPDFSIZET;                                    */

/* typedef BUFDATA FAR *LPMEMBUF;                                        */

typedef char *LPSTRING;
typedef const char *LPCSTRING;  /* non-changing string */
typedef BUFDATA *LPBUF;         /* source data buffer type */
typedef const BUFDATA *LPCBUF;
typedef void *LPVOID;           /* generic buffer pointer */
typedef const void *LPCVOID;
typedef uint32 *LPUINT32;
typedef uint16 *LPUINT16;
typedef CW *LPCW;               /* symbol codeword buffer pointer */
typedef const CW *LPCCW;

typedef uint32 PDFSIZET, *LPPDFSIZET;

typedef BUFDATA *LPMEMBUF;
/****************************************        B-N(仾)            *********************************/

#ifndef FALSE
#define  FALSE 0
#endif
#ifndef TRUE
#define  TRUE  1
#endif

#define  LoWord( l )       (uint16)( l )
#define  HiWord( l )       (uint16)( (uint32)l >> 16 )
#define  HiByte( w )       (uchar)( (w) >> 8 )
#define  LoByte( w )       (uchar)( w )
#define  MakeLAddr( p )    (uint32)( (LPVOID)&(p) )
#define  MakeLParam(hi,lo) ((uint32)(((uint16)(lo)) | (((uint32)((uint16)(hi))) << 16)))
#define  MakeWParam(hi,lo) ((uint16)(((uchar)(lo)) | (((uint16)((uchar)(hi))) << 8)))

#define  XDim2Dots(x,dpi)  (uint16)( ((double)(dpi) * (x)) + 0.5)

typedef int16 PDFSTATUS;
#define  ERR_NOERROR              0 /* successful completion */
#define  ERR_NULLDATASOURCE      -4 /* no input routine specified */
#define  ERR_INVALIDINPUTOBJECT  -5 /* PDFObject corrupt */
#define  ERR_TOOMANYCW           -7 /* re-size of barcode cannot contain data */
#define  ERR_NOTINPUTDEVICE      -8 /* PDFObject was not input type */
#define  ERR_OUTPUTDEVICE        -9 /* Error initializing output object --  */
                                    /* invalid type or memory alloc failure */
#define  ERR_NOFILTERSELECTED   -10 /* No output driver setup/installed */
#define  ERR_TOOMUCHDATA        -11 /* input data length exceed barcode */
#define  ERR_NOACTIVEBARCODE    -12 /* attempt to print/query without barcode */
#define  ERR_MPCBTOOMUCH        -14 /* barcode too small for MPDF info */
#define  ERR_TOOMANYMPDF        -16 /* too many barcodes for MPDF */
#define  ERR_ECCEXCEEDSCAPACITY -17 /* barcode too small for ECC specified */
#define  ERR_MEMORYALLOC        -20 /* failed to alloc temporary buffer */
#define  ERR_ARGUMENT           -21 /* Argument invalid: not supplied/range/etc */
#define  ERR_INVALIDECIESCAPE   -22 /* Ill-formed ECI escape sequence */ 
#define     ERR_C128CONTENT        -23 /* invalid data in code128 emulation input */
#define  ERR_INVALIDMACROCHAR   -24 /* Ill-formed macro character substitution sequence in input*/ 
#define  ERR_FATALINTERNAL      -99 /* internal API error */

#define  STATUS_NOMOREBARCODES    0
#define  STATUS_ENCODEOK          1
#define  STATUS_RENDEROK          ERR_NOERROR

/*
   File/Memory/Function Object Creation
*/
#define  PDFINPUT    1     /* ioDirection specifier for PDFObject */
#define  PDFOUTPUT   2

/*
* For Callback I/O object the following defines represent the values
* of the nCmd argument
*/
#define  PDFIO_READ        1     /* transfer nBytes from input into lpBufIO */
#define  PDFIO_WRITE       2     /* write nBytes to output */
#define  PDFIO_REWIND      3     /* rewind input to beginning */
#define  PDFIO_GETINLEN    4     /* return size of input stream */

#define  PDFIO_MAX_READ 2800  /* maximum PDFIO_READ request */

typedef PDFSIZET PDFCALLBACK FNPDFIO( int16 nCmd, LPBUF lpBufIO, uint16 nBytes, LPVOID lpGeneric );
/****************************************        B-N(伀)            *********************************/
/* typedef FNPDFIO FAR *LPFNPDFIO;    */
typedef FNPDFIO *LPFNPDFIO;
/****************************************        B-N(仾)            *********************************/

typedef struct s_pdfobject {
   uint16 ioType;             /* Input/Output */
   uint16 ioDirection;        /* File/Callback/Memory */
   PDFSIZET nLen;             /* (Bytes to encode)/(Bytes written) */

   union {
      LPMEMBUF lpMemBuffer;
      struct {
         LPFNPDFIO lpfnCallback;
         LPVOID lpAppArg;
      } func;
      struct {
         FILEHANDLE hFile;
         FILEPOS nInitPos;
         Bool fMustClose;
      } file;
      struct {
         LPMEMBUF lpMem;      /* For CF_TEXT clipboard input */
         uint16 fmtOutput;    /* API definition for output format */
      } clip;
   } access;
   Bool fIsHuge;
   LPVOID lpState;         /* internal state information/buffer */

} PDFObject;
/****************************************        B-N(伀)            *********************************/
/* typedef PDFObject FAR *LPPDFObject;    */
typedef PDFObject *LPPDFObject;
/****************************************        B-N(仾)            *********************************/

Bool PDFAPI MakeHugeMemoryObject( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase );
Bool PDFAPI MakeMemoryObject( LPPDFObject lpObj, uint16 ioDirection, LPVOID lpBase );
Bool PDFAPI MakeCallbackObject( LPPDFObject lpObj, uint16 ioDirection, LPFNPDFIO func, LPVOID lpArg );

Bool PDFAPI MakeFileObject( LPPDFObject lpObj, uint16 ioDirection, FILEHANDLE hFile );
Bool PDFAPI MakeFilenameObject( LPPDFObject lpObj, uint16 ioDirection, LPCSTRING lpcszFile );

Bool PDFAPI MakeClipboardObject( LPPDFObject lpObj, uint16 ioDirection, GENHANDLE dummy );

#define  MakeFunctionObject(pObj,io,pFunc)  MakeCallbackObject(pObj,io,(LPFNPDFIO)pFunc,(LPVOID)0)
#define  PDFSetCallbackParam( pObj, lparam )  (pObj)->access.func.lpAppArg = (LPVOID)lparam

/*
   Standard PDF417 API Routine Prototypes
*/
PDFSTATUS PDFAPI PDFEncode( LPPDFObject lpObjIn, PDFSIZET nInputLen );
PDFSTATUS PDFAPI PDFECIEncode( LPPDFObject lpObjIn, PDFSIZET nInputLen );
PDFSTATUS PDFAPI PDFMakeImage( LPPDFObject lpObjOut, LPPDFSIZET lpnBytesWritten );

Bool PDFAPI PDFSetAspect( LPCSTRING lpszAspect );
Bool PDFAPI PDFSetModuleAspect( uint16 aspect );
Bool PDFAPI PDFSetRowHeight( LPCSTRING lpszAspect );
Bool PDFAPI PDFSetRowCol( uint16 rows, uint16 cols );
Bool PDFAPI PDFSetECCPercent( uint16 percentage );
Bool PDFAPI PDFSetECCLevel( uint16 level );
Bool PDFAPI PDFAbort( LPPDFObject lpObj );
Bool PDFAPI PDFSetDefaults( void );
Bool PDFAPI PDFBinaryMode( Bool flag );
Bool PDFAPI PDFUseStrictECC( Bool fUseStrict );

Bool PDFAPI PDFSetCode128EmulationMode( int16 EmulMode );
/* set fdisable to TRUE to disable macro character substitution feature of MicroPDF - default is enabled */ 
Bool PDFAPI PDFNoMacroCharSubstitution( Bool fDisableIt ); 
/*
* Symbol "style" arguments for PDFSetSymbolStyle
*/
#define  STYLE_NORMAL         0
#define  STYLE_TRUNCATED      1

#define  STYLE_MASK           (uint16)0x00ff

Bool PDFAPI PDFSetSymbolStyle( uint16 fPDFStyle );
/*
* PDFTruncate() - Compatibility macro for versions 1.0 and 1.1
*/
#define PDFTruncate( flag )      PDFSetSymbolStyle( (flag ? STYLE_TRUNCATED : STYLE_NORMAL) )

/*
* Row/Column interpretation settings thru PDFSetDimType
*/
#define  USE_FIXED   0
#define  USE_LIMITS  1

Bool PDFAPI PDFSetDimType( uint16 fDimType );
/*
* Encoder version and build timestamp routines
*/
#define  PDFMAJOR(n)    (uint16)( (n) >> 8)
#define  PDFMINOR(n)    (uint16)( (n) & 0xff)

uint16 PDFAPI PDFGetVer( void );
LPCSTRING PDFAPI PDFGetCopyrightString( void );
LPCSTRING PDFAPI PDFGetTimestamp( void );    

#ifndef CWREC
#define CWREC
typedef struct s_cwrec {
   uint16 n;         /* number of codewords in data array */
   uint16 max_data;  /* maximum limit for 'n' -- leaves room in data[] */
   uint16 max_len;   /* maximum number that array can hold */
   CW data[1];       /* variable length data array */
} CWRec;
/****************************************        B-N(伀)            *********************************/
/* typedef CWRec FAR *LPCWRec;    */
typedef CWRec *LPCWRec;
/****************************************        B-N(仾)            *********************************/
#endif

LPCWRec PDFAPI PDFGetCodewords( void ) ;
LPCWRec PDFAPI PDFGetMicroPDFCodewords( void ) ;

/*
* PDF_W_C128EMULTATION: Code 128 emultation (MicroPDF) options
*/
#define  PDF128_EMUL_OFF         0
#define  PDF128_EMUL_C0          1  /* Simple Code 128 emulation */
#define  PDF128_EMUL_C1          2  /* UCC/EAN-128 FN1 in 1st position */
#define  PDF128_EMUL_C2          3  /* UCC/EAN-128 FN1 in 2nd position */
#define  PDF128_EMUL_LINKEDC1    4  /* UCC/EAN-128 C1 linked to 1D bar code */
/* note - if you add any other emulation constants - be sure to change the
** range check in PDFSetCode128EmulationMode
*/                               

#ifndef  __MICROPDF_H__
#define  __MICROPDF_H__

#ifndef NO_MICROPDF


#define  STYLE_MICRO         4

#define  MICRO_MASK          (uint16)0xff00
/*
* MicroPDF sizes enumberations
*/
#define  MICRO_1x11          ( 0 << 8)
#define  MICRO_1x14          ( 1 << 8)
#define  MICRO_1x17          ( 2 << 8)
#define  MICRO_1x20          ( 3 << 8)
#define  MICRO_1x24          ( 4 << 8)
#define  MICRO_1x28          ( 5 << 8)
#define  MICRO_2x8           ( 6 << 8)
#define  MICRO_2x11          ( 7 << 8)
#define  MICRO_2x14          ( 8 << 8)
#define  MICRO_2x17          ( 9 << 8)
#define  MICRO_2x20          (10 << 8)
#define  MICRO_2x23          (11 << 8)
#define  MICRO_2x26          (12 << 8)
#define  MICRO_3x6           (13 << 8)
#define  MICRO_3x8           (14 << 8)
#define  MICRO_3x10          (15 << 8)
#define  MICRO_3x12          (16 << 8)
#define  MICRO_3x15          (17 << 8)
#define  MICRO_3x20          (18 << 8)
#define  MICRO_3x26          (19 << 8)
#define  MICRO_3x32          (20 << 8)
#define  MICRO_3x38          (21 << 8)
#define  MICRO_3x44          (22 << 8)
#define  MICRO_4x6           (23 << 8)
#define  MICRO_4x8           (24 << 8)
#define  MICRO_4x10          (25 << 8)
#define  MICRO_4x12          (26 << 8)
#define  MICRO_4x15          (27 << 8)
#define  MICRO_4x20          (28 << 8)
#define  MICRO_4x26          (29 << 8)
#define  MICRO_4x32          (30 << 8)
#define  MICRO_4x38          (31 << 8)
#define  MICRO_4x44          (32 << 8)
#define  MICRO_4x4           (33 << 8)
#define  MICRO_INDEXCOUNT    34
#endif   /* NO_MICROPDF */
#endif   /* __MICROPDF_H__ */


/*
* Image formatter rendering options -- for graphic output
*/
#define  ROTATE_0          0x0000U
#define  ROTATE_90         0x0100U
#define  ROTATE_180        0x0200U
#define  ROTATE_270        0x0300U

#define  FLIP_NONE         0x0000U
#define  FLIP_VERT         0x1000U
#define  FLIP_HORIZ        0x2000U
#define  FLIP_BOTH         0x3000U

#define  BIT_INVERT        0x4000U   /* invert 1's and 0's in bitmap */

#define  BARWIDTH_REDUCE   0x0400U
#define  BARHEIGHT_REDUCE  0x0800U

#define  I_ROTATION        0x0300U   /* isolate the rotation code */
#define  I_TRANSFORMATION  0x3000U   /* isolate the transformation bits */
#define  I_STRIPOPTIONS    0x0c00U
#define  I_MASK            0x7f00U   /* isolate upper-nibble codes */
/*
* Programmable shaving counts for width and height in word option
* to output formatters. The lower two bits, 0 and 1 , are reserved
* for formatter option flags
*/
#define  I_WSHAVEMASK      0x00e0U   /* Bits 5 thru 7 */
#define  I_HSHAVEMASK      0x001cU   /* Bits 2 thru 4 */

#define  I_FMTOPTIONS      0x0003U   /* Bits 0 and 1 */

#define  ShaveWidthOption( nCount )    (unsigned)( \
            BARWIDTH_REDUCE | ((((nCount)-1) << 5) & I_WSHAVEMASK) )

#define  ShaveHeightOption( nCount )   (unsigned)( \
            BARHEIGHT_REDUCE | ((((nCount-1)) << 2) & I_HSHAVEMASK) )
/*
* Miscelaneous DPI and scaling defines for output formatters
*/
#define  P_DPI_100        (uint32)(100L << 16)
#define  P_DPI_300        (uint32)(300L << 16)
#define  P_DPI_600        (uint32)(600L << 16)
#define  P_DPI_1000       (uint32)(1000L << 16)
#define  P_DPI_1200       (uint32)(1200L << 16)

#define  DPI_SCALE1     1L
#define  DPI_SCALE2     2L
#define  DPI_SCALE3     3L
#define  DPI_SCALE4     4L
#define  DPI_SCALE5     5L
#define  DPI_SCALE6     6L
#define  DPI_SCALE7     7L
#define  DPI_SCALE8     8L
#define  DPI_SCALE9     9L
#define  DPI_SCALE10    10L

#define  DPI_100_AT_10MIL     (P_DPI_100 + DPI_SCALE1)    /* 10.0 mil */

#define  DPI_300_AT_6MIL      (P_DPI_300 + DPI_SCALE2)    /* 6.6 mil  */
#define  DPI_300_AT_10MIL     (P_DPI_300 + DPI_SCALE3)    /* 10.0 mil */

#define  DPI_600_AT_5MIL      (P_DPI_600 + DPI_SCALE3)    /* 5.0 mil  */
#define  DPI_600_AT_6MIL      (P_DPI_600 + DPI_SCALE4)    /* 6.6 mil  */
#define  DPI_600_AT_8MIL      (P_DPI_600 + DPI_SCALE5)    /* 8.3 mil  */
#define  DPI_600_AT_10MIL     (P_DPI_600 + DPI_SCALE6)    /* 10.0 mil */

#define  DPI_1200_AT_2_5MIL   (P_DPI_1200 + DPI_SCALE3)   /* 2.5 mil */
#define  DPI_1200_AT_4_2MIL   (P_DPI_1200 + DPI_SCALE5)   /* 4.2 mil */
#define  DPI_1200_AT_5_8MIL   (P_DPI_1200 + DPI_SCALE7)   /* 5.8 mil */
#define  DPI_1200_AT_7_5MIL   (P_DPI_1200 + DPI_SCALE9)   /* 7.5 mil */

typedef PDFSTATUS PDFAPI FNPDFFILTER( int16 cmd, LPPDFObject lpObj, LPVOID lpGeneric, uint32 l, uint16 w);
/****************************************        B-N(伀)            *********************************/
/* typedef FNPDFFILTER FAR *LPFNPDFFILTER;    */
typedef FNPDFFILTER *LPFNPDFFILTER;
/****************************************        B-N(仾)            *********************************/

Bool PDFAPI PDFOutputFilter( LPFNPDFFILTER func, uint32 lparam, uint16 wparam );
Bool PDFAPI PDFSetFilterWord( uint16 w );
Bool PDFAPI PDFSetFilterLong( uint32 l );
/*
* Compatability filter for older printer drivers:
*
*    PDFOutputAsPatterns( 0, 0 )
*    PDFOutputAsCodewords( 0, <True/False for inclusion of row indicators> )
*/
#define  ADD_ROWINDICATORS    0x0001
#define  DUMP_CODEWORDS       0x0002

Bool PDFAPI PDFOutputAsCodewords( uint32 lDummy, uint16 fAddRI );
Bool PDFAPI PDFOutputAsPatterns( uint32 lDummy, uint16 wDummy );

/*
* Windows Bitmap and Metafile Formatter (BMP/DIB/WMF)
*
*  PDFOutputAsDIBFile( uint32 lDpiScale, uint16 wImageOpts )
*  PDFOutputAsDIB( uint32 lDpiScale, uint16 wImageOpts )
*  PDFOutputAsWMF( uint32 lDpiScale, uint16 wImageOpts )
*
*  lDpiScale   MakeLParam( DPI, XDots ), If zero is specified the the default
*              size of 100 DPI and 10 mil X element will be used.
*  wImageOpts  ImageMode parameter
*
*  XDots is the number of printer dots to assign per X element of barcode.
*  This can be calculated using the macro: 
*     XDim2Dots( xdim, dpi )
*
*  PDFOutputAsDIBFile:  Produce a DIB image with a file header record.
*  PDFOutputAsDIB:      Produce memory version of DIB
*  PDFOutputAsWMF:      Windows metafile output format
*
*  Example, to produce a 300 DPI bitmap file for a barcode with 10 mil elements
*  which is rotated 270 degrees:
*
*  PDFOutputAsDIBFile( MakeLParam(300, XDim2Dots( 0.01, 300 )), ROTATE_270 );
*
*/
#define  DIB_ADDFILEHEADER    0x0001
#define  DIB_GENWMF           0x0002

Bool PDFAPI PDFOutputAsDIBFile( uint32 lDpiScale, uint16 wImageOpts );
Bool PDFAPI PDFOutputAsDIB( uint32 lDpiScale, uint16 wImageOpts );

/* 98.04.14 #if (ENVTYPE & PDF_E_WINMASK) != 0                            */
/* 98.04.14 Bool PDFAPI PDFOutputAsWMF( uint32 lDpiScale, uint16 wImageOpts );            */
/* 98.04.14 #endif                                        */
/*
* Tagged Image File Format Formatter (TIFF)
*
*  PDFOutputAsTIFF( uint32 lDpiScale, uint16 wImageOpts );
*   
*  lDpiScale   MakeLParam( DPI, XDots ), If zero is specified the the default
*              size of 100 DPI and 10 mil X element will be used.
*  wImageOpts  ImageMode parameter
*
*  XDots is the number of printer dots to assign per X element of barcode.
*  This can be calculated using the macro: 
*     XDim2Dots( xdim, dpi )
*
*  Example, to produce a 300 DPI bitmap for a barcode with 10 mil elements,
*
*  PDFOutputAsTIFF( MakeLParam( 300, XDim2Dots( 0.01, 300 ) ),
*                   ROTATE_0
*                 );
*/

Bool PDFAPI PDFOutputAsTIFF( uint32 lDpiScale, uint16 wImageOpts );

/*
* ZSoft Paintbrush File Formatter (PCX)
*
*  PDFOutputAsPCX( uint32 lDpiScale, uint16 wImageOpts );
*   
*  lDpiScale   MakeLParam( DPI, XDots ), If zero is specified the the default
*              size of 100 DPI and 10 mil X element will be used.
*  wImageOpts  ImageMode parameter
*
*  XDots is the number of printer dots to assign per X element of barcode.
*  This can be calculated using the macro: 
*     XDim2Dots( xdim, dpi )
*
*  Example, to produce a 300 DPI bitmap for a barcode with 10 mil elements
*
*  PDFOutputAsPCX( MakeLParam( 300, XDim2Dots( 0.01, 300 ) ),
*                   ROTATE_0
*                 );
*/

Bool PDFAPI PDFOutputAsPCX( uint32 lDpiScale, uint16 wImageOpts );

/*
* Hewlett-Packard Printer Control Language Formatter (PCL)
*
*  PDFOutputAsPCL( uint32 lDpiScale, uint16 wImageOpts );
*  PDFOutputAsPCL5( uint32 lDpiScale, uint16 wImageOpts );
*   
*  lDpiScale   MakeLParam( DPI, XDots ), If zero is specified the the default
*              size of 100 DPI and 10 mil X element will be used.
*  wImageOpts  ImageMode parameter
*
*  Note: PDFOutputAsPCL5 will produce an image using PCL Level 5 delta
*        compression. This compression scheme, available only on printers
*        will Language Level 5 or better, can greatly reduce the amount
*        of data required to render the barcode -- requires less time to
*        download to printer.
*
*  XDots is the number of printer dots to assign per X element of barcode.
*  This can be calculated using the macro: 
*     XDim2Dots( xdim, dpi )
*
*  Example, to produce a 300 DPI bitmap for a barcode with 10 mil elements
*  which is rotated 270 degrees using delta-mode-compression:
*
*  PDFOutputAsPCL5( MakeLParam( 300, XDim2Dots( 0.01, 300 ) ),
*                   ROTATE_270
*                 );
*/
/*
*  This structure represents the format of the output image header record.
*  This can be used to change the presentation mode after receiving it 
*  from PDFMakeImage()
*/
typedef struct {
   struct {             /* presentaion mode */
      uchar prefix[3];     /* '<ESC>*r' */
      uchar mode[1];       /* '0' -- print in logical page orientation */
      uchar term[1];       /* 'F' */
   } present_mode;
   struct {             /* raster graphics DPI */
      uchar prefix[3];     /* '<ESC>*t' */
      uchar value[3];      /* 3 digit ASCII value (075,100,150,300,600) */
      uchar term[1];       /* 'R' */
   } dpi;
   struct {
      uchar cmd[5];        /* '<ESC>*r1A' -- start raster graphics */
   } begin;
   uchar raster_data[1];/* variable length data block */
} PCLHeader;
/****************************************        B-N(伀)            *********************************/
/* typedef PCLHeader FAR *LPPCLHeader;    */
typedef PCLHeader *LPPCLHeader;
/****************************************        B-N(仾)            *********************************/

#define  PCL_DELTACOMPRESSION    0x0001

Bool PDFAPI PDFOutputAsPCL( uint32 lDpiScale, uint16 wImageOpts );
Bool PDFAPI PDFOutputAsPCL5( uint32 lDpiScale, uint16 wImageOpts );

/*
* Adobe Encapsulated PostScript Formatter (EPS)
*
*  PDFOutputAsEPS( uint32 lXDim, uint16 wImageOpts );
*  PDFOutputAsEPSI( uint32 lXDim, uint16 wImageOpts );
*   
*  lXDim       X element dimension for barcode using the EPSXDim() macro
*              to produce the result. The output is a fixed, decimal 
*              floating point number.
*  wImageOpts  ImageMode parameter
*
*  Note: PDFOutputAsEPSI produces an EPS with embedded preview image. The
*        preview image is rendered in Encapsulated PostScript Interchange
*        format.
*
*  Example, to produce a 10 mil barcode with preview image included:
*
*     PDFOutputAsEPS( EPSXDim( 0.01 ), ROTATE_0 );
*/
#define  FIXEDPT        1000000.0  /* convert float to 6 decimal places */
#define  EPS_PREVIEW    0x0001     /* include interchange fmt preview image */

#define  EPSXDim(x)     (uint32)( ((x) * FIXEDPT) + 0.5 )

Bool PDFAPI PDFOutputAsEPS( uint32 lXDim, uint16 wImageOpts );
Bool PDFAPI PDFOutputAsEPSI( uint32 lXDim, uint16 wImageOpts );

/*
* Epson 24-Pin  Formatter (EPN)
*
*  PDFOutputAsEpson24( uint32 lPositionScale, uint16 wImageOpts );
*   
*  lPositionScale  Contains the distance from the left margin that the PDF is
*                  to be printed and the X element scaling factor. The high-
*                   order word contains the positioning values (in units of 
*                  1/60th of an inch) and the low-order word contains the scale.
*                   The default is 0 unit from the left margin and scale of 1 - 
*                  5.56 mil. X element size. The epson printer is 180 dpi.
*
*  wImageOpts     ImageMode parameter
*
*  Note: PDFOutputAsEPSI produces an EPS with embedded preview image. The
*        preview image is rendered in Encapsulated PostScript Interchange
*        format.
*
*  Example, to produce a 11.11 mil barcode 1 inch from the left margin:
*
*     PDFOutputAsEpson24( 0x003c0002, ROTATE_0 | EPSON_POSITION_CMD );
*/
#define  EPSON_BIDIRECTIONAL        0x0001
    
Bool PDFAPI PDFOutputAsEpson24( uint32 lPositionScale, uint16 wImageOpts );

/*
* Epson 9-Pin  Formatter (EPN)
*
*  PDFOutputAsEpson9( uint32 lPositionScale, uint16 wImageOpts );
*   
*  lPositionScale  Contains the distance from the left margin that the PDF is
*                  to be printed and the X element scaling factor. The high-
*                   order word contains the positioning values (in units of 
*                  1/60th of an inch) and the low-order word contains the scale.
*                   The default is 0 unit from the left margin and scale of 1 - 
*                  5.56 mil. X element size. The epson printer is 180 dpi.
*
*  wImageOpts     ImageMode parameter
*
*  Note: PDFOutputAsEPSI produces an EPS with embedded preview image. The
*        preview image is rendered in Encapsulated PostScript Interchange
*        format.
*
*  Example, to produce a 27.77 mil barcode 1 inch from the left margin:
*
*     PDFOutputAsEpson9( 0x003c0002, ROTATE_0 | EPSON_POSITION_CMD );
*/
Bool PDFAPI PDFOutputAsEpson9( uint32 lPositionScale, uint16 wImageOpts );

#pragma pack(2)
typedef struct {
   PDFSIZET nSizeEstimate;   /* number of bytes required to render image */
   uint16   nWidth, nHeight; /* width and height of barcode (in elements) */
   uint16   nPadCW;          /* padding codewords applied to barcode */
   uint16   nMpdfCW;         /* MPDF codewords applied to barcode */
   uint16   nDataCW;         /* data codewords applied to barcode */
   uint16   nEccCW;          /* error correction codewords applied to barcode */
   uint16   nStyle;          /* STYLE_NORMAL/STYLE_TRUNCATED */
   uint16   nRows, nCols;    /* data rows and columns for barcode */
   uint16   nEccLevel;       /* error correction level 0-8 */
} PDFDetailRec;
/****************************************        B-N(伀)            *********************************/
/* typedef PDFDetailRec FAR *LPPDFDetailRec;    */
typedef PDFDetailRec *LPPDFDetailRec;
/****************************************        B-N(仾)            *********************************/
#pragma pack()    /* revert to standard packing */

Bool PDFAPI PDFGetDetails( LPPDFDetailRec lpDetailRec );
Bool PDFAPI PDFGetScaledDetails( LPPDFDetailRec lpDetailRec, uint16 nScale );

/*
   Macro PDF Routine Prototypes
*/
Bool PDFAPI MPDFDisable( void );
Bool PDFAPI MPDFEnable( void );   /* will clear/disable all optional fields */
Bool PDFAPI MPDFTimeStamp( Bool flag, uint32 time );
Bool PDFAPI MPDFFileSize( Bool flag );
Bool PDFAPI MPDFFileID( LPCSTRING lpszFileID );       /* NULL will generate random id */
Bool PDFAPI MPDFFileName( LPCSTRING lpszFileName );   /* NULL will disable */
Bool PDFAPI MPDFSenderID( LPCSTRING lpszSender );     /* NULL will disable */
Bool PDFAPI MPDFAddresseeID( LPCSTRING lpszAddressee );  /* NULL will disable */
Bool PDFAPI MPDFBlockCount( Bool flag );
Bool PDFAPI MPDFChecksum( Bool flag );

uint32 PDFAPI MPDFQueryBlockCount( void ); /* valid only if BlockCount enabled */
Bool PDFAPI MPDFIsEnabled( void );
Bool PDFAPI MPDFWasLast( void );

#ifdef __cplusplus
}
#endif

#endif
 

  • 23
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值