Announcement

Collapse
No announcement yet.

C Structure Definition in PowerBasic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C Structure Definition in PowerBasic

    I am new to PowerBasic. I am attempting to use a DLL called Konvertor,
    which converts a PDF image into any one of a number of different types
    like Jpg, TIFF, etc. The DLL is provided by http://www.logipole.com.

    I am having a great deal of trouble getting it to work. Following is
    the "C" Structure definition. My questions are:

    1. How would this convert to a PB structure definition? Specifically the
    Char* which I believe are string pointers and the BOOL?

    2. Some C code to use the DLL follows the structure definition. Would I
    use a VARPTR(PB structure) to call the function?

    3. If the Char* are string pointers how do I load them in PB. Would I use:
    DIM f_name as string
    F_name = "c:\imagefile.pdf"
    mystrut.filename = STRPRT(f_name)

    4. Here is what I have come up with as to a DECLARE for PB:
    DECLARE FUNCTION PDFtoXXX LIB "Konvertor_pdf2xxx.dll" ALIAS "PDFtoXXX" (lpParam AS DWORD) AS INTEGER
    Is this correct?

    Thank you for any help you can provide me.

    John Sullivan

    ______________________________________________________________

    This function converts a PDF file to another format.
    The program must be linked with Konvertor_pdf2xxx.lib or
    you can call directly the functions, they are exported.

    typedef struct _tagPDF2XXX {

    char* pdfFile;
    char* pdf_password;
    short pdf_dpi;
    short pdf_first_page;
    short pdf_nb_page;
    short target_image_type;
    short target_adjoin;
    short trim;
    char* target_folder;
    short monochrome;
    short gif_delay;
    short jpeg_compression;
    short jpeg_dpi;
    short tif_compression_type;
    short tif_dpi_H;
    short tif_dpi_V;
    short txt_columns;
    short txt_mark_crlf;
    short txt_format;
    short txt_type;
    short new_height;
    BOOL keep_proportions;
    short signature;
    short signature_dissolve;
    char* signature_mask;
    char* temp_folder;
    char* error_buffer;
    } pdf2xxx;


    // image compression types
    #define NONE 0
    #define ZIP 1
    #define JPEG 2
    #define FAX3 3
    #define GROUP4 4
    #define RLE 5

    // target image types

    #define _BMP 0
    #define _FAX 1
    #define _GIF 2
    #define _JPEG 3
    #define _JNG 4
    #define _PCX 5

    #define _PDF 6

    #define _PGM 7
    #define _PNG 8
    #define _PPM 9
    #define _PS 10
    #define _SGI 11
    #define _TGA 12
    #define _TIFF 13
    #define _TXT 14

    // declaration

    void PDFtoXXX(pdf2xxx *param);

    int test(void) {
    pdf2xxx param;
    char version[512];
    int ret;

    // convert to an animated GIF, resizing the pages
    ZeroMemory(error, sizeof(error));
    ZeroMemory(&param, sizeof(param));


    param.target_image_type = _GIF;
    param.target_adjoin = TRUE;
    param.pdfFile = "c:\\pdf\\test.pdf";
    param.pdf_dpi = 75;
    param.new_width = 150;
    param.new_height = 65;
    param.gif_delay = 1000;
    param.target_folder = “c:\\converted”;
    param.temp_folder = “c:\\temp”;
    param.error_buffer = error;
    ret = PDFtoXXX(&param);

    ------------------

  • #2
    You can find information on translating from C types in the PB help,
    under Data Types / Comparative Data types. As for question (4), can
    you show us the original C declaration? Oh, I see. Like this:

    DECLARE SUB PDFtoXXX LIB "Konvertor_pdf2xxx.dll" ALIAS "PDFtoXXX" (param AS tagPDF2XXX)

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment

    Working...
    X