Print image on 4GL report
Posted in 2009
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
On May 26, 3:04 pm, loc <c320...@gmail.com> wrote: > Is it possible to print an image on an Informix 4GL report? I would > like to print a signature on checks. I always output my reports to a > file with: > > "start report report_name to file_name" > > If 4GL can't directly add an image to the report maybe I can post > process the report file and add the image somehow? The check > signature would be the last line of the report, which may make it > easier to append an image to the end of the report text file. Anyone > done this? I found a solution to print an image on a 4GL report using a HP Laserjet macro. Convert bmp image to postscript # convert image.bmp image.ps Convert the postscript image file into pcl using ghostscript # gs -sDEVICE=ljet4 -sOutputFile=image.pcl - < image.ps Get the PCL reference manual: http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13210/bpl13210.pdf Look at the Macros chapter. Edit the PCL image file: You will need to delete all printer resets <ESC>E in the PCL file. The reset command is not allowed in a macro. To position the image (a signature in my case) you will also need to edit the PCL file and remove some stuff. Delete everything up to but not including the resolution command <ESC>*t#R, # is the dpi probably 600. Then delete everything up until <ESC>*r1A, which is the Start Graphics command. The end of the file should have a <ESC>*rB, which is the End Raster Graphics command. Anything after that should be deleted. After the resolution command <ESC>*t#R add <ESC>&a3500h6400V to position the image at (3500, 6400) or wherever you want it to print. Then edit the PCL file and to the top of the file add: <ESC>&f14Y<ESC>&f0X and to the bottom of the file add: <ESC>&f1X<ESC>&f10X Here is what those PCL comands mean: <ESC>&f14Y # Assigns a unique identification number (14) to the macro. <ESC>&f0X # Start macro definition <ESC>&f1X # Stop macro definition <ESC>&f10X # Make macro permanent Send the PCL file to the printer, you must use the raw option so the cups printer definition file doesn't remove the pcl commands lp -o raw image.pcl The macro should now be stored in the printer, to print the image from the macro use: <ESC>&f14Y<ESC>&f2X <ESC>&f14Y # Specify macro you want to use <ESC>&f2X # Execute last specified macro In the 4GL report it would look like this: print ascii 27, "&f0S", # Push (Store cursor position) ascii 27, "&f14Y", # Specify printer macro number 14 ascii 27, "&f2X", # Execute last specified macro ascii 27, "&f1S" # Pop (Recall last pushed cursor position) The Push and Pop of the cursor is only needed if you are going to print more lines after the image so that the cursor is returned to it's last location. You could also use "&f4X" to print the macro in overlay mode which means the macro is the final operation each time a page is printed so the cursor position after the macro is printed wouldn't matter. One other note, the macros are lost if the power is turned off on the printer, but they can be stored in ROM as described in the PCL manual at the link I gave above. Otherwise just make sure you send the PCL file with macro definition to the printer each time before the 4GL report prints.
On Mon, Jul 27, 2009 at 19:25, loc<c320sky@gmail.com> wrote: > On May 26, 3:04 pm, loc <c320...@gmail.com> wrote: >> Is it possible to print an image on an Informix 4GL report? I would >> like to print a signature on checks. I always output my reports to a >> file with: >> >> "start report report_name to file_name" >> >> If 4GL can't directly add an image to the report maybe I can post >> process the report file and add the image somehow? The check >> signature would be the last line of the report, which may make it >> easier to append an image to the end of the report text file. Anyone >> done this? > > > I found a solution to print an image on a 4GL report using a HP > Laserjet macro. [...multi-step solution omitted...] Wow - well done! Have you looked at automating this? Would a Perl script or something make it feasible not to have to worry about it all? -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. Ted Turner - "Sports is like a war without the killing." - http://www.brainyquote.com/quotes/authors/t/ted_turner.html
On Jul 28, 7:29 pm, Jonathan Leffler <jleffler.i...@gmail.com> wrote: > On Mon, Jul 27, 2009 at 19:25, loc<c320...@gmail.com> wrote: > > On May 26, 3:04 pm, loc <c320...@gmail.com> wrote: > >> Is it possible to print an image on an Informix 4GL report? I would > >> like to print a signature on checks. I always output my reports to a > >> file with: > > >> "start report report_name to file_name" > > >> If 4GL can't directly add an image to the report maybe I can post > >> process the report file and add the image somehow? The check > >> signature would be the last line of the report, which may make it > >> easier to append an image to the end of the report text file. Anyone > >> done this? > > > I found a solution to print an image on a 4GL report using a HP > > Laserjet macro. [...multi-step solution omitted...] > > Wow - well done! > > Have you looked at automating this? Would a Perl script or something > make it feasible not to have to worry about it all? > Uhm Why? Look, because you can't control the printer, meaning that it could be turned off or something else could be written to the same id, you really should do this each time. (Already pointed out by the OP) So why not store the image, and the escape commands in the data base? Then in your report, you could on the FIRST PAGE, print out the macro, or at the start of your 4GL program, pipe the image out to a shell and to the printer, then embed the escape codes in your report.