How to call a C library?

New to FreeBASIC? Post your questions here.
Post Reply
haegartheroot
Posts: 114
Joined: Jul 27, 2007 15:45
Location: Bremen, Germany
Contact:

How to call a C library?

Post by haegartheroot »

Hi,

since about one week I'm working with FreeBasic. It's a great product.
Thanks to the developers!!!
Even some of my old QB DOS applications from the late 80s are running perfectly as native Linux programs.

But now I've a problem and need your help:
I found an open source C library named Haru Free PDF Library to create PDF files (http://libharu.sourceforge.net).

Now the questions:
- What needs to be done to call a new C library from FreeBasic (especially in Linux)?
- Do I have to create a .bi file for it?
- Is there a howto available explaining the steps required to use any C library API?

Haru Free PDF Library is a perfect tool for creating PDF files, because it can be used in any OS (DOS, Windows and Linux) and it's open source.

As a first step I like to create a small test program in FreeBasic that does the same as the C program below.

Code: Select all

/*
 * << Haru Free PDF Library 2.0.0 >> -- font_demo.c
 *
 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 * It is provided "as is" without express or implied warranty.
 *
 * Compile with:
 * ---------------------
 * gcc -o font_demo -O2 -Wall font_demo.c -lhpdf -lpng -lz -lm    
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "hpdf.h"

jmp_buf env;

#ifdef HPDF_DLL
void  __stdcall
#else
void
#endif
error_handler (HPDF_STATUS   error_no,
               HPDF_STATUS   detail_no,
               void         *user_data)
{
    printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no,
                (HPDF_UINT)detail_no);
    longjmp(env, 1);
}

const char *font_list[] = {
    "Courier",
    "Courier-Bold",
    "Courier-Oblique",
    "Courier-BoldOblique",
    "Helvetica",
    "Helvetica-Bold",
    "Helvetica-Oblique",
    "Helvetica-BoldOblique",
    "Times-Roman",
    "Times-Bold",
    "Times-Italic",
    "Times-BoldItalic",
    "Symbol",
    "ZapfDingbats",
    NULL
};

int main (int argc, char **argv)
{
    const char *page_title = "Font Demo";
    HPDF_Doc  pdf;
    char fname[256];
    HPDF_Page page;
    HPDF_Font def_font;
    HPDF_REAL tw;
    HPDF_REAL height;
    HPDF_REAL width;
    HPDF_UINT i;

    strcpy (fname, argv[0]);
    strcat (fname, ".pdf");

    pdf = HPDF_New (error_handler, NULL);
    if (!pdf) {
        printf ("error: cannot create PdfDoc object\n");
        return 1;
    }

    if (setjmp(env)) {
        HPDF_Free (pdf);
        return 1;
    }

    /* Add a new page object. */
    page = HPDF_AddPage (pdf);

    height = HPDF_Page_GetHeight (page);
    width = HPDF_Page_GetWidth (page);

    /* Print the lines of the page. */
    HPDF_Page_SetLineWidth (page, 1);
    HPDF_Page_Rectangle (page, 50, 50, width - 100, height - 110);
    HPDF_Page_Stroke (page);

    /* Print the title of the page (with positioning center). */
    def_font = HPDF_GetFont (pdf, "Helvetica", NULL);
    HPDF_Page_SetFontAndSize (page, def_font, 24);

    tw = HPDF_Page_TextWidth (page, page_title);
    HPDF_Page_BeginText (page);
    HPDF_Page_TextOut (page, (width - tw) / 2, height - 50, page_title);
    HPDF_Page_EndText (page);

    /* output subtitle. */
    HPDF_Page_BeginText (page);
    HPDF_Page_SetFontAndSize (page, def_font, 16);
    HPDF_Page_TextOut (page, 60, height - 80, "<Standerd Type1 fonts samples>");
    HPDF_Page_EndText (page);

    HPDF_Page_BeginText (page);
    HPDF_Page_MoveTextPos (page, 60, height - 105);

    i = 0;
    while (font_list[i]) {
        const char* samp_text = "abcdefgABCDEFG12345!#$%&+-@?";
        HPDF_Font font = HPDF_GetFont (pdf, font_list[i], NULL);

        /* print a label of text */
        HPDF_Page_SetFontAndSize (page, def_font, 9);
        HPDF_Page_ShowText (page, font_list[i]);
        HPDF_Page_MoveTextPos (page, 0, -18);

        /* print a sample text. */
        HPDF_Page_SetFontAndSize (page, font, 20);
        HPDF_Page_ShowText (page, samp_text);
        HPDF_Page_MoveTextPos (page, 0, -20);

        i++;
    }

    HPDF_Page_EndText (page);

    HPDF_SaveToFile (pdf, fname);

    /* clean up */
    HPDF_Free (pdf);

    return 0;
}
Thank you for your help!
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

Well, you don't need to port the entire library. Thank God it's in C :P You need to:

1.) Translate the c headers into fb headers. You can use SWIG to help you with this.
2.) Make sure an import library is available. (I think. Sorry I don't do much porting) You'll need the .a because of this :D
3.) Post the translated header and import library on the forums for all of us to enjoy!

I'm trying to find a tutorial, but am are be to lazy. I don't use SWIG >.>;; As for that code, I can't really say. Sorry ^.^;;
haegartheroot
Posts: 114
Joined: Jul 27, 2007 15:45
Location: Bremen, Germany
Contact:

Post by haegartheroot »

Hi,

I tried to translate the c headers into fb headers using SWIG.
Unfortunately only a few typedef's are not converted and I'm not a c expert ...
Do you know how to translate them manually ?

typedef void *HPDF_HANDLE;
typedef HPDF_HANDLE HPDF_Doc;
typedef HPDF_HANDLE HPDF_Page;
typedef HPDF_HANDLE HPDF_Pages;
typedef HPDF_HANDLE HPDF_Stream;
typedef HPDF_HANDLE HPDF_Image;
typedef HPDF_HANDLE HPDF_Font;
typedef HPDF_HANDLE HPDF_Outline;
typedef HPDF_HANDLE HPDF_Encoder;
typedef HPDF_HANDLE HPDF_Destination;
typedef HPDF_HANDLE HPDF_XObject;
typedef HPDF_HANDLE HPDF_Annotation;
typedef HPDF_HANDLE HPDF_ExtGState;

Thanks

NB: when everything is done I'll post the .bi files and (hopefully) a short example program which shows how to create PDF files.
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Post by voodooattack »

this translates to:

Code: Select all

type HPDF_HANDLE as any ptr
type HPDF_Doc as HPDF_HANDLE
type HPDF_Page as HPDF_HANDLE
type HPDF_Pages as HPDF_HANDLE
type HPDF_Stream as HPDF_HANDLE
type HPDF_Image as HPDF_HANDLE
type HPDF_Font as HPDF_HANDLE
type HPDF_Outline as HPDF_HANDLE
type HPDF_Encoder as HPDF_HANDLE
type HPDF_Destination as HPDF_HANDLE
type HPDF_XObject as HPDF_HANDLE
type HPDF_Annotation as HPDF_HANDLE
type HPDF_ExtGState as HPDF_HANDLE
maddogg6
Posts: 824
Joined: Dec 07, 2005 22:58
Contact:

Post by maddogg6 »

Sorry, I don't mean to hijack this thread - but I am curious about something...

Whats wrong/different with this?

Code: Select all

Type HPDF_Doc As Any Ptr
Type HPDF_Page As Any Ptr
Type HPDF_Pages As Any Ptr
...
I *thought* I understood pointers and types somewhat... but this confuses me.

edited to avoid confusing others....
Last edited by maddogg6 on Jul 28, 2007 0:44, edited 1 time in total.
haegartheroot
Posts: 114
Joined: Jul 27, 2007 15:45
Location: Bremen, Germany
Contact:

Post by haegartheroot »

Thanks a lot !

Here are the .bi files already.

hpdf_consts.bi

Code: Select all

''
''
'' hpdf_consts -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
''         be included in other distributions without authorization.
''
''
#ifndef __hpdf_consts_bi__
#define __hpdf_consts_bi__

