Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-05

PDFlib TET - convert using h2pas

15 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

Hi,
I would like to use the TET[1] in FPC on Windows.
There are 2 options:
1- Translate C header to use libtet.dll (I prefer); 2- Use the COM object (TET_com.dll);

I can use COM in Delphi 7 easily. There is a Wizard to translate call from COM object to Object Pascal... But I would like to use FPC!

Somebody can help me to use h2pas tool to translate the C header in attachment?

[1] http://www.pdflib.com/download/tet/

Thanks,

Marcos Douglas

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 13 lines
Hi, I would like to use the TET[1] in FPC on Windows. There are 2 options: 1- Translate C header to use libtet.dll (I prefer); 2- Use the COM object (TET_com.dll); I can use COM in Delphi 7 easily. There is a Wizard to translate call from COM object to Object Pascal... But I would like to use FPC! Somebody can help me to use h2pas tool to translate the C header in attachment? [1] http://www.pdflib.com/download/tet/

Anyone?
At least tell me why h2pas can not parse this header file, please.

Marcos Douglas

Reply by email

Marcos Douglas
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
The file is not big, why don't you just convert it manually?

There are 2 reasons:
1- I do not know C very well.
2- Because the first reason, maybe I expended much time to do this. I would like the help of h2pas tool.

Thanks,

Marcos Douglas

Reply by email

Ludo Brands
to Marcos Douglas: Anyone? At least tell me why h2pas can not parse this header file, please. Marcos Douglas

In this case:
1) because h2pas doesn't use pascal macro's. A construct like #if defined(WIN32) && !defined(PDFLIB_CALL)
#define PDFLIB_CALL __cdecl
#endif
can not be translated using pascal constants or functions. Cdecl is a calling convention modifier.
2) afaik pascal doesnt support widestring constants. Therefor h2pas doesn't understand
#define IFILTER_WCHAR_LONG_VERSIONSTRING L"4.0p7". In this case, the string doesn't contain non-ascii characters and pascal will assign (convert) correctly a ascii string to a widechar string. So you can just solve the problem by
const IFILTER_WCHAR_LONG_VERSIONSTRING=IFILTER_LONG_VERSIONSTRING;

Ludo

Earlier message 29 lines
-----Message d'origine----- De : De la part de Marcos Douglas Envoyé : mercredi 18 mai 2011 16:24 À : FPC-Pascal users discussions Objet : [fpc-pascal] Re: PDFlib TET - convert using h2pas On Tue, May 17, 2011 at 5:04 PM, Marcos Douglas wrote: > > Hi, > I would like to use the TET[1] in FPC on Windows. > There are 2 options: > 1- Translate C header to use libtet.dll (I prefer); > 2- Use the COM object (TET_com.dll); > > I can use COM in Delphi 7 easily. There is a Wizard to translate call > from COM object to Object Pascal... But I would like to use FPC! > > Somebody can help me to use h2pas tool to translate the C header in > attachment? > > [1] http://www.pdflib.com/download/tet/ Anyone? At least tell me why h2pas can not parse this header file, please. Marcos Douglas

Reply by email

Felipe Monteiro de Carvalho
to Marcos Douglas: On Wed, May 18, 2011 at 11:37 AM, Felipe Monteiro de Carvalho OK, thank you! Answer me:…
Marcos Douglas wrote
Answer me: if you were to use this lib, which way do you choose? ActiveX (Delphi or FPC), translate header or use another language with support (Java, .NET, Pyhon, Perl, etc... see here http://www.pdflib.com/products/tet/how-to-use-tet/ ).

I would translate the headers manually and use that.

I am sending back what I translated in 2 minutes of work. You can use as a model.

Felipe Monteiro de Carvalho

Reply by email

Ludo Brands
to Ludo Brands: In this case: 1) because h2pas doesn't use pascal macro's. A construct like #if…
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)

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

Ludo

