Salesforce

Generating Adobe PDF Documents with Graphical Overlay on iBM i (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Generating Adobe PDF Documents with Graphical Overlay on iBM i (Magic xpa 3.x)

Prerequisites

Before you can generate PDF files with Magic xpa on an i 6.1/ i7.1 system, there are a few prerequisites.

  • Magic xpa server for IBM i must be installed and configured on your system.

  • IBM licensed program 5761SS1 on V6R1M0 (R610) i5/OS or 5770SS1 on V7R1M0 (7.1) i5/OS Option 3 (which includes support for the IFS) and Option 33 (which includes support for the Portable Application Solutions Environment or PASE) of the operating system must be installed.

  • The licensed programs mentioned above were most probably installed already on your system since they are also required to run the Magic xpa server on IBM i.

  • The IBM licensed program Transform Services for i5/OS, 5761TS1 on V6R1M0 (R610) i5/OS or 5770TS1 on V7R1M0 (7.1) i5/OS, must have both the base option and Option 1 installed. This product is free and ships as part of the bonus pack with i 6.1 and i 7.1.

Objective

How can we generate Adobe PDF documents with a graphical overlay from our Magic xpa applications running on IBM i and store them in stream files in an IFS directory for use with client applications?

The Magic xpa server running on IBM i 6.1/7.1 provides a simple way to do this.

Solution

Main Concept

The IBM licensed program Transform Services lets you "override" the IBM i spool file into a PDF document in the IFS directory using the OVRPRTF command.

Implementation

The OVRPRTF OS/400 command is limited to running in a single thread environment only. In a multi-threaded job, this command can only be issued from the initial thread.

Considering the mentioned limitation of the OVRPRTF command, there are two possible implementation scenarios:

  • Single thread Magic xpa setup: Magic xpa server job without connection to Magic xpa Broker or any other middleware.

  • Multi-thread Magic xpa setup: RIA, Internet or Partitioning environment.

1. If you plan to run Magic xpa as a single thread job, follow the steps below:

  1. Create a standard Magic xpa text-based printing program defining the “Printer” media in the I/O properties of the Magic xpa task.

  2. Prior to calling a printing task, execute the IBM i command OVRPTF using the “Invoke OS command” operation:

    OVRPRTF FILE(MAGICPRTF) DEVTYPE(*AFPDS) TOSTMF(''/tmp/magic.pdf'') FRONTOVL(MSE/LEON2) WSCST(*PDF) OVRSCOPE(*JOB)

    Where TOSTMF() is the IFS path of the PDF file to be created (make sure it doesn’t exist)

    If you test the command from IBM i command line, one single quote is required: TOSTMF('/tmp/magic.pdf')

    In the Magic xpa expression, use two single quotes: TOSTMF(''/tmp/magic.pdf'')

    FRONTOVL() – overlay object with graphic (see the Create Graphical Overlay Object section below)


  3. After closing the printing task, delete the Override using the DLTOVR FILE(MAGICPRTF) LVL(*JOB) command.

    Make sure to call it via the Magic xpa Invoke OS Command operation not via a Call UDP operation.

2. If your Magic xpa application is configured for a multi-threaded environment, follow the steps below:

  • Set File in the I/O Properties of your printing task. Magic xpa will generate a text-based IFS file that can be converted later to a PDF using the MGPRINTC utility from the Magic xpa server library.

3. By the end of the printing task, call the following commands using Call UDP MGEAC32.ISERIES:

-ADDLIBLE LIB(MAGICXPA) POSITION(*LAST)

Where MAGICXPA is the Magic xpa server library on IBM i

-OVRPRTF FILE(MAGICPRTF) DEVTYPE(*AFPDS) TOSTMF(''/tmp/magic.pdf'') FRONTOVL(MSE/LEON2) WSCST(*PDF) OVRSCOPE(*JOB)

Where

TOSTMF() is the IFS path of the PDF file to be created (make sure it doesn’t exist)

If you test the command from IBM i command line, one single quote is required: TOSTMF('/tmp/magic.pdf')

In the Magic xpa expression, use two single quotes: TOSTMF(''/tmp/magic.pdf'')

FRONTOVL() – the overlay object with a graphic (see the Create Graphical Overlay Object section below)

-CALL MAGICXPA/MGPRINTC PARM(IFSFile ‘N’)

Where

IFSFile is the full path of the text-based report that was just produced by the Magic xpa printing task.

-DLTOVR FILE(MAGICPRTF) LVL(*JOB)


The commands described above will convert the IFS text-based file that was generated by Magic xpa into a PDF document with a graphic background.

The same method is applicable for Magic xpa Windows clients.

If you generate text-based file in the IFS directory of your IBM I server, you can convert it to a PDF using the steps below.

Create Graphical Overlay Object (OVL)

The steps below are instructions for generating an Overlay object that can be used to assign a graphical background for your PDF documents.

  1. Install the IBM AFP 300 driver (ftp://ftp.software.ibm.com/printers/drivers/afp/IBMAFPDrv.exe).

  2. Add the printer manually (local port - > File, local drive c:\driver_path).

  3. Create your overlay document with Excel or Word by joining your graphical elements.

  4. Go to Print/Property on the IBM AFP 300 printer and select Overlay as the Output type.

  5. Check the Print to file box.


  6. In the System i Navigator, go to the AFP Manager.


  7. Import the PRN file and indicate the library to generate the ".OVL" object.

The imported OVL object can be used in the OVRPRTF command to assign graphical overlays for your PDF documents.

For more information, see the IBM documentation regarding the OVRPRTF command and PDF generation on the IBM i system.

Reference
Attachment 
Attachment