#define HPDF_TRUE 1
#define HPDF_FALSE 0
#define HPDF_OK 0
#define HPDF_NOERROR 0
#define HPDF_TMP_BUF_SIZ 512
#define HPDF_SHORT_BUF_SIZ 32
#define HPDF_REAL_LEN 11
#define HPDF_INT_LEN 11
#define HPDF_TEXT_DEFAULT_LEN 256
#define HPDF_UNICODE_HEADER_LEN 2
#define HPDF_DATE_TIME_STR_LEN 23
#define HPDF_BYTE_OFFSET_LEN 10
#define HPDF_OBJ_ID_LEN 7
#define HPDF_GEN_NO_LEN 5
#define HPDF_DEF_FONT "Helvetica"
#define HPDF_DEF_WORDSPACE 0
#define HPDF_DEF_CHARSPACE 0
#define HPDF_DEF_FONTSIZE 10
#define HPDF_DEF_HSCALING 100
#define HPDF_DEF_LEADING 0
#define HPDF_DEF_RISE 0
#define HPDF_DEF_RAISE 0
#define HPDF_DEF_LINEWIDTH 1
#define HPDF_DEF_MITERLIMIT 10
#define HPDF_DEF_FLATNESS 1
#define HPDF_DEF_PAGE_NUM 1
#define HPDF_BS_DEF_WIDTH 1
#define HPDF_DEF_PAGE_WIDTH 595.276F
#define HPDF_DEF_PAGE_HEIGHT 841.89F
#define HPDF_VERSION_TEXT "2.0.8"
#define HPDF_COMP_NONE &h00
#define HPDF_COMP_TEXT &h01
#define HPDF_COMP_IMAGE &h02
#define HPDF_COMP_METADATA &h04
#define HPDF_COMP_ALL &h0F
#define HPDF_COMP_MASK &hFF
#define HPDF_ENABLE_READ 0
#define HPDF_ENABLE_PRINT 4
#define HPDF_ENABLE_EDIT_ALL 8
#define HPDF_ENABLE_COPY 16
#define HPDF_ENABLE_EDIT 32
#define HPDF_HIDE_TOOLBAR 1
#define HPDF_HIDE_MENUBAR 2
#define HPDF_HIDE_WINDOW_UI 4
#define HPDF_FIT_WINDOW 8
#define HPDF_CENTER_WINDOW 16
#define HPDF_LIMIT_MAX_INT 2147483647
#define HPDF_LIMIT_MIN_INT -2147483647
#define HPDF_LIMIT_MAX_REAL 32767
#define HPDF_LIMIT_MIN_REAL -32767
#define HPDF_LIMIT_MAX_STRING_LEN 65535
#define HPDF_LIMIT_MAX_NAME_LEN 127
#define HPDF_LIMIT_MAX_ARRAY 8191
#define HPDF_LIMIT_MAX_DICT_ELEMENT 4095
#define HPDF_LIMIT_MAX_XREF_ELEMENT 8388607
#define HPDF_LIMIT_MAX_GSTATE 28
#define HPDF_LIMIT_MAX_DEVICE_N 8
#define HPDF_LIMIT_MAX_DEVICE_N_V15 32
#define HPDF_LIMIT_MAX_CID 65535
#define HPDF_MAX_GENERATION_NUM 65535
#define HPDF_MIN_PAGE_HEIGHT 3
#define HPDF_MIN_PAGE_WIDTH 3
#define HPDF_MAX_PAGE_HEIGHT 14400
#define HPDF_MAX_PAGE_WIDTH 14400
#define HPDF_MIN_MAGNIFICATION_FACTOR 8
#define HPDF_MAX_MAGNIFICATION_FACTOR 3200
#define HPDF_MIN_PAGE_SIZE 3
#define HPDF_MAX_PAGE_SIZE 14400
#define HPDF_MIN_HORIZONTALSCALING 10
#define HPDF_MAX_HORIZONTALSCALING 300
#define HPDF_MIN_WORDSPACE -30
#define HPDF_MAX_WORDSPACE 300
#define HPDF_MIN_CHARSPACE -30
#define HPDF_MAX_CHARSPACE 300
#define HPDF_MAX_FONTSIZE 300
#define HPDF_MAX_ZOOMSIZE 10
#define HPDF_MAX_LEADING 300
#define HPDF_MAX_LINEWIDTH 100
#define HPDF_MAX_DASH_PATTERN 100
#define HPDF_MAX_JWW_NUM 128
#define HPDF_COUNTRY_AF "AF"
#define HPDF_COUNTRY_AL "AL"
#define HPDF_COUNTRY_DZ "DZ"
#define HPDF_COUNTRY_AS "AS"
#define HPDF_COUNTRY_AD "AD"
#define HPDF_COUNTRY_AO "AO"
#define HPDF_COUNTRY_AI "AI"
#define HPDF_COUNTRY_AQ "AQ"
#define HPDF_COUNTRY_AG "AG"
#define HPDF_COUNTRY_AR "AR"
#define HPDF_COUNTRY_AM "AM"
#define HPDF_COUNTRY_AW "AW"
#define HPDF_COUNTRY_AU "AU"
#define HPDF_COUNTRY_AT "AT"
#define HPDF_COUNTRY_AZ "AZ"
#define HPDF_COUNTRY_BS "BS"
#define HPDF_COUNTRY_BH "BH"
#define HPDF_COUNTRY_BD "BD"
#define HPDF_COUNTRY_BB "BB"
#define HPDF_COUNTRY_BY "BY"
#define HPDF_COUNTRY_BE "BE"
#define HPDF_COUNTRY_BZ "BZ"
#define HPDF_COUNTRY_BJ "BJ"
#define HPDF_COUNTRY_BM "BM"
#define HPDF_COUNTRY_BT "BT"
#define HPDF_COUNTRY_BO "BO"
#define HPDF_COUNTRY_BA "BA"
#define HPDF_COUNTRY_BW "BW"
#define HPDF_COUNTRY_BV "BV"
#define HPDF_COUNTRY_BR "BR"
#define HPDF_COUNTRY_IO "IO"
#define HPDF_COUNTRY_BN "BN"
#define HPDF_COUNTRY_BG "BG"
#define HPDF_COUNTRY_BF "BF"
#define HPDF_COUNTRY_BI "BI"
#define HPDF_COUNTRY_KH "KH"
#define HPDF_COUNTRY_CM "CM"
#define HPDF_COUNTRY_CA "CA"
#define HPDF_COUNTRY_CV "CV"
#define HPDF_COUNTRY_KY "KY"
#define HPDF_COUNTRY_CF "CF"
#define HPDF_COUNTRY_TD "TD"
#define HPDF_COUNTRY_CL "CL"
#define HPDF_COUNTRY_CN "CN"
#define HPDF_COUNTRY_CX "CX"
#define HPDF_COUNTRY_CC "CC"
#define HPDF_COUNTRY_CO "CO"
#define HPDF_COUNTRY_KM "KM"
#define HPDF_COUNTRY_CG "CG"
#define HPDF_COUNTRY_CK "CK"
#define HPDF_COUNTRY_CR "CR"
#define HPDF_COUNTRY_CI "CI"
#define HPDF_COUNTRY_HR "HR"
#define HPDF_COUNTRY_CU "CU"
#define HPDF_COUNTRY_CY "CY"
#define HPDF_COUNTRY_CZ "CZ"
#define HPDF_COUNTRY_DK "DK"
#define HPDF_COUNTRY_DJ "DJ"
#define HPDF_COUNTRY_DM "DM"
#define HPDF_COUNTRY_DO "DO"
#define HPDF_COUNTRY_TP "TP"
#define HPDF_COUNTRY_EC "EC"
#define HPDF_COUNTRY_EG "EG"
#define HPDF_COUNTRY_SV "SV"
#define HPDF_COUNTRY_GQ "GQ"
#define HPDF_COUNTRY_ER "ER"
#define HPDF_COUNTRY_EE "EE"
#define HPDF_COUNTRY_ET "ET"
#define HPDF_COUNTRY_FK "FK"
#define HPDF_COUNTRY_FO "FO"
#define HPDF_COUNTRY_FJ "FJ"
#define HPDF_COUNTRY_FI "FI"
#define HPDF_COUNTRY_FR "FR"
#define HPDF_COUNTRY_FX "FX"
#define HPDF_COUNTRY_GF "GF"
#define HPDF_COUNTRY_PF "PF"
#define HPDF_COUNTRY_TF "TF"
#define HPDF_COUNTRY_GA "GA"
#define HPDF_COUNTRY_GM "GM"
#define HPDF_COUNTRY_GE "GE"
#define HPDF_COUNTRY_DE "DE"
#define HPDF_COUNTRY_GH "GH"
#define HPDF_COUNTRY_GI "GI"
#define HPDF_COUNTRY_GR "GR"
#define HPDF_COUNTRY_GL "GL"
#define HPDF_COUNTRY_GD "GD"
#define HPDF_COUNTRY_GP "GP"
#define HPDF_COUNTRY_GU "GU"
#define HPDF_COUNTRY_GT "GT"
#define HPDF_COUNTRY_GN "GN"
#define HPDF_COUNTRY_GW "GW"
#define HPDF_COUNTRY_GY "GY"
#define HPDF_COUNTRY_HT "HT"
#define HPDF_COUNTRY_HM "HM"
#define HPDF_COUNTRY_HN "HN"
#define HPDF_COUNTRY_HK "HK"
#define HPDF_COUNTRY_HU "HU"
#define HPDF_COUNTRY_IS "IS"
#define HPDF_COUNTRY_IN "IN"
#define HPDF_COUNTRY_ID "ID"
#define HPDF_COUNTRY_IR "IR"
#define HPDF_COUNTRY_IQ "IQ"
#define HPDF_COUNTRY_IE "IE"
#define HPDF_COUNTRY_IL "IL"
#define HPDF_COUNTRY_IT "IT"
#define HPDF_COUNTRY_JM "JM"
#define HPDF_COUNTRY_JP "JP"
#define HPDF_COUNTRY_JO "JO"
#define HPDF_COUNTRY_KZ "KZ"
#define HPDF_COUNTRY_KE "KE"
#define HPDF_COUNTRY_KI "KI"
#define HPDF_COUNTRY_KP "KP"
#define HPDF_COUNTRY_KR "KR"
#define HPDF_COUNTRY_KW "KW"
#define HPDF_COUNTRY_KG "KG"
#define HPDF_COUNTRY_LA "LA"
#define HPDF_COUNTRY_LV "LV"
#define HPDF_COUNTRY_LB "LB"
#define HPDF_COUNTRY_LS "LS"
#define HPDF_COUNTRY_LR "LR"
#define HPDF_COUNTRY_LY "LY"
#define HPDF_COUNTRY_LI "LI"
#define HPDF_COUNTRY_LT "LT"
#define HPDF_COUNTRY_LU "LU"
#define HPDF_COUNTRY_MO "MO"
#define HPDF_COUNTRY_MK "MK"
#define HPDF_COUNTRY_MG "MG"
#define HPDF_COUNTRY_MW "MW"
#define HPDF_COUNTRY_MY "MY"
#define HPDF_COUNTRY_MV "MV"
#define HPDF_COUNTRY_ML "ML"
#define HPDF_COUNTRY_MT "MT"
#define HPDF_COUNTRY_MH "MH"
#define HPDF_COUNTRY_MQ "MQ"
#define HPDF_COUNTRY_MR "MR"
#define HPDF_COUNTRY_MU "MU"
#define HPDF_COUNTRY_YT "YT"
#define HPDF_COUNTRY_MX "MX"
#define HPDF_COUNTRY_FM "FM"
#define HPDF_COUNTRY_MD "MD"
#define HPDF_COUNTRY_MC "MC"
#define HPDF_COUNTRY_MN "MN"
#define HPDF_COUNTRY_MS "MS"
#define HPDF_COUNTRY_MA "MA"
#define HPDF_COUNTRY_MZ "MZ"
#define HPDF_COUNTRY_MM "MM"
#define HPDF_COUNTRY_NA "NA"
#define HPDF_COUNTRY_NR "NR"
#define HPDF_COUNTRY_NP "NP"
#define HPDF_COUNTRY_NL "NL"
#define HPDF_COUNTRY_AN "AN"
#define HPDF_COUNTRY_NC "NC"
#define HPDF_COUNTRY_NZ "NZ"
#define HPDF_COUNTRY_NI "NI"
#define HPDF_COUNTRY_NE "NE"
#define HPDF_COUNTRY_NG "NG"
#define HPDF_COUNTRY_NU "NU"
#define HPDF_COUNTRY_NF "NF"
#define HPDF_COUNTRY_MP "MP"
#define HPDF_COUNTRY_NO "NO"
#define HPDF_COUNTRY_OM "OM"
#define HPDF_COUNTRY_PK "PK"
#define HPDF_COUNTRY_PW "PW"
#define HPDF_COUNTRY_PA "PA"
#define HPDF_COUNTRY_PG "PG"
#define HPDF_COUNTRY_PY "PY"
#define HPDF_COUNTRY_PE "PE"
#define HPDF_COUNTRY_PH "PH"
#define HPDF_COUNTRY_PN "PN"
#define HPDF_COUNTRY_PL "PL"
#define HPDF_COUNTRY_PT "PT"
#define HPDF_COUNTRY_PR "PR"
#define HPDF_COUNTRY_QA "QA"
#define HPDF_COUNTRY_RE "RE"
#define HPDF_COUNTRY_RO "RO"
#define HPDF_COUNTRY_RU "RU"
#define HPDF_COUNTRY_RW "RW"
#define HPDF_COUNTRY_KN "KN"
#define HPDF_COUNTRY_LC "LC"
#define HPDF_COUNTRY_VC "VC"
#define HPDF_COUNTRY_WS "WS"
#define HPDF_COUNTRY_SM "SM"
#define HPDF_COUNTRY_ST "ST"
#define HPDF_COUNTRY_SA "SA"
#define HPDF_COUNTRY_SN "SN"
#define HPDF_COUNTRY_SC "SC"
#define HPDF_COUNTRY_SL "SL"
#define HPDF_COUNTRY_SG "SG"
#define HPDF_COUNTRY_SK "SK"
#define HPDF_COUNTRY_SI "SI"
#define HPDF_COUNTRY_SB "SB"
#define HPDF_COUNTRY_SO "SO"
#define HPDF_COUNTRY_ZA "ZA"
#define HPDF_COUNTRY_ES "ES"
#define HPDF_COUNTRY_LK "LK"
#define HPDF_COUNTRY_SH "SH"
#define HPDF_COUNTRY_PM "PM"
#define HPDF_COUNTRY_SD "SD"
#define HPDF_COUNTRY_SR "SR"
#define HPDF_COUNTRY_SJ "SJ"
#define HPDF_COUNTRY_SZ "SZ"
#define HPDF_COUNTRY_SE "SE"
#define HPDF_COUNTRY_CH "CH"
#define HPDF_COUNTRY_SY "SY"
#define HPDF_COUNTRY_TW "TW"
#define HPDF_COUNTRY_TJ "TJ"
#define HPDF_COUNTRY_TZ "TZ"
#define HPDF_COUNTRY_TH "TH"
#define HPDF_COUNTRY_TG "TG"
#define HPDF_COUNTRY_TK "TK"
#define HPDF_COUNTRY_TO "TO"
#define HPDF_COUNTRY_TT "TT"
#define HPDF_COUNTRY_TN "TN"
#define HPDF_COUNTRY_TR "TR"
#define HPDF_COUNTRY_TM "TM"
#define HPDF_COUNTRY_TC "TC"
#define HPDF_COUNTRY_TV "TV"
#define HPDF_COUNTRY_UG "UG"
#define HPDF_COUNTRY_UA "UA"
#define HPDF_COUNTRY_AE "AE"
#define HPDF_COUNTRY_GB "GB"
#define HPDF_COUNTRY_US "US"
#define HPDF_COUNTRY_UM "UM"
#define HPDF_COUNTRY_UY "UY"
#define HPDF_COUNTRY_UZ "UZ"
#define HPDF_COUNTRY_VU "VU"
#define HPDF_COUNTRY_VA "VA"
#define HPDF_COUNTRY_VE "VE"
#define HPDF_COUNTRY_VN "VN"
#define HPDF_COUNTRY_VG "VG"
#define HPDF_COUNTRY_VI "VI"
#define HPDF_COUNTRY_WF "WF"
#define HPDF_COUNTRY_EH "EH"
#define HPDF_COUNTRY_YE "YE"
#define HPDF_COUNTRY_YU "YU"
#define HPDF_COUNTRY_ZR "ZR"
#define HPDF_COUNTRY_ZM "ZM"
#define HPDF_COUNTRY_ZW "ZW"
#define HPDF_LANG_AA "aa"
#define HPDF_LANG_AB "ab"
#define HPDF_LANG_AF "af"
#define HPDF_LANG_AM "am"
#define HPDF_LANG_AR "ar"
#define HPDF_LANG_AS "as"
#define HPDF_LANG_AY "ay"
#define HPDF_LANG_AZ "az"
#define HPDF_LANG_BA "ba"
#define HPDF_LANG_BE "be"
#define HPDF_LANG_BG "bg"
#define HPDF_LANG_BH "bh"
#define HPDF_LANG_BI "bi"
#define HPDF_LANG_BN "bn"
#define HPDF_LANG_BO "bo"
#define HPDF_LANG_BR "br"
#define HPDF_LANG_CA "ca"
#define HPDF_LANG_CO "co"
#define HPDF_LANG_CS "cs"
#define HPDF_LANG_CY "cy"
#define HPDF_LANG_DA "da"
#define HPDF_LANG_DE "de"
#define HPDF_LANG_DZ "dz"
#define HPDF_LANG_EL "el"
#define HPDF_LANG_EN "en"
#define HPDF_LANG_EO "eo"
#define HPDF_LANG_ES "es"
#define HPDF_LANG_ET "et"
#define HPDF_LANG_EU "eu"
#define HPDF_LANG_FA "fa"
#define HPDF_LANG_FI "fi"
#define HPDF_LANG_FJ "fj"
#define HPDF_LANG_FO "fo"
#define HPDF_LANG_FR "fr"
#define HPDF_LANG_FY "fy"
#define HPDF_LANG_GA "ga"
#define HPDF_LANG_GD "gd"
#define HPDF_LANG_GL "gl"
#define HPDF_LANG_GN "gn"
#define HPDF_LANG_GU "gu"
#define HPDF_LANG_HA "ha"
#define HPDF_LANG_HI "hi"
#define HPDF_LANG_HR "hr"
#define HPDF_LANG_HU "hu"
#define HPDF_LANG_HY "hy"
#define HPDF_LANG_IA "ia"
#define HPDF_LANG_IE "ie"
#define HPDF_LANG_IK "ik"
#define HPDF_LANG_IN "in"
#define HPDF_LANG_IS "is"
#define HPDF_LANG_IT "it"
#define HPDF_LANG_IW "iw"
#define HPDF_LANG_JA "ja"
#define HPDF_LANG_JI "ji"
#define HPDF_LANG_JW "jw"
#define HPDF_LANG_KA "ka"
#define HPDF_LANG_KK "kk"
#define HPDF_LANG_KL "kl"
#define HPDF_LANG_KM "km"
#define HPDF_LANG_KN "kn"
#define HPDF_LANG_KO "ko"
#define HPDF_LANG_KS "ks"
#define HPDF_LANG_KU "ku"
#define HPDF_LANG_KY "ky"
#define HPDF_LANG_LA "la"
#define HPDF_LANG_LN "ln"
#define HPDF_LANG_LO "lo"
#define HPDF_LANG_LT "lt"
#define HPDF_LANG_LV "lv"
#define HPDF_LANG_MG "mg"
#define HPDF_LANG_MI "mi"
#define HPDF_LANG_MK "mk"
#define HPDF_LANG_ML "ml"
#define HPDF_LANG_MN "mn"
#define HPDF_LANG_MO "mo"
#define HPDF_LANG_MR "mr"
#define HPDF_LANG_MS "ms"
#define HPDF_LANG_MT "mt"
#define HPDF_LANG_MY "my"
#define HPDF_LANG_NA "na"
#define HPDF_LANG_NE "ne"
#define HPDF_LANG_NL "nl"
#define HPDF_LANG_NO "no"
#define HPDF_LANG_OC "oc"
#define HPDF_LANG_OM "om"
#define HPDF_LANG_OR "or"
#define HPDF_LANG_PA "pa"
#define HPDF_LANG_PL "pl"
#define HPDF_LANG_PS "ps"
#define HPDF_LANG_PT "pt"
#define HPDF_LANG_QU "qu"
#define HPDF_LANG_RM "rm"
#define HPDF_LANG_RN "rn"
#define HPDF_LANG_RO "ro"
#define HPDF_LANG_RU "ru"
#define HPDF_LANG_RW "rw"
#define HPDF_LANG_SA "sa"
#define HPDF_LANG_SD "sd"
#define HPDF_LANG_SG "sg"
#define HPDF_LANG_SH "sh"
#define HPDF_LANG_SI "si"
#define HPDF_LANG_SK "sk"
#define HPDF_LANG_SL "sl"
#define HPDF_LANG_SM "sm"
#define HPDF_LANG_SN "sn"
#define HPDF_LANG_SO "so"
#define HPDF_LANG_SQ "sq"
#define HPDF_LANG_SR "sr"
#define HPDF_LANG_SS "ss"
#define HPDF_LANG_ST "st"
#define HPDF_LANG_SU "su"
#define HPDF_LANG_SV "sv"
#define HPDF_LANG_SW "sw"
#define HPDF_LANG_TA "ta"
#define HPDF_LANG_TE "te"
#define HPDF_LANG_TG "tg"
#define HPDF_LANG_TH "th"
#define HPDF_LANG_TI "ti"
#define HPDF_LANG_TK "tk"
#define HPDF_LANG_TL "tl"
#define HPDF_LANG_TN "tn"
#define HPDF_LANG_TR "tr"
#define HPDF_LANG_TS "ts"
#define HPDF_LANG_TT "tt"
#define HPDF_LANG_TW "tw"
#define HPDF_LANG_UK "uk"
#define HPDF_LANG_UR "ur"
#define HPDF_LANG_UZ "uz"
#define HPDF_LANG_VI "vi"
#define HPDF_LANG_VO "vo"
#define HPDF_LANG_WO "wo"
#define HPDF_LANG_XH "xh"
#define HPDF_LANG_YO "yo"
#define HPDF_LANG_ZH "zh"
#define HPDF_LANG_ZU "zu"
#define HPDF_GMODE_PAGE_DESCRIPTION &h0001
#define HPDF_GMODE_PATH_OBJECT &h0002
#define HPDF_GMODE_TEXT_OBJECT &h0004
#define HPDF_GMODE_CLIPPING_PATH &h0008
#define HPDF_GMODE_SHADING &h0010
#define HPDF_GMODE_INLINE_IMAGE &h0020
#define HPDF_GMODE_EXTERNAL_OBJECT &h0040