Earlier message 54 lines
-----Message d'origine----- De : De la part de Ludo Brands Envoyé : mercredi 18 mai 2011 16:51 À : 'FPC-Pascal users discussions' Objet : RE : [fpc-pascal] Re: PDFlib TET - convert using h2pas In this case: 1) because h2pas doesn't use pascal macro's. A construct like #if defined(WIN32) && !defined(PDFLIB_CALL) #define PDFLIB_CALL __cdecl #endif can not be translated using pascal constants or functions. Cdecl is a calling convention modifier. 2) afaik pascal doesnt support widestring constants. Therefor h2pas doesn't understand #define IFILTER_WCHAR_LONG_VERSIONSTRING L"4.0p7". In this case, the string doesn't contain non-ascii characters and pascal will assign (convert) correctly a ascii string to a widechar string. So you can just solve the problem by const IFILTER_WCHAR_LONG_VERSIONSTRING=IFILTER_LONG_VERSIONSTRING; Ludo -----Message d'origine----- De : De la part de Marcos Douglas Envoyé : mercredi 18 mai 2011 16:24 À : FPC-Pascal users discussions Objet : [fpc-pascal] Re: PDFlib TET - convert using h2pas On Tue, May 17, 2011 at 5:04 PM, Marcos Douglas wrote: > > Hi, > I would like to use the TET[1] in FPC on Windows. > There are 2 options: > 1- Translate C header to use libtet.dll (I prefer); > 2- Use the COM object (TET_com.dll); > > I can use COM in Delphi 7 easily. There is a Wizard to translate call > from COM object to Object Pascal... But I would like to use FPC! > > Somebody can help me to use h2pas tool to translate the C header in > attachment? > > [1] http://www.pdflib.com/download/tet/ Anyone? At least tell me why h2pas can not parse this header file, please. Marcos Douglas

Reply by email

Marcos Douglas
to Felipe Monteiro de Carvalho: I would translate the headers manually and use that. I am sending back what I translated…
Felipe Monteiro de Carvalho wrote 11 lines
On Wed, May 18, 2011 at 4:43 PM, Marcos Douglas wrote: > Answer me: if you were to use this lib, which way do you choose? > ActiveX (Delphi or FPC), translate header or use another language with > support (Java, .NET, Pyhon, Perl, etc... see here > http://www.pdflib.com/products/tet/how-to-use-tet/ ). I would translate the headers manually and use that. I am sending back what I translated in 2 minutes of work. You can use as a model.

WHAT? 2 minutes?!
Oh.. you just begun the translate... hehe =)

Thanks!
Marcos Douglas

Reply by email

Marcos Douglas
to Ludo Brands: windows. I also assume that you don't want to export functions defiend. So, I did the…
Ludo Brands wrote 5 lines
>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.

Show quoted text 11 lines
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

Reply by email

Ludo Brands
to Marcos Douglas

Here you go,

Ludo

Earlier message 39 lines
-----Message d'origine----- De : 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 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

Reply by email

Ludo Brands
to Marcos Douglas

Remember, what I did was just educated "arm twisting" the input file so that h2pas could understand the input and do the bulk of the work. There is still quite some work to do after on the pp file. Some can be done from looking at the header file only, others need a better knowledge of the API.

Ludo

Earlier message 18 lines
-----Message d'origine----- De : De la part de Marcos Douglas Envoyé : mercredi 18 mai 2011 19:54 À : FPC-Pascal users discussions Objet : Re: RE : RE : RE : [fpc-pascal] Re: PDFlib TET - convert using h2pas On Wed, May 18, 2011 at 2:43 PM, Ludo Brands wrote: > > Here you go, Now I can learn a bit more about C language, comparing your header file with my (incomplete) header file. Thanks, Marcos Douglas

Reply by email

Marcos Douglas
to Ludo Brands
Ludo Brands wrote 5 lines
Remember, what I did was just educated "arm twisting" the input file so that h2pas could understand the input and do the bulk of the work. There is still quite some work to do after on the pp file. Some can be done from looking at the header file only, others need a better knowledge of the API.

Yes, I understand.

Marcos Douglas

Reply by email