Building PDFlib on EBCDIC platforms
===================================

Important note: the Aladdin license does not apply to PDFlib on
EBCDIC platforms. This means you will have to purchase a commercial
PDFlib license in order to use PDFlib on AS/400, S/390, or other
EBCDIC-based platforms.

PDFlib can be used on EBCDIC-based midrange and mainframe platforms
such as IBM AS/400 and S/390 (with the "Unix system services for OS/390").
PDF generation on EBCDIC systems is a delicate issue since PDF is based
on ASCII operators, but nevertheless we want to be able to process EBCDIC
text strings. However, PDFlib is carefully set up to meet these requirements.

Note that although the PDFlib core library C code is EBCDIC-aware, not
all language bindings have been modified for use on EBCDIC-based hosts.
Currently only the C, C++, and Java language bindings are EBCDIC-safe.


General remarks on building PDFlib on EBCDIC-based systems
==========================================================

Please observe the notes in the PDFlib manual regarding expected
file formats (EBCDIC text vs. binary) for several items related to
PDFlib usage. These rules must strictly be observed in order to
successfully use PDFlib on EBCDIC-based platforms.

PDFlib's EBCDIC support is built on the following assumptions:

- Use the EBCDIC PDFlib package which is available from our Web site.
  On the AS/400 the EBCDIC codepage (CCSID) 819 is assumed, on S/390 
  CCSID 1047.  Other systems must manually select the required codepage
  by #define'ing #PDF_CODEPAGE in p_config.h appropriately. 

- ASCII support libraries (such as IBM's libascii) are not required,
  and must not be used.

- The C source code strings must not be translated automatically to
  ISO 8859-1 by some compiler directive or similar means (for example,
  setting the __STRING_CODE_SET__ #define), but must be processed as
  EBCDIC text. This is crucial for successfully building and using PDFlib!

- Using the PDFlib auxiliary libraries on EBCDIC systems:
  - libpng and zlib are believed to be EBCDIC-safe.
  - TIFFlib may also be EBCDIC-safe, but has not been tested on EBCDIC
    systems.


Building PDFlib on the S/390 with Unix System Services
======================================================

Unpack the PDFlib EBCDIC distribution with the pax utility:

pax -rzf pdflib-#.##-ebcdic.tar.Z

(The *.gz distribution of PDFlib generally won't work since it
was compressed using gzip instead of compress, and contains
ASCII instead of EBCDIC text files.)

PDFlib's configure and Makefile machinery can be used to build
a static PDFlib library on the S/390. However, automatic support
for building S/390 DLLs is currently not available.

The zlib compression library can be built with the following commands
(unpack zlib1.1.3.tar.gz to zlib1.1.3.tar on a Unix machine):

$ pax -rf zlib1.1.3.tar -o from=ISO8859-1,to=IBM-1047
$ cd zlib-1.1.3
$ make
cc -O -c example.c
cc -O -c adler32.c
cc -O -c compress.c
cc -O -c crc32.c
cc -O -c gzio.c
cc -O -c uncompr.c
cc -O -c deflate.c
cc -O -c trees.c
cc -O -c zutil.c
cc -O -c inflate.c
cc -O -c infblock.c
cc -O -c inftrees.c
cc -O -c infcodes.c
cc -O -c infutil.c
cc -O -c inffast.c
ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o

(The error on building the zlib example program can be ignored.)

You can build the PDFlib test program as follows:

c89 -o pdftest ./pdftest.o ../pdflib/.libs/libpdf.a  /u/zlib/libz.a

Notes on manually compiling the PDFlib wrapper for Java on S/390
can be found in bind/java/readme.txt. Also check our Web site since
we plan to make available pre-built binaries for S/390.


MVS notes
=========

On MVS you must rename the AFM metrics files, change the name of pdflib.upr
to PDFLBUPR, and change all entries in pdflib.upr accordingly.

Specify the MVS PDFLIB.UPR path as follows:

PDF_set_parameter(p, "resourcefile", "'LRS164.VPS.R80.CNTL(PDFLBUPR)'");
PDF_set_parameter(p,"prefix","'LRS164.VPS.R80.CNTL");


Building PDFlib on the AS/400
=============================

The following steps have been reported to result in successful PDFlib
build and deployment on the AS/400:

- Create a library and source files:

  CRTLIB LIB(LIBPDF)
  CHGCURLIB LIB(LIBPDF) 
  CRTSRCPF FILE(H) RCDLEN(240) /* For Header files */ 
  CRTSRCPF FILE(QCSRC) RCDLEN(240) /* For C files */

- Unpack the PDFlib source distribution and transfer to the AS/400
  using FTP. The files must be converted to EBCDIC during the transfer.
  The FTP commands will look similar to the following:

  put pdflib.h H.pdflib 
  put p_afm.c QCSRC.p_afm
  ...

- Create PDFlib modules:

  CHGCURLIB LIB(LIBPDF) 
  CRTCMOD MODULE(P_AFM) DEFINE(AS400 PDFLIB_EBCDIC) SYSIFCOPT(*IFSIO) 
  CRTCMOD MODULE(P_ANNOTS) DEFINE(AS400 PDFLIB_EBCDIC) SYSIFCOPT(*IFSIO)
  ...

- Create the PDFlib service program. First, create a AS/400 export language
  source for each module:

  CHGCURLIB LIB(LIBPDF) 
  CRTSRCPF FILE(PDFMAKE) 
  RTVBNDSRC MODULE(P_AFM) SRCFILE(PDFMAKE) SRCMBR(MODEXPORT) MBROPT(*REPLACE) 
  RTVBNDSRC MODULE(P_ANNOTS) SRCFILE(PDFMAKE) SRCMBR(MODEXPORT) MBROPT(*ADD) 
  RTVBNDSRC MODULE(P_BASIC) SRCFILE(PDFMAKE) SRCMBR(MODEXPORT) MBROPT(*ADD) 
  RTVBNDSRC MODULE(P_CCITT) SRCFILE(PDFMAKE) SRCMBR(MODEXPORT) MBROPT(*ADD)
  ...

  Make a copy of the export language in file PDFMAKE, member MODEXPORT to
  member SRVEXPORT. Edit the text in member SRVEXPORT to remove the export,
  STRPGMEXP, and ENDPGMEXP statements that are not required.

  The final step is to build the service program, using the following AS400
  commands: 

  CHGCURLIB LIB(LIBPDF) 
  CRTSRVPGM SRVPGM(PDFLIB) MODULE(*CURLIB/P_*) +
      EXPORT(*SRCFILE) SRCFILE(PDFMAKE) SRCMBR(SRVEXPORT) +
      TEXT('PdfLib Service program')

- To do a test run using the supplied pdftest.c demo edit the prefix entry
  in fonts/pdflib.upr, and upload the contents of the fonts directory to
  the AS/400. Also upload the image test files from the test directory.
  Then create the test program as follows: 

  CHGCURLIB LIBPDF 
  CRTCMOD MODULE(PDFTEST) DEFINE(AS400 PDFLIB_EBCDIC) SYSIFCOPT(*IFSIO) 

  CRTPGM PGM(PDFTEST) MODULE(PDFTEST) BNDSRVPGM(*LIBL/PDFLIB) + 
     TEXT('PDFLIB Test Program')

  Then run the test program: CALL PGM(TESTPDF)