#endif
hpdf_types.bi

Code: Select all

''
''
'' hpdf_types -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
''         be included in other distributions without authorization.
''
''
#ifndef __hpdf_types_bi__
#define __hpdf_types_bi__


Type HPDF_HANDLE As Any Ptr
Type HPDF_Doc As HPDF_HANDLE
Type HPDF_Page As HPDF_HANDLE
Type HPDF_Pages As HPDF_HANDLE
Type HPDF_Stream As HPDF_HANDLE
Type HPDF_Image As HPDF_HANDLE
Type HPDF_Font As HPDF_HANDLE
Type HPDF_Outline As HPDF_HANDLE
Type HPDF_Encoder As HPDF_HANDLE
Type HPDF_Destination As HPDF_HANDLE
Type HPDF_XObject As HPDF_HANDLE
Type HPDF_Annotation As HPDF_HANDLE
Type HPDF_ExtGState As HPDF_HANDLE


type HPDF_INT as integer
type HPDF_UINT as uinteger
type HPDF_INT32 as integer
type HPDF_UINT32 as uinteger
type HPDF_INT16 as short
type HPDF_UINT16 as ushort
type HPDF_INT8 as byte
type HPDF_UINT8 as ubyte
type HPDF_BYTE as ubyte
type HPDF_REAL as single
type HPDF_DOUBLE as double
type HPDF_BOOL as integer
type HPDF_STATUS as uinteger
type HPDF_CID as HPDF_UINT16
type HPDF_UNICODE as HPDF_UINT16

