IBM Toolbox for Java Example: Reading and Transforming Spooled File Data

## Examples using PrintObjectPageInputStream and PrintObjectTransformedInputStream

The following examples demonstrate how to set up a PrintParameterList to obtain different transformations when reading spooled file data. In the code segments that follow, assume a spooled file already exists on a system, and the createSpooledFile() method creates an instance of the SpooledFile class representing the spooled file.

### Example of PrintObjectPageInputStream

The following example shows how to create a PrintObjectPageInputStream object for reading pages of data formatted as GIF images. In this case, each page from the spooled file will be transformed into a GIF image. A GIF workstation customization object is used to specify the data transform.

    // Create a spooled file
    SpooledFile splF = createSpooledFile();

    // Set up print parameter list
    PrintParameterList printParms = new PrintParameterList();
    printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPGIF.WSCST");
    printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");

    // Create a page input stream from the spooled file
    PrintObjectPageInputStream is = splF.getPageInputStream(printParms);

### Example of PrintObjectTransformedInputStream

The following example shows how to create a PrintObjectTransformedInputStream object for reading data formatted as TIFF. A TIFF (G4 compression) workstation customization object is used to specify the data transform.

    // Create a spooled file
    SpooledFile splF = createSpooledFile();

    // Set up print parameter list
    PrintParameterList printParms = new PrintParameterList();
    printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPTIFFG4.WSCST");
    printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");

    // Create a transformed input stream from the spooled file
    PrintObjectTransformedInputStream is = splF.getTransformedInputStream(printParms);

### Example of PrintObjectTransformedInputStream using manufacturer type and model

The following example shows how to create a PrintObjectTransformedInputStream object for reading data formatted for output to an ASCII printer. A manufacturer type and model of *HP4 is used to specify the data transform.

    // Create a spooled file
    SpooledFile splF = createSpooledFile();

    // Set up print parameter list
    PrintParameterList printParms = new PrintParameterList();
    printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*HP4");

    // Create a transformed input stream from the spooled file
    PrintObjectTransformedInputStream is = splF.getTransformedInputStream(printParms);