Create Page Segment from STMF


*------------------------------------------------------------------------ * @Author: Kato Integrations * @Description: * This is a test program demonstrating how to call IPI APIs to * create a page segment (*PAGSEG) from a provided image file in the * IFS. You can specify the dimensions of the page segment being created * in inches. *------------------------------------------------------------------------ H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('IPIBND') OPTION(*NODEBUGIO) /COPY QRPGLECPY,IPICB // This is included for demo output purposes only and is not part of IPI. D WriteToJobLog PR 10I 0 Extproc('Qp0zLprintf') D pString * Value Options(*String) D NewLine C x'15' // This data structure will contain any error information returned by // the IPI APIs. D IPIErrorDS DS LikeDS(IPI_ErrorDS_t) Inz(*LikeDS) // This data structure is used to configure how image data is loaded as // well as whether or not the image is coming from a STMF or a field. D LoadImageDS DS LikeDS(IPI_LoadImageDS_t) D Inz(*LikeDS) // This data structure is used to pass around information about a loaded // image to other IPI APIs for further processing or output. D ImageDS DS LikeDS(IPI_ImageDS_t) D Inz(*LikeDS) // This data structure configures where the page segment will be // created and allows you to specify the target dimensions of the // page segment in inches. D TargetPagSegDS DS LikeDS(IPI_PageSegmentDS_t) D Inz(*LikeDS) /FREE // Always call IPI_Initialize() before calling any other IPI APIs. // IPI_Initialize() will return *On if it was successful or *Off if not reset IPIErrorDS; if not IPI_Initialize( IPIErrorDS ); // handle error here WriteToJobLog( 'IPI_Initialize() Error' + NewLine ); WriteToJobLog( 'Error Message ID: ' + IPIErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + IPIErrorDS.Message + NewLine ); exsr cleanup; return; endif; // Always reset IPI data structures before using them. reset ImageDS; reset LoadImageDS; // Set which IFS image file to create a page segment from LoadImageDS.Stmf = '/tmp/image.tiff'; // Is the input data base64 encoded? LoadImageDS.Base64Encoded = IPI_NO; reset IPIErrorDS; if not IPI_LoadImage( ImageDS : LoadImageDS : *Omit : IPIErrorDS ); // handle error here WriteToJobLog( 'IPI_Initialize() Error' + NewLine ); WriteToJobLog( 'Error Message ID: ' + IPIErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + IPIErrorDS.Message + NewLine ); exsr cleanup; return; endif; // Specify location of created page segment reset TargetPagSegDS; TargetPagSegDS.ObjectName = 'IPITSTPS'; TargetPagSegDS.LibraryName = 'IPI'; // Width in inches TargetPagSegDS.Width = 2.00; // Height in inches TargetPagSegDS.Height = 1.00; reset IPIErrorDS; if not IPI_ImageToPageSegment( ImageDS : TargetPagSegDS : IPIErrorDS ); // handle error here WriteToJobLog( 'IPI_Initialize() Error' + NewLine ); WriteToJobLog( 'Error Message ID: ' + IPIErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + IPIErrorDS.Message + NewLine ); exsr cleanup; return; endif; exsr cleanup; *INLR = *ON; return; begsr cleanup; IPI_UnloadImage( ImageDS : IPIErrorDS ); IPI_Terminate( IPIErrorDS ); endsr; /END-FREE