type _HPDF_Point
	x as HPDF_REAL
	y as HPDF_REAL
end type

type HPDF_Point as _HPDF_Point

type _HPDF_Rect
	left as HPDF_REAL
	bottom as HPDF_REAL
	right as HPDF_REAL
	top as HPDF_REAL
end type

type HPDF_Rect as _HPDF_Rect
type HPDF_Box as _HPDF_Rect

type _HPDF_Date
	year as HPDF_INT
	month as HPDF_INT
	day as HPDF_INT
	hour as HPDF_INT
	minutes as HPDF_INT
	seconds as HPDF_INT
	ind as byte
	off_hour as HPDF_INT
	off_minutes as HPDF_INT
end type

type HPDF_Date as _HPDF_Date

enum _HPDF_InfoType
	HPDF_INFO_CREATION_DATE = 0
	HPDF_INFO_MOD_DATE
	HPDF_INFO_AUTHOR
	HPDF_INFO_CREATOR
	HPDF_INFO_PRODUCER
	HPDF_INFO_TITLE
	HPDF_INFO_SUBJECT
	HPDF_INFO_KEYWORDS
	HPDF_INFO_EOF
end enum

type HPDF_InfoType as _HPDF_InfoType

enum _HPDF_PdfVer
	HPDF_VER_12 = 0
	HPDF_VER_13
	HPDF_VER_14
	HPDF_VER_15
	HPDF_VER_16
	HPDF_VER_EOF
end enum

type HPDF_PDFVer as _HPDF_PdfVer

enum _HPDF_EncryptMode
	HPDF_ENCRYPT_R2 = 2
	HPDF_ENCRYPT_R3 = 3
end enum

type HPDF_EncryptMode as _HPDF_EncryptMode
type HPDF_Error_Handler as sub cdecl(byval as HPDF_STATUS, byval as HPDF_STATUS, byval as any ptr)
type HPDF_Alloc_Func as sub cdecl(byval as HPDF_UINT)
type HPDF_Free_Func as sub cdecl(byval as any ptr)

type _HPDF_TextWidth
	numchars as HPDF_UINT
	numwords as HPDF_UINT
	width as HPDF_UINT
	numspace as HPDF_UINT
end type

type HPDF_TextWidth as _HPDF_TextWidth

type _HPDF_DashMode
	ptn(0 to 8-1) as HPDF_UINT16
	num_ptn as HPDF_UINT
	phase as HPDF_UINT
end type

type HPDF_DashMode as _HPDF_DashMode

type _HPDF_TransMatrix
	a as HPDF_REAL
	b as HPDF_REAL
	c as HPDF_REAL
	d as HPDF_REAL
	x as HPDF_REAL
	y as HPDF_REAL
end type

type HPDF_TransMatrix as _HPDF_TransMatrix

enum _HPDF_ColorSpace
	HPDF_CS_DEVICE_GRAY = 0
	HPDF_CS_DEVICE_RGB
	HPDF_CS_DEVICE_CMYK
	HPDF_CS_CAL_GRAY
	HPDF_CS_CAL_RGB
	HPDF_CS_LAB
	HPDF_CS_ICC_BASED
	HPDF_CS_SEPARATION
	HPDF_CS_DEVICE_N
	HPDF_CS_INDEXED
	HPDF_CS_PATTERN
	HPDF_CS_EOF
end enum

type HPDF_ColorSpace as _HPDF_ColorSpace

type _HPDF_RGBColor
	r as HPDF_REAL
	g as HPDF_REAL
	b as HPDF_REAL
end type

type HPDF_RGBColor as _HPDF_RGBColor

type _HPDF_CMYKColor
	c as HPDF_REAL
	m as HPDF_REAL
	y as HPDF_REAL
	k as HPDF_REAL
end type

type HPDF_CMYKColor as _HPDF_CMYKColor

enum _HPDF_LineCap
	HPDF_BUTT_END = 0
	HPDF_ROUND_END
	HPDF_PROJECTING_SCUARE_END
	HPDF_LINECAP_EOF
end enum

type HPDF_LineCap as _HPDF_LineCap

enum _HPDF_LineJoin
	HPDF_MITER_JOIN = 0
	HPDF_ROUND_JOIN
	HPDF_BEVEL_JOIN
	HPDF_LINEJOIN_EOF
end enum

type HPDF_LineJoin as _HPDF_LineJoin

enum _HPDF_TextRenderingMode
	HPDF_FILL = 0
	HPDF_STROKE
	HPDF_FILL_THEN_STROKE
	HPDF_INVISIBLE
	HPDF_FILL_CLIPPING
	HPDF_STROKE_CLIPPING
	HPDF_FILL_STROKE_CLIPPING
	HPDF_CLIPPING
	HPDF_RENDERING_MODE_EOF
end enum

type HPDF_TextRenderingMode as _HPDF_TextRenderingMode

enum _HPDF_WritingMode
	HPDF_WMODE_HORIZONTAL = 0
	HPDF_WMODE_VERTICAL
	HPDF_WMODE_EOF
end enum

type HPDF_WritingMode as _HPDF_WritingMode

enum _HPDF_PageLayout
	HPDF_PAGE_LAYOUT_SINGLE = 0
	HPDF_PAGE_LAYOUT_ONE_COLUMN
	HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT
	HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT
	HPDF_PAGE_LAYOUT_EOF
end enum

type HPDF_PageLayout as _HPDF_PageLayout

enum _HPDF_PageMode
	HPDF_PAGE_MODE_USE_NONE = 0
	HPDF_PAGE_MODE_USE_OUTLINE
	HPDF_PAGE_MODE_USE_THUMBS
	HPDF_PAGE_MODE_FULL_SCREEN
	HPDF_PAGE_MODE_EOF
end enum

type HPDF_PageMode as _HPDF_PageMode

enum _HPDF_PageNumStyle
	HPDF_PAGE_NUM_STYLE_DECIMAL = 0
	HPDF_PAGE_NUM_STYLE_UPPER_ROMAN
	HPDF_PAGE_NUM_STYLE_LOWER_ROMAN
	HPDF_PAGE_NUM_STYLE_UPPER_LETTERS
	HPDF_PAGE_NUM_STYLE_LOWER_LETTERS
	HPDF_PAGE_NUM_STYLE_EOF
end enum

type HPDF_PageNumStyle as _HPDF_PageNumStyle

enum _HPDF_DestinationType
	HPDF_XYZ = 0
	HPDF_FIT
	HPDF_FIT_H
	HPDF_FIT_V
	HPDF_FIT_R
	HPDF_FIT_B
	HPDF_FIT_BH
	HPDF_FIT_BV
	HPDF_DST_EOF
end enum

type HPDF_DestinationType as _HPDF_DestinationType

enum _HPDF_AnnotType
	HPDF_ANNOT_TEXT_NOTES
	HPDF_ANNOT_LINK
	HPDF_ANNOT_SOUND
	HPDF_ANNOT_FREE_TEXT
	HPDF_ANNOT_STAMP
	HPDF_ANNOT_SQUARE
	HPDF_ANNOT_CIRCLE
	HPDF_ANNOT_STRIKE_OUT
	HPDF_ANNOT_HIGHTLIGHT
	HPDF_ANNOT_UNDERLINE
	HPDF_ANNOT_INK
	HPDF_ANNOT_FILE_ATTACHMENT
	HPDF_ANNOT_POPUP
end enum

type HPDF_AnnotType as _HPDF_AnnotType

enum _HPDF_AnnotFlgs
	HPDF_ANNOT_INVISIBLE
	HPDF_ANNOT_HIDDEN
	HPDF_ANNOT_PRINT
	HPDF_ANNOT_NOZOOM
	HPDF_ANNOT_NOROTATE
	HPDF_ANNOT_NOVIEW
	HPDF_ANNOT_READONLY
end enum

type HPDF_AnnotFlgs as _HPDF_AnnotFlgs

enum _HPDF_AnnotHighlightMode
	HPDF_ANNOT_NO_HIGHTLIGHT = 0
	HPDF_ANNOT_INVERT_BOX
	HPDF_ANNOT_INVERT_BORDER
	HPDF_ANNOT_DOWN_APPEARANCE
	HPDF_ANNOT_HIGHTLIGHT_MODE_EOF
end enum

type HPDF_AnnotHighlightMode as _HPDF_AnnotHighlightMode

enum _HPDF_AnnotIcon
	HPDF_ANNOT_ICON_COMMENT = 0
	HPDF_ANNOT_ICON_KEY
	HPDF_ANNOT_ICON_NOTE
	HPDF_ANNOT_ICON_HELP
	HPDF_ANNOT_ICON_NEW_PARAGRAPH
	HPDF_ANNOT_ICON_PARAGRAPH
	HPDF_ANNOT_ICON_INSERT
	HPDF_ANNOT_ICON_EOF
end enum

type HPDF_AnnotIcon as _HPDF_AnnotIcon

enum _HPDF_BSSubtype
	HPDF_BS_SOLID
	HPDF_BS_DASHED
	HPDF_BS_BEVELED
	HPDF_BS_INSET
	HPDF_BS_UNDERLINED
end enum

type HPDF_BSSubtype as _HPDF_BSSubtype

enum _HPDF_BlendMode
	HPDF_BM_NORMAL
	HPDF_BM_MULTIPLY
	HPDF_BM_SCREEN
	HPDF_BM_OVERLAY
	HPDF_BM_DARKEN
	HPDF_BM_LIGHTEN
	HPDF_BM_COLOR_DODGE
	HPDF_BM_COLOR_BUM
	HPDF_BM_HARD_LIGHT
	HPDF_BM_SOFT_LIGHT
	HPDF_BM_DIFFERENCE
	HPDF_BM_EXCLUSHON
	HPDF_BM_EOF
end enum

type HPDF_BlendMode as _HPDF_BlendMode

