Here you go,

Ludo

-----Message d'origine-----
De : fpc-pascal-boun...@lists.freepascal.org
[mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Marcos
Douglas
Envoyé : mercredi 18 mai 2011 19:37
À : FPC-Pascal users discussions
Objet : Re: RE : RE : [fpc-pascal] Re: PDFlib TET - convert using h2pas


On Wed, May 18, 2011 at 1:28 PM, Ludo Brands <ludo.bra...@free.fr> wrote:
> >From your question COM or header, I assumed you are only interested 
> >in
> windows. I also assume that you don't want to export functions 
> defiend. So, I did the following:
> - removed PDFLIB_API and PDFLIB_CALL (point 1 in my previous message)
> - replaced the L".." defines by one to the char version (point 2)

Yeah!
I did the 2 points above, like you... but I can't compile yet. Other errors
occurred.

> The result from h2pas is attached. What needs to be done:
> - add stdcall; behind all functions that had PDFLIB_API. Both in 
> interface and implementation part.
> - if you are linking dynamically replace in the functions that had 
> PDFLIB_CALL in the implementation part
>  begin
>    { You must implement this function }
>  end;
> with
>  external 'name of the lib';
> - as always, review the translation

Can you send the tetlib.h that you modified? With it I can run h2pas again
with others parameters, like external lib, stdcall, type conversion, etc.

Thank you.

Marcos Douglas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
/*---------------------------------------------------------------------------*
 |          Copyright (c) 2002-2010 PDFlib GmbH. All rights reserved.        |
 +---------------------------------------------------------------------------+
 |    This software may not be copied or distributed except as expressly     |
 |    authorized by PDFlib GmbH's general license agreement or a custom      |
 |    license agreement signed by PDFlib GmbH.                               |
 |    For more information about licensing please refer to www.pdflib.com.   |
 *---------------------------------------------------------------------------*/

/* $Id: tetlib.h,v 1.165.2.13 2011/01/31 13:20:32 rjs Exp $
 *
 * TET public function declarations
 *
 */

/*
 * ----------------------------------------------------------------------
 * Setup, mostly Windows calling conventions and DLL stuff
 * ----------------------------------------------------------------------
 */

#ifndef TETLIB_H
#define TETLIB_H

#include <stdio.h>
#include <setjmp.h>

#if defined(WIN32) && !defined(PDFLIB_CALL)
#define PDFLIB_CALL     __cdecl
#endif

#undef PDFLIB_API

#ifndef PDFLIB_CALL
    #define PDFLIB_CALL /* */   /* default: no special calling conventions */
#endif

#ifndef PDFLIB_API
    #define PDFLIB_API /* */     /* default: generate or use static library */
#endif

/* Make our declarations C++ compatible */
#ifdef __cplusplus
extern "C" {
#endif

/*
 * There's a redundant product name literal elsewhere that needs to be
 * changed with this one!
 */
#define IFILTER_PRODUCTNAME     "TET PDF IFilter"
#define IFILTER_WCHAR_PRODUCTNAME IFILTER_PRODUCTNAME
#define IFILTER_PRODUCTDESCR    "PDFlib TET PDF IFilter"
#define IFILTER_COPYRIGHT \
        "(c) 2002-2010 PDFlib GmbH  www.pdflib.com  sa...@pdflib.com\n"

#define IFILTER_MAJORVERSION    4
#define IFILTER_MINORVERSION    0
#define IFILTER_REVISION        0

/* Patched by the dist/ifilter/version.pl script */
#define IFILTER_SHORT_VERSIONSTRING     "4"
#define IFILTER_WCHAR_SHORT_VERSIONSTRING       IFILTER_SHORT_VERSIONSTRING
#define IFILTER_LONG_VERSIONSTRING      "4.0p7"
#define IFILTER_WCHAR_LONG_VERSIONSTRING        IFILTER_WCHAR_LONG_VERSIONSTRING

#define TET_PRODUCTNAME         "TET"
#define TET_PRODUCTDESCR        "PDFlib Text Extraction Toolkit"
#define TET_COPYRIGHT \
        "(c) 2002-2010 PDFlib GmbH  www.pdflib.com  sa...@pdflib.com\n"

#define TET_MAJORVERSION        4
#define TET_MINORVERSION        0
#define TET_REVISION            0
/* ALWAYS change all version strings in the same way */
#define TET_SHORT_VERSIONSTRING          "4"
#define TET_WCHAR_SHORT_VERSIONSTRING   TET_SHORT_VERSIONSTRING
#define TET_LONG_VERSIONSTRING           "4.0p7"
#define TET_WCHAR_LONG_VERSIONSTRING    TET_LONG_VERSIONSTRING

/* Opaque data type for the TET context. */
#if !defined(TET) || defined(ACTIVEX)
typedef struct TET_s TET;
#endif

/* The API structure with function pointers. */
typedef struct TET_api_s TET_api;

/*
 * ----------------------------------------------------------------------
 * pCOS-specific enums and defines
 * ----------------------------------------------------------------------
 */

/*
 * Guard against multiple definition of pcos_mode and pcos_object_type for the
 * case that multiple PDFlib products are used in the same program.
 */
#ifndef PDF_PCOS_ENUMS

/* document access levels.
*/
typedef enum
{
    pcos_mode_minimum    = 0, /* encrypted doc (opened w/o password)          */
    pcos_mode_restricted = 1, /* encrypted doc (opened w/ user password)      */
    pcos_mode_full       = 2  /* unencrypted doc or opened w/ master password */
} pcos_mode;


/* object types.
*/
typedef enum
{
    pcos_ot_null        = 0,
    pcos_ot_boolean     = 1,
    pcos_ot_number      = 2,
    pcos_ot_name        = 3,
    pcos_ot_string      = 4,
    pcos_ot_array       = 5,
    pcos_ot_dict        = 6,
    pcos_ot_stream      = 7,
    pcos_ot_fstream     = 8
} pcos_object_type;

#define PDF_PCOS_ENUMS

#endif /* PDF_PCOS_ENUMS */


/*
 * ----------------------------------------------------------------------
 * TET-specific enums, structures, and defines
 * ----------------------------------------------------------------------
 */

/* Image formats returned by TET_write_image_file() */
typedef enum
{
    tet_if_error= -1,
    tet_if_auto =  0,
    tet_if_tiff = 10,
    tet_if_jpeg = 20,
    tet_if_jpx  = 30,
    tet_if_raw  = 40            /* unsupported */
} tet_image_format;

/* TET_char_info character types with real geometry info.
*/
#define TET_CT__REAL            0
#define TET_CT_NORMAL           0
#define TET_CT_SEQ_START        1

/* TET_char_info character types with artificial geometry info.
*/
#define TET_CT__ARTIFICIAL      10
#define TET_CT_SEQ_CONT         10
#define TET_CT_SUR_TRAIL        11      /* deprecated */
#define TET_CT_INSERTED         12


/* TET_char_info text rendering modes.
*/
#define TET_TR_FILL             0       /* fill text                          */
#define TET_TR_STROKE           1       /* stroke text (outline)              */
#define TET_TR_FILLSTROKE       2       /* fill and stroke text               */
#define TET_TR_INVISIBLE        3       /* invisible text                     */
#define TET_TR_FILL_CLIP        4       /* fill text and
                                           add it to the clipping path        */
#define TET_TR_STROKE_CLIP      5       /* stroke text and
                                           add it to the clipping path        */
#define TET_TR_FILLSTROKE_CLIP  6       /* fill and stroke text and
                                           add it to the clipping path        */
#define TET_TR_CLIP             7       /* add text to the clipping path      */




/* TET_char_info attributes
*/

#define TET_ATTR_NONE         0x00000000
#define TET_ATTR_SUB          0x00000001        /* subscript                */
#define TET_ATTR_SUP          0x00000002        /* superscript              */
#define TET_ATTR_DROPCAP      0x00000004        /* initial large letter     */
#define TET_ATTR_SHADOW       0x00000008        /* shadowed text            */

/* character before hyphenation     */
#define TET_ATTR_DEHYPHENATION_PRE       0x00000010
/* hyphenation artifact, i.e. the dash */
#define TET_ATTR_DEHYPHENATION_ARTIFACT  0x00000020
/* character after hyphenation     */
#define TET_ATTR_DEHYPHENATION_POST      0x00000040


/* ensure correct structure alignment */
#if _MSC_VER >= 1310  /* VS .NET 2003 and later */
#pragma pack(push)
#pragma pack(8)
#endif /* _MSC_VER >= 1310 */

typedef struct
{
    int         uv;             /* current character in UTF-32                */
    int         type;           /* character type, see TET_CT_* above         */
    int         unknown;        /* 1 if glyph couldn't be mapped to Unicode   */

    int         attributes;     /* character attributes, see TET_ATTR_* above */

    double      x;              /* x position of the char's reference point   */
    double      y;              /* y position of the char's reference point   */
    double      width;          /* horizontal character extent                */
    double      alpha;          /* text baseline angle in degrees             */
    double      beta;           /* vertical character slanting angle          */

    int         fontid;         /* pCOS font id                               */
    double      fontsize;       /* size of the font                           */


    int         textrendering;  /* text rendering mode, see TET_TR_* above    */
} TET_char_info;


typedef struct
{
    double      x;              /* x position of the image's reference point */
    double      y;              /* y position of the image's reference point */
    double      width;          /* width and height of the image on the page */
    double      height;         /* in points, measured along the edges       */
    double      alpha;          /* direction of the pixel rows (in degrees)  */
    double      beta;           /* direction of columns, relative to the     */
                                /* perpendicular of alpha                    */
    int         imageid;        /* pCOS image id                             */
} TET_image_info;

#if _MSC_VER >= 1310  /* VS .NET 2003 and later */
#pragma pack(pop)
#endif /* _MSC_VER >= 1310 */


/*
 * ----------------------------------------------------------------------
 * TET API functions
 * ----------------------------------------------------------------------
 */

/* Release a document handle and all internal resources related to that
   document. */
 void 
TET_close_document(
    TET *tet,
    int doc);

/* Release a page handle and all related resources. */
 void 
TET_close_page(
    TET *tet,
    int page);

/* Create a named virtual read-only file from data provided in memory. */
 void 
TET_create_pvf(
    TET *tet,
    const char *filename,
    int len,
    const void *data,
    size_t size,
    const char *optlist);

/* Delete a TET object and release all related internal resources. */
 void 
TET_delete(TET *tet);

/* Delete a named virtual file and free its data structures (but not the
   contents).
   Returns: -1 if the virtual file exists but is locked, and
             1 otherwise.
 */
 int 
TET_delete_pvf(
    TET *tet,
    const char *filename,
    int len);

/*
 * Retrieve a structure with TET API function pointers (mainly for DLLs).
 * Although this function is published here, it is not supposed to be used
 * directly by clients. Use TET_new_dl() in tetlibdl.c instead.
 */
 const TET_api * 
TET_get_api(void);

/* Get the name of the API function which caused an exception or failed. */
 const char * 
TET_get_apiname(
    TET *tet);

/* Get detailed information for the next character in the most recent
   text fragment. */
 const TET_char_info * 
TET_get_char_info(
    TET *tet,
    int page);

/* Get the text of the last thrown exception or the reason for a failed
   function call. */
 const char * 
TET_get_errmsg(
    TET *tet);

/* Get the number of the last thrown exception or the reason for a failed
   function call. */
 int 
TET_get_errnum(
    TET *tet);

/* Retrieve image data in memory. */
 const char * 
TET_get_image_data(
    TET *tet,
    int doc,
    size_t *length,
    int imageid,
    const char *optlist);

/* Retrieve information about the next image on the page (but not the actual
   pixel data). */
 const TET_image_info * 
TET_get_image_info(
    TET *tet,
    int page);

/* Fetch the opaque client pointer from with a TET context. Unsupported. */
 void * 
TET_get_opaque(TET *tet);

/* Get the next text fragment from a page's content. */
 const char * 
TET_get_text(
    TET *tet,
    int page,
    int *len);

/* Create a new TET object. */
 TET * 
TET_new(void);

/* Create a new TET context with a user-supplied error handler and
** opaque pointer. Unsupported.
*/
typedef void (*tet_error_fp)(TET *tet, int type, const char *msg);

 TET * 
TET_new2(tet_error_fp errorhandler, void *opaque);

/* Open a disk-based or virtual PDF document for content extraction. */
 int 
TET_open_document(
    TET *tet,
    const char *filename,
    int len,
    const char *optlist);

/* Open a PDF document from a custom data source for content extraction. */
 int 
TET_open_document_callback(
    TET *tet,
    void *opaque,
    size_t filesize,
    size_t (*readproc)(void *opaque, void *buffer, size_t size),
    int (*seekproc)(void *opaque, long offset),
    const char *optlist);

/* Deprecated; use TET_create_pvf( ) and TET_open_document( ). */
 int 
TET_open_document_mem(
    TET *tet,
    const void *data,
    size_t size,
    const char *optlist);

/* Open a page for content extraction. */
 int 
TET_open_page(
    TET *tet,
    int doc,
    int pagenumber,
    const char *optlist);

/* Get the value of a pCOS path with type number or boolean. */
 double 
TET_pcos_get_number(
    TET *tet,
    int doc,
    const char *path, ...);

/* Get the value of a pCOS path with type name, string or boolean. */
 const char * 
TET_pcos_get_string(
    TET *tet,
    int doc,
    const char *path, ...);

/* Get the contents of a pCOS path with type stream, fstream, or string. */
 const unsigned char * 
TET_pcos_get_stream(
    TET *tet,
    int doc,
    int *length,
    const char *optlist,
    const char *path, ...);

/* Set one or more global options for TET. */
 void 
TET_set_option(
    TET *tet,
    const char *optlist);

/* Convert a string from UTF-16 format to UTF-8. */
 const char * 
TET_utf16_to_utf8(
    TET *tet,
    const char *utf16string,
    int len,
    int *size);

/* Convert a string from UTF-8 format to UTF-16. */
 const char * 
TET_utf8_to_utf16(
   TET *tet,
   const char *utf8string,
   const char *ordering,
   int *size);

/* Convert a string from UTF-32 format to UTF-16. */
 const char * 
TET_utf32_to_utf16(
   TET *tet,
   const char *utf32string,
   int len,
   const char *ordering,
   int *size);

/* Convert a string from UTF-16 format to UTF-32 */
 const char * 
TET_utf16_to_utf32(
    TET *tet,
    const char *utf16string,
    int len,
    const char *ordering,
    int *size);

/* Convert a string from UTF-8 format to UTF-32 */
 const char * 
TET_utf8_to_utf32(
    TET *tet,
    const char *utf8string,
    const char *ordering,
    int *size);

/* Convert a string from UTF-32 format to UTF-8 */
 const char * 
TET_utf32_to_utf8(
    TET *tet,
    const char *utf32string,
    int len,
    int *size);

/* Write image data to disk. */
 int 
TET_write_image_file(
    TET *tet,
    int doc,
    int imageid,
    const char *optlist);

/* Process a page and create TETML output. */
 int 
TET_process_page(
    TET *tet,
    int doc,
    int pageno,
    const char *optlist);

/* Retrieve data from memory. */
 const char * 
TET_get_xml_data(
    TET *tet,
    int doc,
    size_t *length,
    const char *optlist);

/* Deflate a Unicode string (UTF-16 or UTF-32) to a byte string (unsupported)
*/
 const char * 
TET_deflate_unicode(
    TET *tet,
    const char *utfstring,
    int len,
    int charsize,
    int *highchar);

/*
 * ----------------------------------------------------------------------
 * TET API structure with function pointers to all API functions
 * ----------------------------------------------------------------------
 */

typedef struct
{
    jmp_buf     jbuf;
} tet_jmpbuf;

/* The API structure with pointers to all PDFlib API functions */
struct TET_api_s
{
    /* version numbers for checking the DLL against client code */
    size_t sizeof_TET_api; /* size of this structure */

    int major; /* TET major version number */
    int minor; /* TET minor version number */
    int revision; /* TET revision number */

    int reserved; /* reserved */

    void ( * TET_close_document)(TET *tet, int doc);
    void ( * TET_close_page)(TET *tet, int page);
    void ( * TET_create_pvf)(TET *tet, const char *filename,
            int len, const void *data, size_t size, const char *optlist);
    const char * ( * TET_deflate_unicode)(TET *tet,
            const char *utfstring, int len, int charsize, int *highchar);
    void ( * TET_delete)(TET *tet);
    int ( * TET_delete_pvf)(TET *tet, const char *filename, int len);
    const TET_api * ( * TET_get_api)(void);
    const char * ( * TET_get_apiname)(TET *tet);
    const TET_char_info * ( * TET_get_char_info)(TET *tet, int page);
    const char * ( * TET_get_errmsg)(TET *tet);
    int ( * TET_get_errnum)(TET *tet);
    const char * ( * TET_get_image_data)(TET *tet, int doc,
            size_t *length, int imageid, const char *optlist);
    const TET_image_info * ( * TET_get_image_info)(TET *tet,
            int page);
    void * ( * TET_get_opaque)(TET *tet);
    const char * ( * TET_get_text)(TET *tet, int page, int *len);
    const char * ( * TET_get_xml_data)(TET *tet, int doc,
            size_t *length, const char *optlist);
    TET * ( * TET_new)(void);
    TET * ( * TET_new2)(tet_error_fp errorhandler, void *opaque);
    int ( * TET_open_document)(TET *tet, const char *filename,
            int len, const char *optlist);
    int ( * TET_open_document_callback)(TET *tet, void *opaque,
            size_t filesize, size_t(*readproc)(void *opaque, void *buffer,
                    size_t size), int(*seekproc)(void *opaque, long offset),
            const char *optlist);
    int ( * TET_open_document_mem)(TET *tet, const void *data,
            size_t size, const char *optlist);
    int ( * TET_open_page)(TET *tet, int doc, int pagenumber,
            const char *optlist);
    double ( * TET_pcos_get_number)(TET *tet, int doc,
            const char *path, ...);
    const unsigned char * ( * TET_pcos_get_stream)(TET *tet,
            int doc, int *length, const char *optlist, const char *path, ...);
    const char * ( * TET_pcos_get_string)(TET *tet, int doc,
            const char *path, ...);
    int ( * TET_process_page)(TET *tet, int doc, int pageno,
            const char *optlist);
    void ( * TET_set_option)(TET *tet, const char *optlist);
    const char * ( * TET_utf16_to_utf32)(TET *tet,
            const char *utf16string, int len, const char *ordering, int *size);
    const char * ( * TET_utf16_to_utf8)(TET *tet,
            const char *utf16string, int len, int *size);
    const char * ( * TET_utf32_to_utf16)(TET *tet,
            const char *utf32string, int len, const char *ordering, int *size);
    const char * ( * TET_utf32_to_utf8)(TET *tet,
            const char *utf32string, int len, int *size);
    const char * ( * TET_utf8_to_utf16)(TET *tet,
            const char *utf8string, const char *ordering, int *size);
    const char * ( * TET_utf8_to_utf32)(TET *tet,
            const char *utf8string, const char *ordering, int *size);
    int ( * TET_write_image_file)(TET *tet, int doc, int imageid,
            const char *optlist);

    tet_jmpbuf * ( * tet_jbuf)(TET *tet);
    void ( * tet_exit_try)(TET *tet);
    int ( * tet_catch)(TET *tet);
    void ( * tet_rethrow)(TET *tet);
    void ( * tet_throw)(TET *tet, const char *parm1,
            const char *parm2, const char *parm3);
};

/*
 * ----------------------------------------------------------------------
 * Exception handling with try/catch implementation
 * ----------------------------------------------------------------------
 */

/* Set up an exception handling frame; must always be paired with TET_CATCH().
*/
#define TET_TRY(tet)            if (setjmp(tet_jbuf(tet)->jbuf) == 0)

/* Inform the exception machinery that a TET_TRY() will be left without
   entering the corresponding TET_CATCH( ) clause. */

#define TET_EXIT_TRY(tet)       tet_exit_try(tet)

/* Catch an exception; must always be paired with TET_TRY(). */

#define TET_CATCH(tet)          if (tet_catch(tet))

/* Re-throw an exception to another handler. */

#define TET_RETHROW(tet)        tet_rethrow(tet)


/*
 * ----------------------------------------------------------------------
 * Private stuff, do not use explicitly but only via the above macros!
 * ----------------------------------------------------------------------
 */

 tet_jmpbuf * 
tet_jbuf(
    TET *tet);

 void 
tet_exit_try(
    TET *tet);

 int 
tet_catch(
    TET *tet);

 void 
tet_rethrow(
    TET *tet);

 void 
tet_throw(
    TET *tet,
    const char *parm1,
    const char *parm2,
    const char *parm3);

#ifdef __cplusplus
}       /* extern "C" */
#endif

#endif /* TETLIB_H */


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to