17.05.2014 Views

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.10 RPG Binding<br />

<strong>TET</strong> provides a /copy module that defines all prototypes and some useful constants<br />

needed to compile ILE-RPG programs with embedded <strong>TET</strong> functions.<br />

Unicode string handling. Since all <strong>TET</strong> functions use Unicode strings with variable<br />

length as parameters, you have to use the %UCS2 builtin function to convert a singlebyte<br />

string to a Unicode string. All strings returned by <strong>TET</strong> functions are Unicode strings<br />

with variable length. Use the %CHAR builtin function to convert these Unicode strings<br />

to single-byte strings.<br />

Note The %CHAR and %UCS2 functions use the current job’s CCSID to convert strings from and to<br />

Unicode. The examples provided with <strong>PDFlib</strong> are based on CCSID 37 (US EBCDIC). Some special<br />

characters in option lists (e.g. { [ ] } ) may not be translated correctly if you run the examples<br />

under other codepages.<br />

Since all strings are passed as variable length strings you must not pass the length parameters<br />

in various functions which expect explicit string lengths (the length of a variable<br />

length string is stored in the first two bytes of the string).<br />

Compiling and binding RPG programs for <strong>TET</strong>. Since all functions provided by <strong>TET</strong> are<br />

implemented in the C language, you have to add x'00' at the end of each string value<br />

passed to a <strong>TET</strong> function. All strings returned from <strong>TET</strong> will have this terminating x'00'<br />

as well.<br />

Using <strong>TET</strong> functions from RPG requires the compiled <strong>TET</strong> service program. To include<br />

the <strong>TET</strong> definitions at compile time you have to specify the name in the D specs of<br />

your ILE-RPG program:<br />

d/copy QRPGLESRC,<strong>TET</strong>LIB<br />

If the <strong>TET</strong> source file library is not on top of your library list you have to specify the library<br />

as well:<br />

d/copy tetsrclib/QRPGLESRC,<strong>TET</strong>LIB<br />

Before you start compiling your ILE-RPG program you have to create a binding directory<br />

that includes the <strong>TET</strong>LIB service program shipped with <strong>TET</strong>. The following example assumes<br />

that you want to create a binding directory called <strong>TET</strong>LIB in the library <strong>TET</strong>LIB:<br />

CRTBNDDIR BNDDIR(<strong>TET</strong>LIB/<strong>TET</strong>LIB) TEXT('<strong>TET</strong>lib Binding Directory')<br />

After creating the binding directory you need to add the <strong>TET</strong>LIB service program to your<br />

binding directory. The following example assumes that you want to add the service program<br />

<strong>TET</strong>LIB in the library <strong>TET</strong>LIB to the binding directory created earlier.<br />

ADDBNDDIRE BNDDIR(<strong>TET</strong>LIB/<strong>TET</strong>LIB) OBJ((<strong>TET</strong>LIB/<strong>TET</strong>LIB *SRVPGM))<br />

Now you can compile your program using the CRTBNDRPG command (or option 14 in<br />

PDM):<br />

CRTBNDRPG PGM(<strong>TET</strong>LIB/EXTRACTOR) SRCFILE(<strong>TET</strong>LIB/QRPGLESRC) SRCMBR(*PGM) DFTACTGRP(*NO)<br />

BNDDIR(<strong>TET</strong>LIB/<strong>TET</strong>LIB)<br />

32 Chapter 3: <strong>TET</strong> Library Language Bindings

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!