enum _HPDF_TransitionStyle
	HPDF_TS_WIPE_RIGHT = 0
	HPDF_TS_WIPE_UP
	HPDF_TS_WIPE_LEFT
	HPDF_TS_WIPE_DOWN
	HPDF_TS_BARN_DOORS_HORIZONTAL_OUT
	HPDF_TS_BARN_DOORS_HORIZONTAL_IN
	HPDF_TS_BARN_DOORS_VERTICAL_OUT
	HPDF_TS_BARN_DOORS_VERTICAL_IN
	HPDF_TS_BOX_OUT
	HPDF_TS_BOX_IN
	HPDF_TS_BLINDS_HORIZONTAL
	HPDF_TS_BLINDS_VERTICAL
	HPDF_TS_DISSOLVE
	HPDF_TS_GLITTER_RIGHT
	HPDF_TS_GLITTER_DOWN
	HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT
	HPDF_TS_REPLACE
	HPDF_TS_EOF
end enum

type HPDF_TransitionStyle as _HPDF_TransitionStyle

enum _HPDF_PageSizes
	HPDF_PAGE_SIZE_LETTER = 0
	HPDF_PAGE_SIZE_LEGAL
	HPDF_PAGE_SIZE_A3
	HPDF_PAGE_SIZE_A4
	HPDF_PAGE_SIZE_A5
	HPDF_PAGE_SIZE_B4
	HPDF_PAGE_SIZE_B5
	HPDF_PAGE_SIZE_EXECUTIVE
	HPDF_PAGE_SIZE_US4x6
	HPDF_PAGE_SIZE_US4x8
	HPDF_PAGE_SIZE_US5x7
	HPDF_PAGE_SIZE_COMM10
	HPDF_PAGE_SIZE_EOF
end enum

type HPDF_PageSizes as _HPDF_PageSizes

enum _HPDF_PageDirection
	HPDF_PAGE_PORTRAIT = 0
	HPDF_PAGE_LANDSCAPE
end enum

type HPDF_PageDirection as _HPDF_PageDirection

enum _HPDF_EncoderType
	HPDF_ENCODER_TYPE_SINGLE_BYTE
	HPDF_ENCODER_TYPE_DOUBLE_BYTE
	HPDF_ENCODER_TYPE_UNINITIALIZED
	HPDF_ENCODER_UNKNOWN
end enum

type HPDF_EncoderType as _HPDF_EncoderType

enum _HPDF_ByteType
	HPDF_BYTE_TYPE_SINGLE = 0
	HPDF_BYTE_TYPE_LEAD
	HPDF_BYTE_TYPE_TRIAL
	HPDF_BYTE_TYPE_UNKNOWN
end enum

type HPDF_ByteType as _HPDF_ByteType

enum _HPDF_TextAlignment
	HPDF_TALIGN_LEFT = 0
	HPDF_TALIGN_RIGHT
	HPDF_TALIGN_CENTER
	HPDF_TALIGN_JUSTIFY
end enum

type HPDF_TextAlignment as _HPDF_TextAlignment

#endif
hpdf.bi

Code: Select all

''
''
'' hpdf -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
''         be included in other distributions without authorization.
''
''
#ifndef __hpdf_bi__
#define __hpdf_bi__

#inclib "hpdf"

