Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
How to Print JPEG using DDS and RPG
has no ratings.
Published: 26 Sep 2013
Revised: 11 Aug 2016 - 2815 days ago
Last viewed on: 25 Apr 2024 (14789 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

How to Print JPEG using DDS and RPG Published by: Bob Cozzi on 26 Sep 2013 view comments(1)

The goal is simple for any non-IBM i system: PRINT SOMETHING NON-TEXT in nature.

I've read up on the AFPRSC Keyword. I have it working.

I've read up on the OUTQ Mfg Model Number Parameter.

I haven't read up much at all on CRTDEVPRT command.

Here are the Original Requirements:

  1. Capture a Signature from a Pad and store it in a BLOB in DB2. DONE
  2. Extract the BLOB on demand send it to the Epson Receipt Printer. DONE

Here are the NEW Requirements:

  1. Capture the Signature as before. DONE
  2. Print the Signature on another printer (such as one of the HP LaserJet printers) that are attached to the IBM i system as an IP Printer (remote outq).

Using AFPRSC DDS Keyword I can generate a SPOOL file. All text and barcodes in that SPOOL file print on the HP Printers. The Image identified by the AFPRSC does NOT print.

PDF Round Trip

If I copy that SPOOL file to a PDF file on the IFS, then use the COZTOOLS CPYFRMPDF command and copy that PDF to the OUTQ for the remote printer (the same outq from where it was originally printed), the PDF (text and image) print as expected. They don't print perfectly, but at least everything prints.

Is there any working example of using the AFPRSC DDS keyword to print an Image stored on the IFS?

Preferrably to a HP or Epson Printer but anything. I'd also settle for any written example (in RPG or C) of using the QImgCvtI API.

NOTE: PAGESEQ and OVERLAY are NOT applicable since they are more STATIC entities that require conversion of the image to some goofy IBM-only format using a process that screams "Move off the 400".

The weird thing is this: Last month, I could swear I had this simple tool I wrote PRTIMG (Print Image File) working. It loaded a JPG from the IFS into the AFPRSC keyword and it printed--after screwing with the scaling. Today I can no longer find those settings or perhaps I used the PDF "round trip" technique I mentioned above, and simply forgot.

Example RPG PRTIMAGE Source

     H DFTACTGRP(*NO) ACTGRP(*NEW) OPTION(*SRCSTMT: *NODEBUGIO)
     H THREAD(*SERIALIZE)
     FPRTIMAGE  O    E             PRINTER
     D entryPList      PR                  extpgm('PRTIMAGE')
     D  imageFile                   128A   Const Varying
     D  path                        640A   Const Varying
     D  pos                                Const LikeDS(POS_T)
     D  imgSize                            Const LikeDS(POS_T)
     D entryPList      PI
     D  imageFile                   128A   Const Varying
     D  path                        640A   Const Varying
     D  pos                                Const LikeDS(POS_T)
     D  imgSize                            Const LikeDS(POS_T)

     D pos_T           DS                  Qualified
     D  elem                          5I 0
     D  top                           5P 3
     D  left                          5P 3
     D  width                         5P 3  overlay(top)
     D  height                        5P 3  overlay(left)
     C                   MOVE      *ON           *INLR
      /free
           data = 'This is the Image Print Test program';
           imgDown   = pos.top;
           imgAcross = pos.left;
           imgWidth  = imgSize.width;
           imgHeight = imgSize.height;

           imgFile   = imageFile;
           imgPath   = path;
           write image;
           write text;
           return;
      /end-free 

Example DDS PRTF PRTIMAGE Source

     A          R TEXT                      SPACEA(1)
     A            DATA          56A        2SPACEA(1)
     A          R IMAGE                     AFPRSC(&IMGFILE *JFIF +
     A                                             &IMGDOWN &IMGACROSS +
     A                                             (*PATH &IMGPATH) +
     A                                             (*MAPOPT *SL)   +
     A                                             (*SIZE &IMGWIDTH &IMGHEIGHT))
     A            IMGWIDTH       5S 3P
     A            IMGHEIGHT      5S 3P
     A            IMGDOWN        5S 3P
     A            IMGACROSS      5S 3P
     A            IMGFILE      125A  P
     A            IMGPATH      640A  P 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: vhamberg
Comment on: How to Print JPEG using DDS and RPG
Posted: 7 years 8 months 14 days 11 hours 7 minutes ago

If your release of the OS is 7.1 or lower, Host Print Transform does not support the AFPRSC keyword, and you will get an empty area where the image should have gone.