Printing A Graphic Image from
Joe Drouillard
Principal/Consultant
Avenue Systems
http://www.avenue-systems.com/
Steps
for printing a graphic image (such as a logo on an invoice) from Progress - -
works well with Mfg/Pro by QAD.
Summary: Here are the steps for printing a graphic image, such as a logo or signature, on a Progress 4/GL report, when sent to a laserjet printer. First, get a good black and white graphic image. Then, use an inexpensive utility to convert the graphic file to a PCL macro that can be sent to a printer then called from a Progress program. Then, modify the Progress report program to print the graphic as desired.
Scan in a graphic, save it as a black and white bitmap or jpeg (bmp or jpg extension) file, e.g.: ourlog.bmp. Or, get a good high-quality graphic bmp or jpg file from your corporate communications department, preferably a black and white or gray-tone BMP or JPG image file. To make sure it is “pretty” enough, try printing it to a laser printer from your graphic package, or MS Paint. File size or print size of the original graphic are not important, as your graphic may be resized and compressed using the utility described below.
Next, convert the graphic file to a .pcl macro command file. This is essentially a graphic file with additional embedded PCL (laserjet printer control language) commands. You can buy software to do this. HIGHLY recommended at only $75 U.S. is Mkpcl, by Spectra Color Graphics. Contact Jim Asman at jlasman@telus.net. See http://www.spectracolorservices.com/ for more information and trial downloads. Using Mkpcl, one can convert any BMP, JPG or PCX file into a file that is easily called from a Progress program in either Windows or UNIX environments. The mkpcl utility has options for scaling, resizing, positioning, and compressing your image and turning it into a “.pcl” macro file that is sent to your printer at the beginning of a program, then called at will to lay-down a graphic on the printed page.
The following mkpcl command when issued from the Windows command line creates a graphic macro file called “ourlogo.pcl”. It takes the graphic file “ourlogo.jpg” and creates a .4 inch high version in a macro called “017”. Note: a number designation is given for pcl macros, because this is a limitation of HP’s PCL printer language.
C:\mkpcl
–m 017 –h .4 ourlogo.jpg ourlogo.pcl.
The ourlogo.pcl file, though created on a PC, can easily be transmitted to a UNIX platform using any FTP software. Just make sure that you have the “BINARY” option set on. For those who prefer, there is also a UNIX version of Mkpcl.
Why use a Macro? Because the Progress 4GL does not give strict control over the printing process. By calling the Macro before starting a new page, graphic printing works better. Simply send the PCL graphic file once to the printer, and call it at will from the Progress program using simple PUT CONTROL commands as follows:
At the beginning of the Progress program a UNIX or DOS command is used to transmit the PCL macro command to the printer. For UNIX, use the lp command. For DOS/Windows, use the print or copy command. This will have the effect of storing it on your printer temporarily as a saved macro command. Then, the PUT CONTROL command is used to transmit a PCL command to the printer once to print the graphic automatically on every page. Or, a PCL command can be issued to selectively call the macro when the graphic is desired, e.g.: to print the “fine print” at the bottom of the last page of a shipping document.
The following example sends the macro to the printer using the UNIX lp command, then immediately issues the command which will force the graphic to print on every subsequent page.
UNIX
silent lp -s -d printerdevice
/data/ourlogo.pcl
PUT CONTROL
"~033&f017Y4X". /*print
using macro 17 on all subsequent pages*/
The follwing “3X” command (instead of the “4X, above) may be inserted further in the program to only call the macro once, when desired.
PUT CONTROL
"~033&f017Y3X". /*print
once using macro 17*/
One other command to consider is the PCL cursor control command. Often this is important to tell the printer where to print the graphic, and/or where to resume printing after the graphic has been laid down. The following example puts the cursur to row 0, column 0, or the the top left – i.e.: beginning – of the page.
PUT CONTROL "~033&a0r0C”
Here is another example for printing a logo on every page, and “fine print” trailer pcl files in a QAD Mfg/Pro shipper and bill of lading print program. Macro 17 contains the logo, and macro 18 contains the “fine print” trailer.
At the beginning of the QAD Mfg/Pro program . . .
if available prd_det and prd_path gt
"" then
do:
unix silent value(prd_path + " /scripts/ourlogo.pcl").
/*copy logo pcl macro to printer*/
put control "~033&f017y4X".
/*enables macro 17 on every page*/
put control "~033&a0r0C".
/*put cursor to top*/
unix silent value(prd_path + " /scriptsl/shippertrail.pcl").
/*copy trailer macro to printer for later use*/
The logo will now print automatically on every page in the QAD Mfg/Pro shipper form. At the end of the final page, after printing all detail and trailer comments - and ensuring there is adequate room left to print on the page . . . the fine-print macro will be called:
if available prd_det and prd_path gt
"" then
do:
put control "~033&a47r0C". /*Position cursor for trailer, row 47, col 0*/
put control "~033&f018y3X". /*call trailer pcl macro 018 */
end.
Note: the “if available prd_det” etc. is done to avoid transmitting the logo if output is not to a printer (i.e.: to the terminal). You will need to adjust this logic further if your installation has any non-PCL printers.
Please
feel free to contact me if you need assistance.
J o s e p h D r o u i l l a r d
Principal/Consultant
Avenue Systems
Novi
http://www.avenue-systems.com/