declare function HPDF_GetVersion cdecl alias "HPDF_GetVersion" () as zstring ptr
declare function HPDF_NewEx cdecl alias "HPDF_NewEx" (byval user_error_fn as HPDF_Error_Handler, byval user_alloc_fn as HPDF_Alloc_Func, byval user_free_fn as HPDF_Free_Func, byval mem_pool_buf_size as HPDF_UINT, byval user_data as any ptr) as HPDF_Doc
declare function HPDF_New cdecl alias "HPDF_New" (byval user_error_fn as HPDF_Error_Handler, byval user_data as any ptr) as HPDF_Doc
declare function HPDF_SetErrorHandler cdecl alias "HPDF_SetErrorHandler" (byval pdf as HPDF_Doc, byval user_error_fn as HPDF_Error_Handler) as HPDF_STATUS
declare sub HPDF_Free cdecl alias "HPDF_Free" (byval pdf as HPDF_Doc)
declare function HPDF_NewDoc cdecl alias "HPDF_NewDoc" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare sub HPDF_FreeDoc cdecl alias "HPDF_FreeDoc" (byval pdf as HPDF_Doc)
declare function HPDF_HasDoc cdecl alias "HPDF_HasDoc" (byval pdf as HPDF_Doc) as HPDF_BOOL
declare sub HPDF_FreeDocAll cdecl alias "HPDF_FreeDocAll" (byval pdf as HPDF_Doc)
declare function HPDF_SaveToStream cdecl alias "HPDF_SaveToStream" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_GetStreamSize cdecl alias "HPDF_GetStreamSize" (byval pdf as HPDF_Doc) as HPDF_UINT32
declare function HPDF_ReadFromStream cdecl alias "HPDF_ReadFromStream" (byval pdf as HPDF_Doc, byval buf as HPDF_BYTE ptr, byval size as HPDF_UINT32 ptr) as HPDF_STATUS
declare function HPDF_ResetStream cdecl alias "HPDF_ResetStream" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_SaveToFile cdecl alias "HPDF_SaveToFile" (byval pdf as HPDF_Doc, byval file_name as zstring ptr) as HPDF_STATUS
declare function HPDF_GetError cdecl alias "HPDF_GetError" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_GetErrorDetail cdecl alias "HPDF_GetErrorDetail" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare sub HPDF_ResetError cdecl alias "HPDF_ResetError" (byval pdf as HPDF_Doc)
declare function HPDF_SetPagesConfiguration cdecl alias "HPDF_SetPagesConfiguration" (byval pdf as HPDF_Doc, byval page_per_pages as HPDF_UINT) as HPDF_STATUS
declare function HPDF_GetPageByIndex cdecl alias "HPDF_GetPageByIndex" (byval pdf as HPDF_Doc, byval index as HPDF_UINT) as HPDF_Page
declare function HPDF_GetPageLayout cdecl alias "HPDF_GetPageLayout" (byval pdf as HPDF_Doc) as HPDF_PageLayout
declare function HPDF_SetPageLayout cdecl alias "HPDF_SetPageLayout" (byval pdf as HPDF_Doc, byval layout as HPDF_PageLayout) as HPDF_STATUS
declare function HPDF_GetPageMode cdecl alias "HPDF_GetPageMode" (byval pdf as HPDF_Doc) as HPDF_PageMode
declare function HPDF_SetPageMode cdecl alias "HPDF_SetPageMode" (byval pdf as HPDF_Doc, byval mode as HPDF_PageMode) as HPDF_STATUS
declare function HPDF_GetViewerPreference cdecl alias "HPDF_GetViewerPreference" (byval pdf as HPDF_Doc) as HPDF_UINT
declare function HPDF_SetViewerPreference cdecl alias "HPDF_SetViewerPreference" (byval pdf as HPDF_Doc, byval value as HPDF_UINT) as HPDF_STATUS
declare function HPDF_SetOpenAction cdecl alias "HPDF_SetOpenAction" (byval pdf as HPDF_Doc, byval open_action as HPDF_Destination) as HPDF_STATUS
declare function HPDF_GetCurrentPage cdecl alias "HPDF_GetCurrentPage" (byval pdf as HPDF_Doc) as HPDF_Page
declare function HPDF_AddPage cdecl alias "HPDF_AddPage" (byval pdf as HPDF_Doc) as HPDF_Page
declare function HPDF_InsertPage cdecl alias "HPDF_InsertPage" (byval pdf as HPDF_Doc, byval page as HPDF_Page) as HPDF_Page
declare function HPDF_Page_SetWidth cdecl alias "HPDF_Page_SetWidth" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetHeight cdecl alias "HPDF_Page_SetHeight" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetSize cdecl alias "HPDF_Page_SetSize" (byval page as HPDF_Page, byval size as HPDF_PageSizes, byval direction as HPDF_PageDirection) as HPDF_STATUS
declare function HPDF_Page_SetRotate cdecl alias "HPDF_Page_SetRotate" (byval page as HPDF_Page, byval angle as HPDF_UINT16) as HPDF_STATUS
declare function HPDF_GetFont cdecl alias "HPDF_GetFont" (byval pdf as HPDF_Doc, byval font_name as zstring ptr, byval encoding_name as zstring ptr) as HPDF_Font
declare function HPDF_LoadType1FontFromFile cdecl alias "HPDF_LoadType1FontFromFile" (byval pdf as HPDF_Doc, byval afm_file_name as zstring ptr, byval data_file_name as zstring ptr) as zstring ptr
declare function HPDF_LoadTTFontFromFile cdecl alias "HPDF_LoadTTFontFromFile" (byval pdf as HPDF_Doc, byval file_name as zstring ptr, byval embedding as HPDF_BOOL) as zstring ptr
declare function HPDF_LoadTTFontFromFile2 cdecl alias "HPDF_LoadTTFontFromFile2" (byval pdf as HPDF_Doc, byval file_name as zstring ptr, byval index as HPDF_UINT, byval embedding as HPDF_BOOL) as zstring ptr
declare function HPDF_AddPageLabel cdecl alias "HPDF_AddPageLabel" (byval pdf as HPDF_Doc, byval page_num as HPDF_UINT, byval style as HPDF_PageNumStyle, byval first_page as HPDF_UINT, byval prefix as zstring ptr) as HPDF_STATUS
declare function HPDF_UseJPFonts cdecl alias "HPDF_UseJPFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseKRFonts cdecl alias "HPDF_UseKRFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseCNSFonts cdecl alias "HPDF_UseCNSFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseCNTFonts cdecl alias "HPDF_UseCNTFonts" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_CreateOutline cdecl alias "HPDF_CreateOutline" (byval pdf as HPDF_Doc, byval parent as HPDF_Outline, byval title as zstring ptr, byval encoder as HPDF_Encoder) as HPDF_Outline
declare function HPDF_Outline_SetOpened cdecl alias "HPDF_Outline_SetOpened" (byval outline as HPDF_Outline, byval opened as HPDF_BOOL) as HPDF_STATUS
declare function HPDF_Outline_SetDestination cdecl alias "HPDF_Outline_SetDestination" (byval outline as HPDF_Outline, byval dst as HPDF_Destination) as HPDF_STATUS
declare function HPDF_Page_CreateDestination cdecl alias "HPDF_Page_CreateDestination" (byval page as HPDF_Page) as HPDF_Destination
declare function HPDF_Destination_SetXYZ cdecl alias "HPDF_Destination_SetXYZ" (byval dst as HPDF_Destination, byval left as HPDF_REAL, byval top as HPDF_REAL, byval zoom as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Destination_SetFit cdecl alias "HPDF_Destination_SetFit" (byval dst as HPDF_Destination) as HPDF_STATUS
declare function HPDF_Destination_SetFitH cdecl alias "HPDF_Destination_SetFitH" (byval dst as HPDF_Destination, byval top as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Destination_SetFitV cdecl alias "HPDF_Destination_SetFitV" (byval dst as HPDF_Destination, byval left as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Destination_SetFitR cdecl alias "HPDF_Destination_SetFitR" (byval dst as HPDF_Destination, byval left as HPDF_REAL, byval bottom as HPDF_REAL, byval right as HPDF_REAL, byval top as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Destination_SetFitB cdecl alias "HPDF_Destination_SetFitB" (byval dst as HPDF_Destination) as HPDF_STATUS
declare function HPDF_Destination_SetFitBH cdecl alias "HPDF_Destination_SetFitBH" (byval dst as HPDF_Destination, byval top as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Destination_SetFitBV cdecl alias "HPDF_Destination_SetFitBV" (byval dst as HPDF_Destination, byval left as HPDF_REAL) as HPDF_STATUS
declare function HPDF_GetEncoder cdecl alias "HPDF_GetEncoder" (byval pdf as HPDF_Doc, byval encoding_name as zstring ptr) as HPDF_Encoder
declare function HPDF_GetCurrentEncoder cdecl alias "HPDF_GetCurrentEncoder" (byval pdf as HPDF_Doc) as HPDF_Encoder
declare function HPDF_SetCurrentEncoder cdecl alias "HPDF_SetCurrentEncoder" (byval pdf as HPDF_Doc, byval encoding_name as zstring ptr) as HPDF_STATUS
declare function HPDF_Encoder_GetType cdecl alias "HPDF_Encoder_GetType" (byval encoder as HPDF_Encoder) as HPDF_EncoderType
declare function HPDF_Encoder_GetByteType cdecl alias "HPDF_Encoder_GetByteType" (byval encoder as HPDF_Encoder, byval text as zstring ptr, byval index as HPDF_UINT) as HPDF_ByteType
declare function HPDF_Encoder_GetUnicode cdecl alias "HPDF_Encoder_GetUnicode" (byval encoder as HPDF_Encoder, byval code as HPDF_UINT16) as HPDF_UNICODE
declare function HPDF_Encoder_GetWritingMode cdecl alias "HPDF_Encoder_GetWritingMode" (byval encoder as HPDF_Encoder) as HPDF_WritingMode
declare function HPDF_UseJPEncodings cdecl alias "HPDF_UseJPEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseKREncodings cdecl alias "HPDF_UseKREncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseCNSEncodings cdecl alias "HPDF_UseCNSEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_UseCNTEncodings cdecl alias "HPDF_UseCNTEncodings" (byval pdf as HPDF_Doc) as HPDF_STATUS
declare function HPDF_Page_CreateTextAnnot cdecl alias "HPDF_Page_CreateTextAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval text as zstring ptr, byval encoder as HPDF_Encoder) as HPDF_Annotation
declare function HPDF_Page_CreateLinkAnnot cdecl alias "HPDF_Page_CreateLinkAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval dst as HPDF_Destination) as HPDF_Annotation
declare function HPDF_Page_CreateURILinkAnnot cdecl alias "HPDF_Page_CreateURILinkAnnot" (byval page as HPDF_Page, byval rect as HPDF_Rect, byval uri as zstring ptr) as HPDF_Annotation
declare function HPDF_LinkAnnot_SetHighlightMode cdecl alias "HPDF_LinkAnnot_SetHighlightMode" (byval annot as HPDF_Annotation, byval mode as HPDF_AnnotHighlightMode) as HPDF_STATUS
declare function HPDF_LinkAnnot_SetBorderStyle cdecl alias "HPDF_LinkAnnot_SetBorderStyle" (byval annot as HPDF_Annotation, byval width as HPDF_REAL, byval dash_on as HPDF_UINT16, byval dash_off as HPDF_UINT16) as HPDF_STATUS
declare function HPDF_TextAnnot_SetIcon cdecl alias "HPDF_TextAnnot_SetIcon" (byval annot as HPDF_Annotation, byval icon as HPDF_AnnotIcon) as HPDF_STATUS
declare function HPDF_TextAnnot_SetOpened cdecl alias "HPDF_TextAnnot_SetOpened" (byval annot as HPDF_Annotation, byval opened as HPDF_BOOL) as HPDF_STATUS
declare function HPDF_LoadPngImageFromFile cdecl alias "HPDF_LoadPngImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
declare function HPDF_LoadPngImageFromFile2 cdecl alias "HPDF_LoadPngImageFromFile2" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
declare function HPDF_LoadJpegImageFromFile cdecl alias "HPDF_LoadJpegImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr) as HPDF_Image
declare function HPDF_LoadRawImageFromFile cdecl alias "HPDF_LoadRawImageFromFile" (byval pdf as HPDF_Doc, byval filename as zstring ptr, byval width as HPDF_UINT, byval height as HPDF_UINT, byval color_space as HPDF_ColorSpace) as HPDF_Image
declare function HPDF_LoadRawImageFromMem cdecl alias "HPDF_LoadRawImageFromMem" (byval pdf as HPDF_Doc, byval buf as HPDF_BYTE ptr, byval width as HPDF_UINT, byval height as HPDF_UINT, byval color_space as HPDF_ColorSpace, byval bits_per_component as HPDF_UINT) as HPDF_Image
declare function HPDF_Image_GetSize cdecl alias "HPDF_Image_GetSize" (byval image as HPDF_Image) as HPDF_Point
declare function HPDF_Image_GetSize2 cdecl alias "HPDF_Image_GetSize2" (byval image as HPDF_Image, byval size as HPDF_Point ptr) as HPDF_STATUS
declare function HPDF_Image_GetWidth cdecl alias "HPDF_Image_GetWidth" (byval image as HPDF_Image) as HPDF_UINT
declare function HPDF_Image_GetHeight cdecl alias "HPDF_Image_GetHeight" (byval image as HPDF_Image) as HPDF_UINT
declare function HPDF_Image_GetBitsPerComponent cdecl alias "HPDF_Image_GetBitsPerComponent" (byval image as HPDF_Image) as HPDF_UINT
declare function HPDF_Image_GetColorSpace cdecl alias "HPDF_Image_GetColorSpace" (byval image as HPDF_Image) as zstring ptr
declare function HPDF_Image_SetColorMask cdecl alias "HPDF_Image_SetColorMask" (byval image as HPDF_Image, byval rmin as HPDF_UINT, byval rmax as HPDF_UINT, byval gmin as HPDF_UINT, byval gmax as HPDF_UINT, byval bmin as HPDF_UINT, byval bmax as HPDF_UINT) as HPDF_STATUS
declare function HPDF_Image_SetMaskImage cdecl alias "HPDF_Image_SetMaskImage" (byval image as HPDF_Image, byval mask_image as HPDF_Image) as HPDF_STATUS
declare function HPDF_SetInfoAttr cdecl alias "HPDF_SetInfoAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType, byval value as zstring ptr) as HPDF_STATUS
declare function HPDF_GetInfoAttr cdecl alias "HPDF_GetInfoAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType) as zstring ptr
declare function HPDF_SetInfoDateAttr cdecl alias "HPDF_SetInfoDateAttr" (byval pdf as HPDF_Doc, byval type as HPDF_InfoType, byval value as HPDF_Date) as HPDF_STATUS
declare function HPDF_SetPassword cdecl alias "HPDF_SetPassword" (byval pdf as HPDF_Doc, byval owner_passwd as zstring ptr, byval user_passwd as zstring ptr) as HPDF_STATUS
declare function HPDF_SetPermission cdecl alias "HPDF_SetPermission" (byval pdf as HPDF_Doc, byval permission as HPDF_UINT) as HPDF_STATUS
declare function HPDF_SetEncryptionMode cdecl alias "HPDF_SetEncryptionMode" (byval pdf as HPDF_Doc, byval mode as HPDF_EncryptMode, byval key_len as HPDF_UINT) as HPDF_STATUS
declare function HPDF_SetCompressionMode cdecl alias "HPDF_SetCompressionMode" (byval pdf as HPDF_Doc, byval mode as HPDF_UINT) as HPDF_STATUS
declare function HPDF_Font_GetFontName cdecl alias "HPDF_Font_GetFontName" (byval font as HPDF_Font) as zstring ptr
declare function HPDF_Font_GetEncodingName cdecl alias "HPDF_Font_GetEncodingName" (byval font as HPDF_Font) as zstring ptr
declare function HPDF_Font_GetUnicodeWidth cdecl alias "HPDF_Font_GetUnicodeWidth" (byval font as HPDF_Font, byval code as HPDF_UNICODE) as HPDF_INT
declare function HPDF_Font_GetBBox cdecl alias "HPDF_Font_GetBBox" (byval font as HPDF_Font) as HPDF_Box
declare function HPDF_Font_GetAscent cdecl alias "HPDF_Font_GetAscent" (byval font as HPDF_Font) as HPDF_INT
declare function HPDF_Font_GetDescent cdecl alias "HPDF_Font_GetDescent" (byval font as HPDF_Font) as HPDF_INT
declare function HPDF_Font_GetXHeight cdecl alias "HPDF_Font_GetXHeight" (byval font as HPDF_Font) as HPDF_UINT
declare function HPDF_Font_GetCapHeight cdecl alias "HPDF_Font_GetCapHeight" (byval font as HPDF_Font) as HPDF_UINT
declare function HPDF_Font_TextWidth cdecl alias "HPDF_Font_TextWidth" (byval font as HPDF_Font, byval text as HPDF_BYTE ptr, byval len as HPDF_UINT) as HPDF_TextWidth
declare function HPDF_Font_MeasureText cdecl alias "HPDF_Font_MeasureText" (byval font as HPDF_Font, byval text as HPDF_BYTE ptr, byval len as HPDF_UINT, byval width as HPDF_REAL, byval font_size as HPDF_REAL, byval char_space as HPDF_REAL, byval word_space as HPDF_REAL, byval wordwrap as HPDF_BOOL, byval real_width as HPDF_REAL ptr) as HPDF_UINT
declare function HPDF_CreateExtGState cdecl alias "HPDF_CreateExtGState" (byval pdf as HPDF_Doc) as HPDF_ExtGState
declare function HPDF_ExtGState_SetAlphaStroke cdecl alias "HPDF_ExtGState_SetAlphaStroke" (byval ext_gstate as HPDF_ExtGState, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_ExtGState_SetAlphaFill cdecl alias "HPDF_ExtGState_SetAlphaFill" (byval ext_gstate as HPDF_ExtGState, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_ExtGState_SetBlendMode cdecl alias "HPDF_ExtGState_SetBlendMode" (byval ext_gstate as HPDF_ExtGState, byval mode as HPDF_BlendMode) as HPDF_STATUS
declare function HPDF_Page_TextWidth cdecl alias "HPDF_Page_TextWidth" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_REAL
declare function HPDF_Page_MeasureText cdecl alias "HPDF_Page_MeasureText" (byval page as HPDF_Page, byval text as zstring ptr, byval width as HPDF_REAL, byval wordwrap as HPDF_BOOL, byval real_width as HPDF_REAL ptr) as HPDF_UINT
declare function HPDF_Page_GetWidth cdecl alias "HPDF_Page_GetWidth" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetHeight cdecl alias "HPDF_Page_GetHeight" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetGMode cdecl alias "HPDF_Page_GetGMode" (byval page as HPDF_Page) as HPDF_UINT16
declare function HPDF_Page_GetCurrentPos cdecl alias "HPDF_Page_GetCurrentPos" (byval page as HPDF_Page) as HPDF_Point
declare function HPDF_Page_GetCurrentPos2 cdecl alias "HPDF_Page_GetCurrentPos2" (byval page as HPDF_Page, byval pos as HPDF_Point ptr) as HPDF_STATUS
declare function HPDF_Page_GetCurrentTextPos cdecl alias "HPDF_Page_GetCurrentTextPos" (byval page as HPDF_Page) as HPDF_Point
declare function HPDF_Page_GetCurrentTextPos2 cdecl alias "HPDF_Page_GetCurrentTextPos2" (byval page as HPDF_Page, byval pos as HPDF_Point ptr) as HPDF_STATUS
declare function HPDF_Page_GetCurrentFont cdecl alias "HPDF_Page_GetCurrentFont" (byval page as HPDF_Page) as HPDF_Font
declare function HPDF_Page_GetCurrentFontSize cdecl alias "HPDF_Page_GetCurrentFontSize" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetTransMatrix cdecl alias "HPDF_Page_GetTransMatrix" (byval page as HPDF_Page) as HPDF_TransMatrix
declare function HPDF_Page_GetLineWidth cdecl alias "HPDF_Page_GetLineWidth" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetLineCap cdecl alias "HPDF_Page_GetLineCap" (byval page as HPDF_Page) as HPDF_LineCap
declare function HPDF_Page_GetLineJoin cdecl alias "HPDF_Page_GetLineJoin" (byval page as HPDF_Page) as HPDF_LineJoin
declare function HPDF_Page_GetMiterLimit cdecl alias "HPDF_Page_GetMiterLimit" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetDash cdecl alias "HPDF_Page_GetDash" (byval page as HPDF_Page) as HPDF_DashMode
declare function HPDF_Page_GetFlat cdecl alias "HPDF_Page_GetFlat" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetCharSpace cdecl alias "HPDF_Page_GetCharSpace" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetWordSpace cdecl alias "HPDF_Page_GetWordSpace" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetHorizontalScalling cdecl alias "HPDF_Page_GetHorizontalScalling" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetTextLeading cdecl alias "HPDF_Page_GetTextLeading" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetTextRenderingMode cdecl alias "HPDF_Page_GetTextRenderingMode" (byval page as HPDF_Page) as HPDF_TextRenderingMode
declare function HPDF_Page_GetTextRaise cdecl alias "HPDF_Page_GetTextRaise" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetTextRise cdecl alias "HPDF_Page_GetTextRise" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetRGBFill cdecl alias "HPDF_Page_GetRGBFill" (byval page as HPDF_Page) as HPDF_RGBColor
declare function HPDF_Page_GetRGBStroke cdecl alias "HPDF_Page_GetRGBStroke" (byval page as HPDF_Page) as HPDF_RGBColor
declare function HPDF_Page_GetCMYKFill cdecl alias "HPDF_Page_GetCMYKFill" (byval page as HPDF_Page) as HPDF_CMYKColor
declare function HPDF_Page_GetCMYKStroke cdecl alias "HPDF_Page_GetCMYKStroke" (byval page as HPDF_Page) as HPDF_CMYKColor
declare function HPDF_Page_GetGrayFill cdecl alias "HPDF_Page_GetGrayFill" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetGrayStroke cdecl alias "HPDF_Page_GetGrayStroke" (byval page as HPDF_Page) as HPDF_REAL
declare function HPDF_Page_GetStrokingColorSpace cdecl alias "HPDF_Page_GetStrokingColorSpace" (byval page as HPDF_Page) as HPDF_ColorSpace
declare function HPDF_Page_GetFillingColorSpace cdecl alias "HPDF_Page_GetFillingColorSpace" (byval page as HPDF_Page) as HPDF_ColorSpace
declare function HPDF_Page_GetTextMatrix cdecl alias "HPDF_Page_GetTextMatrix" (byval page as HPDF_Page) as HPDF_TransMatrix
declare function HPDF_Page_GetGStateDepth cdecl alias "HPDF_Page_GetGStateDepth" (byval page as HPDF_Page) as HPDF_UINT
declare function HPDF_Page_SetLineWidth cdecl alias "HPDF_Page_SetLineWidth" (byval page as HPDF_Page, byval line_width as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetLineCap cdecl alias "HPDF_Page_SetLineCap" (byval page as HPDF_Page, byval line_cap as HPDF_LineCap) as HPDF_STATUS
declare function HPDF_Page_SetLineJoin cdecl alias "HPDF_Page_SetLineJoin" (byval page as HPDF_Page, byval line_join as HPDF_LineJoin) as HPDF_STATUS
declare function HPDF_Page_SetMiterLimit cdecl alias "HPDF_Page_SetMiterLimit" (byval page as HPDF_Page, byval miter_limit as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetDash cdecl alias "HPDF_Page_SetDash" (byval page as HPDF_Page, byval dash_ptn as HPDF_UINT16 ptr, byval num_param as HPDF_UINT, byval phase as HPDF_UINT) as HPDF_STATUS
declare function HPDF_Page_SetFlat cdecl alias "HPDF_Page_SetFlat" (byval page as HPDF_Page, byval flatness as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetExtGState cdecl alias "HPDF_Page_SetExtGState" (byval page as HPDF_Page, byval ext_gstate as HPDF_ExtGState) as HPDF_STATUS
declare function HPDF_Page_GSave cdecl alias "HPDF_Page_GSave" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_GRestore cdecl alias "HPDF_Page_GRestore" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Concat cdecl alias "HPDF_Page_Concat" (byval page as HPDF_Page, byval a as HPDF_REAL, byval b as HPDF_REAL, byval c as HPDF_REAL, byval d as HPDF_REAL, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_MoveTo cdecl alias "HPDF_Page_MoveTo" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_LineTo cdecl alias "HPDF_Page_LineTo" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_CurveTo cdecl alias "HPDF_Page_CurveTo" (byval page as HPDF_Page, byval x1 as HPDF_REAL, byval y1 as HPDF_REAL, byval x2 as HPDF_REAL, byval y2 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_CurveTo2 cdecl alias "HPDF_Page_CurveTo2" (byval page as HPDF_Page, byval x2 as HPDF_REAL, byval y2 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_CurveTo3 cdecl alias "HPDF_Page_CurveTo3" (byval page as HPDF_Page, byval x1 as HPDF_REAL, byval y1 as HPDF_REAL, byval x3 as HPDF_REAL, byval y3 as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_ClosePath cdecl alias "HPDF_Page_ClosePath" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Rectangle cdecl alias "HPDF_Page_Rectangle" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval width as HPDF_REAL, byval height as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_Stroke cdecl alias "HPDF_Page_Stroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_ClosePathStroke cdecl alias "HPDF_Page_ClosePathStroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Fill cdecl alias "HPDF_Page_Fill" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Eofill cdecl alias "HPDF_Page_Eofill" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_FillStroke cdecl alias "HPDF_Page_FillStroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_EofillStroke cdecl alias "HPDF_Page_EofillStroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_ClosePathFillStroke cdecl alias "HPDF_Page_ClosePathFillStroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_ClosePathEofillStroke cdecl alias "HPDF_Page_ClosePathEofillStroke" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_EndPath cdecl alias "HPDF_Page_EndPath" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Clip cdecl alias "HPDF_Page_Clip" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_Eoclip cdecl alias "HPDF_Page_Eoclip" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_BeginText cdecl alias "HPDF_Page_BeginText" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_EndText cdecl alias "HPDF_Page_EndText" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_SetCharSpace cdecl alias "HPDF_Page_SetCharSpace" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetWordSpace cdecl alias "HPDF_Page_SetWordSpace" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetHorizontalScalling cdecl alias "HPDF_Page_SetHorizontalScalling" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetTextLeading cdecl alias "HPDF_Page_SetTextLeading" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetFontAndSize cdecl alias "HPDF_Page_SetFontAndSize" (byval page as HPDF_Page, byval font as HPDF_Font, byval size as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetTextRenderingMode cdecl alias "HPDF_Page_SetTextRenderingMode" (byval page as HPDF_Page, byval mode as HPDF_TextRenderingMode) as HPDF_STATUS
declare function HPDF_Page_SetTextRise cdecl alias "HPDF_Page_SetTextRise" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetTextRaise cdecl alias "HPDF_Page_SetTextRaise" (byval page as HPDF_Page, byval value as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_MoveTextPos cdecl alias "HPDF_Page_MoveTextPos" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_MoveTextPos2 cdecl alias "HPDF_Page_MoveTextPos2" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetTextMatrix cdecl alias "HPDF_Page_SetTextMatrix" (byval page as HPDF_Page, byval a as HPDF_REAL, byval b as HPDF_REAL, byval c as HPDF_REAL, byval d as HPDF_REAL, byval x as HPDF_REAL, byval y as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_MoveToNextLine cdecl alias "HPDF_Page_MoveToNextLine" (byval page as HPDF_Page) as HPDF_STATUS
declare function HPDF_Page_ShowText cdecl alias "HPDF_Page_ShowText" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_STATUS
declare function HPDF_Page_ShowTextNextLine cdecl alias "HPDF_Page_ShowTextNextLine" (byval page as HPDF_Page, byval text as zstring ptr) as HPDF_STATUS
declare function HPDF_Page_ShowTextNextLineEx cdecl alias "HPDF_Page_ShowTextNextLineEx" (byval page as HPDF_Page, byval word_space as HPDF_REAL, byval char_space as HPDF_REAL, byval text as zstring ptr) as HPDF_STATUS
declare function HPDF_Page_SetGrayFill cdecl alias "HPDF_Page_SetGrayFill" (byval page as HPDF_Page, byval gray as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetGrayStroke cdecl alias "HPDF_Page_SetGrayStroke" (byval page as HPDF_Page, byval gray as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetRGBFill cdecl alias "HPDF_Page_SetRGBFill" (byval page as HPDF_Page, byval r as HPDF_REAL, byval g as HPDF_REAL, byval b as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetRGBStroke cdecl alias "HPDF_Page_SetRGBStroke" (byval page as HPDF_Page, byval r as HPDF_REAL, byval g as HPDF_REAL, byval b as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetCMYKFill cdecl alias "HPDF_Page_SetCMYKFill" (byval page as HPDF_Page, byval c as HPDF_REAL, byval m as HPDF_REAL, byval y as HPDF_REAL, byval k as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_SetCMYKStroke cdecl alias "HPDF_Page_SetCMYKStroke" (byval page as HPDF_Page, byval c as HPDF_REAL, byval m as HPDF_REAL, byval y as HPDF_REAL, byval k as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_ExecuteXObject cdecl alias "HPDF_Page_ExecuteXObject" (byval page as HPDF_Page, byval obj as HPDF_XObject) as HPDF_STATUS
declare function HPDF_Page_DrawImage cdecl alias "HPDF_Page_DrawImage" (byval page as HPDF_Page, byval image as HPDF_Image, byval x as HPDF_REAL, byval y as HPDF_REAL, byval width as HPDF_REAL, byval height as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_Circle cdecl alias "HPDF_Page_Circle" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval ray as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_Ellipse cdecl alias "HPDF_Page_Ellipse" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval xray as HPDF_REAL, byval yray as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_Arc cdecl alias "HPDF_Page_Arc" (byval page as HPDF_Page, byval x as HPDF_REAL, byval y as HPDF_REAL, byval ray as HPDF_REAL, byval ang1 as HPDF_REAL, byval ang2 as HPDF_REAL) as HPDF_STATUS
declare function HPDF_Page_TextOut cdecl alias "HPDF_Page_TextOut" (byval page as HPDF_Page, byval xpos as HPDF_REAL, byval ypos as HPDF_REAL, byval text as zstring ptr) as HPDF_STATUS
declare function HPDF_Page_TextRect cdecl alias "HPDF_Page_TextRect" (byval page as HPDF_Page, byval left as HPDF_REAL, byval top as HPDF_REAL, byval right as HPDF_REAL, byval bottom as HPDF_REAL, byval text as zstring ptr, byval align as HPDF_TextAlignment, byval len as HPDF_UINT ptr) as HPDF_STATUS
declare function HPDF_Page_SetSlideShow cdecl alias "HPDF_Page_SetSlideShow" (byval page as HPDF_Page, byval type as HPDF_TransitionStyle, byval disp_time as HPDF_REAL, byval trans_time as HPDF_REAL) as HPDF_STATUS

#endif
I've also started to code the program, but I'm facing a new problem.
The function HPDF_New, which creates a new PDF file, is called with a parameter that equals to an error handler subroutine (see also the original c code attached above).
Here's my code, but I guess it can't be correct - when I compile it I get the error: Argument count mismatch, found ',' in 'pdf = HPDF_New(error_handler, NULL)'

Code: Select all

'****************************************************************************** 
'* Includes for Haru Free PDF Library 
'****************************************************************************** 
#ifndef __mod_hpdf_bi__
#define __mod_hpdf_bi__
#include once "hpdf_consts.bi"
#include once "hpdf_types.bi"
#include once "hpdf.bi"
#endif

#define NULL 0 

'****************************************************************************** 
'* Declarations of subroutines and functions
'****************************************************************************** 

declare sub error_handler cdecl (byval error_no as HPDF_STATUS ptr, byval detail_no as HPDF_STATUS ptr, byval user_data as any ptr )

'****************************************************************************** 
'* Constants
'****************************************************************************** 
const page_title = "PDF test document"

'****************************************************************************** 
'* Variables
'****************************************************************************** 
dim shared pdf          as HPDF_Doc 'ptr 
dim shared fname        as string * 256   
dim shared page         as HPDF_Page
dim shared def_font     as HPDF_Font
dim shared tw           as HPDF_REAL
dim shared doc_height   as HPDF_REAL
dim shared doc_width    as HPDF_REAL 
dim shared i            as HPDF_UINT
dim shared errno        as HPDF_STATUS ptr
dim shared detno        as HPDF_STATUS ptr
dim shared userdat      as any ptr

' let's go ...

pdf = HPDF_New(error_handler, NULL)


sub error_handler cdecl (byval error_no as HPDF_STATUS ptr, byval detail_no as HPDF_STATUS ptr, byval user_data as any ptr) 
' do something here ...

end sub
Does somebody know how to invoke a call with a subroutine as a parameter?
Thanks again
Last edited by haegartheroot on Jul 28, 2007 15:07, edited 1 time in total.
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Post by voodooattack »

Code: Select all

pdf = HPDF_New(@error_handler, NULL)
Using the @ prefix is the equivalent of using ProcPtr(error_handler), and is used to obtain the address of your callback procedure, without it, FreeBASIC will assume that you're trying to call the "error_handler" procedure (and if it was a function, passing its return value to HPDF_New as the first parameter).

maddogg6: it's basically type-aliasing here, used only for abstraction, so yours would work seamlessly (disregarding the "As As" typo)

I didn't test the code yet, But hopefully I'll get a chance to test it soon.
Thumbs up, great work :)
maddogg6
Posts: 824
Joined: Dec 07, 2005 22:58
Contact:

Post by maddogg6 »

voodooattack wrote: maddogg6: it's basically type-aliasing here, used only for abstraction, so yours would work seamlessly (disregarding the "As As" typo)
Yes- thats a cut and paste mistake on my part... thank you
haegartheroot
Posts: 114
Joined: Jul 27, 2007 15:45
Location: Bremen, Germany
Contact:

Post by haegartheroot »

Thanks for your help !!!
This is one of the best forums I've ever seen.
Now the example program is ready to use.
It creates a PDF file, with a header line, a frame and three lines of text inside the frame with different fonts.
See how easy it is to create a PDF document with FreeBasic and hpdf:

Code: Select all

'******************************************************************************
'*  Program name: hpdftest
'*  Version:      0.1
'*
'*  Author:       Copyright (c) 2007 Klaus Siebke
'*                Siebke Unternehmensberatung
'*                URL http://www.siebke.com
'*
'*  Description:
'*  ----------
'*
'*  Program to test the creation of a PDF file using the Haru Free PDF Library
'*
'*  License:
'*  -------
'*
'* Permission to use, copy, modify, distribute and sell this software
'* and its documentation for any purpose is hereby granted without fee,
'* provided that the above copyright notice appear in all copies and
'* that both that copyright notice and this permission notice appear
'* in supporting documentation.
'* It is provided "as is" without express or implied warranty.
'*
'*
'* External libraries used by the program:
'* --------------------------------------
'*
'* << Haru Free PDF Library 2.0.8 >>
'* URL http://libharu.sourceforge.net/
'* Copyright (c) 1999-2006 Takeshi Kanno
'*
'****************************************************************************** 
'****************************************************************************** 
'* Includes for Haru Free PDF Library 
'****************************************************************************** 
#ifndef __mod_hpdf_bi__
#define __mod_hpdf_bi__
#include once "hpdf_consts.bi"
#include once "hpdf_types.bi"
#include once "hpdf.bi"
#endif

'****************************************************************************** 
'* Declarations of subroutines and functions
'****************************************************************************** 
declare sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr )

'****************************************************************************** 
'* Constants
'****************************************************************************** 
#define NULL 0 
const page_title = "PDF test document"

'****************************************************************************** 
'* Variables
'****************************************************************************** 
dim shared pdf          as HPDF_Doc 'ptr 
dim shared fname        as string * 256   
dim shared page         as HPDF_Page
dim shared def_font     as HPDF_Font
dim shared txt_font     as HPDF_Font
dim shared tw           as HPDF_REAL
dim shared doc_height   as HPDF_REAL
dim shared doc_width    as HPDF_REAL 
dim shared i            as HPDF_UINT
dim shared errno        as HPDF_STATUS ptr
dim shared detno        as HPDF_STATUS ptr
dim shared userdat      as any ptr

'****************************************************************************** 
'* Begin of main program
'****************************************************************************** 

'let's go ... (initialize hpdf)
pdf = HPDF_New(@error_handler, NULL)

'add a new page object
page = HPDF_AddPage (pdf)
doc_height = HPDF_Page_GetHeight (page)
doc_width = HPDF_Page_GetWidth (page)

'print a frame
HPDF_Page_SetLineWidth (page, 1)
HPDF_Page_Rectangle (page, 50, 50, doc_width - 100, doc_height - 110)
HPDF_Page_Stroke (page)

'print the title of the page (with positioning center) with font Helvetica
def_font = HPDF_GetFont (pdf, "Helvetica", NULL)
HPDF_Page_SetFontAndSize (page, def_font, 24)
tw = HPDF_Page_TextWidth (page, page_title)
HPDF_Page_BeginText (page)
HPDF_Page_TextOut (page, (doc_width - tw) / 2, doc_height - 50, page_title)
HPDF_Page_EndText (page)

'print some text inside the frame 
HPDF_Page_BeginText (page)

'first line with font Times Roman 14
txt_font = HPDF_GetFont (pdf, "Times-Roman", NULL)
HPDF_Page_MoveTextPos (page, 60, doc_height - 105)
HPDF_Page_SetFontAndSize (page, txt_font, 14)
HPDF_Page_ShowText (page, "This is a first line")

'second line with font Courier 12
txt_font = HPDF_GetFont (pdf, "Courier", NULL)
HPDF_Page_MoveTextPos (page, 0, -20)
HPDF_Page_SetFontAndSize (page, txt_font, 12)
HPDF_Page_ShowText (page, "This is a second line")

'third line with font Symbol 16
txt_font = HPDF_GetFont (pdf, "Symbol", NULL)
HPDF_Page_MoveTextPos (page, 0, -20)
HPDF_Page_SetFontAndSize (page, txt_font, 16)
HPDF_Page_ShowText (page, "Here are some symbols")

HPDF_Page_EndText (page)

'save the document
HPDF_SaveToFile (pdf, "mydoc.pdf")

'clean up
HPDF_Free (pdf)

'****************************************************************************** 
'* End of main program
'****************************************************************************** 


sub error_handler cdecl (byval error_no as HPDF_STATUS, byval detail_no as HPDF_STATUS, byval user_data as any ptr) 
'****************************************************************************** 
'* Error handler
'****************************************************************************** 
' do something here ... 
  print "error_no: ", error_no
  print "detail_no:", detail_no
  print "data:     ", user_data

end sub
FreeBasic is a perfect language: write a program once and compile/run it (almost) everywhere.
Post Reply