Printing a BMP file to a print job

35 views
Skip to first unread message

Richard Kann

unread,
Jul 1, 2009, 6:40:30 PM7/1/09
to Devsup, jB...@googlegroups.com
Hi All:

I am trying to print a .bmp file (a signature capture) to a PCL inkjet
printer (Jbase version 3.4.x windows) at the bottom of an invoice. Has
anyone accomplished this before or knows how to do it?

Richard Kann
Comp-Ware Systems, Inc.

Tony G

unread,
Jul 2, 2009, 12:16:52 AM7/2/09
to jB...@googlegroups.com
Richard - always great to see ya.

See the demos I created for PrintWizard, BASIC source code
provided:
nospamNebula-RnD.com/products/printwizard.htm
Contact info for the vendor at bottom of that page.

We don't sell PrintWizard or get commissions, I just think it's
great software and quite frequently it's THE solution to lots of
printing problems people present in these forums.

Please let us know what you think.
Tony Gravagno
Nebula Research and Development
TG@ remove.pleaseNebula-RnD.com

Daniel Klein

unread,
Jul 2, 2009, 9:12:44 AM7/2/09
to jB...@googlegroups.com
I use DOSPrinter for all of my printing needs.
http://www.geocities.com/DOSPrint/

It is especially handy when you have a GDI printer.

And it is easy enough to integrate with the jBASE spooler.

Dan

Richard Kann

unread,
Jul 2, 2009, 5:38:15 PM7/2/09
to jB...@googlegroups.com
Thanks. One question though. It works in command prompt in windows, but when I put it in a program it locks up and will not print. This is the code line. Any ideas:

EXECUTE CHAR(255):'k':'C:\TEMP\DOSPRINTER C:\TEMP\SAMPLE2.PRN'

Daniel Klein

unread,
Jul 2, 2009, 6:30:21 PM7/2/09
to jB...@googlegroups.com
I think you need to specify the destination printer. Here is an
example of what works for me:

cmd = "C:\Software\DOSPrinter\DOSPrinter.exe /SEL'Canon_i850' c:\temp\file.txt"
EXECUTE CHAR(255):'k':cmd

Where 'Canon_i850' is the name of the printer; on my system it is the
network shared name.

Dan

Richard Kann

unread,
Jul 2, 2009, 8:55:44 PM7/2/09
to jB...@googlegroups.com
I will try it. What I found is if I log onto the windows account jbase runs on it works. If I go on a different account it does not. But I did not try the specif printer approach.

I am assuming in order to use this I need to put the entire invoice in a text file, write it out somewhere in windows and then print and delete it. That is how print wizard works.

It would be nice if jbase itself had a utility to print graphics files within normal print statements. This way I would not have to re-write entire programs to do this kind of printing.

Daniel Klein

unread,
Jul 2, 2009, 11:07:52 PM7/2/09
to jB...@googlegroups.com
Actually, it's DOSPrinter that allows you to embed graphics in the
document. If you read the documentation from that link, it tells you
how to do this. In a nutshell, there are a few options but the way I
do it is to place:

<esc>"graphic_name"

in the document at the place you want the graphic to be. Note that
<esc> is char(27).

You can generate the document so that it ends up in the jBASE spooler
under a form queue that is created like this:

SP-CREATE CANON PROG c:\home\bin\jspool.exe Canon_i850

Here's the 'jspool.b' code that uses DOSPrinter:

0001 PROGRAM jspool
0002 INCLUDE JBC.h
0003 id = CHANGE(UNIQUEKEY(),'/',']2F')
0004 tempdirname = 'c:\temp'
0005 OPENSEQ tempdirname:DIR_DELIM_CH:id TO outstream ELSE
0006 CREATE outstream ELSE NULL
0007 END
0008 args = SYSTEM(1000) ;* addl parameters (like
printername, cpi, lpi, font, etc)
0009 printername = args<2>
0010 cpi = args<3>
0011 IF cpi = '' THEN cpi = 10
0012 LOOP
0013 numchars = SYSTEM(14)
0014 WHILE numchars DO
0015 INPUT line, numchars
0016 line := CHAR(13)
0017 WRITESEQ line ON outstream ELSE NULL
0018 REPEAT
0019 WEOFSEQ outstream ELSE NULL
0020 CLOSESEQ outstream
0021 cmd = "C:\Software\DOSPrinter\DOSPrinter.exe /DEL
/SEL'":printername:"' /CPI":cpi:' '
0022 cmd := tempdirname:DIR_DELIM_CH:id
0023 EXECUTE CHAR(255):'k':cmd

If you are on jBASE 3.x then you would need to:

a) change line 3 to something like this:

id = SYSTEM(21):'_':DATE():'_':TIME():'_':SYSTEM(9):'_':RND(32000)

b) change the OPENSEQ lines 5 thru 7 (inclusive) to:

OPENSEQ tempdirname:DIR_DELIM_CH:id TO outstream NULL

c) make sure 'openseq_creates = true' is set in your 'Config_EMULATE'
file under the appropriate emulation section

And, of course, line 21 should be changed to something that makes
sense on your system

You'll note that the code automagically removes the temp file when it
is done despooling.

DOSPrinter has a robust array of printing options, and all for just 40
smackers for a single user.***

Dan

***Note that I am in no way affiliated with this product, nor do I
receive any kickbacks. I just like it cos it works well and does what
the docs say it does, which is more than I can say for a lot of other
commercial software out there.

Richard Kann

unread,
Jul 3, 2009, 2:15:07 PM7/3/09
to jB...@googlegroups.com
Running into an issue. I set it up as you said tweaking the program to match my system. When I send a job to the new printer it does run the jspool program but nothing is being passed. i know this because I have jspool writing out the numchars value to a file and it comes up with zero each time. What would cause the spooled data to not pass to the jspool program? I assume I send it like normal by doing the printer on and print statements. Program below:

001 OPEN '','MD' TO MD ELSE STOP
002   PROMPT ''
003      INCLUDE JBC.h
004      id = SYSTEM(21):'_':DATE():'_':TIME():'_':SYSTEM(9):'_':RND(32000)
005      tempdirname = 'c:\temp'
006      OPENSEQ tempdirname:DIR_DELIM_CH:id TO outstream ELSE NULL
007      args = SYSTEM(1000)       ;* addl parameters (like
008      printername = args<2>
009      LOOP
010          numchars = SYSTEM(14)
011 WRITE numchars ON MD,'XXXNUM'
012      WHILE numchars DO
013          INPUT line,numchars
014          line=line:CHAR(13)
015          WRITESEQ line ON outstream ELSE NULL
016      REPEAT
017      WEOFSEQ outstream ELSE NULL
018      CLOSESEQ outstream
019      cmd = "C:\DARTSCD\DOSPrinter\DOSPrinter.exe /SEL'":printername:"' "
020      cmd=cmd:' /DEL ':tempdirname:DIR_DELIM_CH:id
021      EXECUTE CHAR(255):'k':cmd
022      END

program doing the printing:

001 PRINTER ON
002 PRINT 'HELLO'
003 PRINT 'HOW ARE YOU'
004 PRINT CHAR(27):'C:\SIGNATURES\836-1.BMP'
005 PRINT 'HELLO AGAIN'
006 PRINTER OFF
007 PRINTER CLOSE
008 END

the above is run after assigning the GPRINT printer specs below::

FormQueue :GPRINT     (DEVCONFIG*1)
  Status  :ASSIGNED  (6)
  DevType :PROG  (2)
  DevName :C:\CWS\DEMO\BIN\JSPOOL.EXE HPLJ6
  LockPid :2320
  Created :DEMO  0  03 JUL 2009  12:42:59
  Stop Reason  :

Daniel Klein

unread,
Jul 3, 2009, 8:29:04 PM7/3/09
to jB...@googlegroups.com
I see 2 distinct problems, one is obvious, the other is going to take
some debugging on your part.

The 'obvious' one is the 'HELLO' code. If you've read the DOSPrinter
documentation says that the embedded string must be of the form:

<esc>"graphic"

so you need to change line 7 to:

004 PRINT CHAR(27):DQUOTE('C:\SIGNATURES\836-1.BMP')

Wrt 'the other problem'...

is 'openseq_creates = true' set in 'Config_EMULATE' ?

is 'HPLJ6' the correct name of the printer, as seen in the printer's
'properties' ?

If you go to Control Panel > Printers, and double-click on the
printer, then despool the job from jBASE, does anything show up in the
printer window?

Dan

Richard Kann

unread,
Jul 3, 2009, 9:09:24 PM7/3/09
to jB...@googlegroups.com
I'll correct the graphics line, but that is not what is causing the issue though. The openseqs is correct as it does create the file. It just has 0 bytes though and nothing is coming into the input prompt. It has a count of zero for numchars. I also tried writing out what got input and it is blank. It seems I should get the hello and other lines as input but nothing is being sent to the program at all (though the program is being run). HPLJ6 is the printer name.

Daniel Klein

unread,
Jul 3, 2009, 10:09:27 PM7/3/09
to jB...@googlegroups.com
At this point, you might want to post a full 'jdiag.out' file (jdiag -vL).

I'm thinking that the problem is with SYSTEM(14). What compiler is
being used on this system?

Try this...

cnt = 0
LOOP UNTIL SYSTEM(14) DO
CRT cnt
cnt++
SLEEP(1)
REPEAT

Run this program and then press any key to put something in the input
buffer. Does the program terminate at that point?

Dan

Daniel Klein

unread,
Jul 4, 2009, 10:48:11 PM7/4/09
to jB...@googlegroups.com
Is 'HPLJ6' a local or network printer?

If it's a network printer then you would have to create the form queue
like this:

SP-CREATE GPRINT PROG C:\CWS\DEMO\BIN\JSPOOL.EXE \\server_name\HPLJ6

Dan

Richard Kann

unread,
Jul 4, 2009, 11:43:12 PM7/4/09
to jB...@googlegroups.com
It's local. And I have printed to it direct via the lp program.

Daniel Klein

unread,
Jul 5, 2009, 6:49:32 AM7/5/09
to jB...@googlegroups.com
Did you check out SYSTEM(14) as previously requested?

Dan

Richard Kann

unread,
Jul 5, 2009, 8:09:32 AM7/5/09
to jB...@googlegroups.com
Not yet. It was 4th of July. Besides you are on vacation. Go have fun! :-)

Richard Kann

unread,
Jul 6, 2009, 9:52:46 AM7/6/09
to jB...@googlegroups.com
The program kept counting until I hit a key. I am using the .NET complier. Jdiag as follows:
    jdiag - jBASE diagnostic

System Information
==================

System                      : Win2K RICK2 5.0 i386
OS Release                  : Win 2000  Build 2195  Service Pack 4
NT User                     : DEMO
jBASE User (JBCLOGNAME)     : DEMO
Time                        : Mon Jul 06 09:49:11 2009

Licence details
===============

jPML: jENTERPRISE licensed for 5 users, expires Mon Dec 14 19:00:00 2009
Product: jENTERPRISE licensed for 5 Users; expires Mon Dec 14 19:00:00 2009

License Details: jENTERPRISE^0^5^1260835200

Environment
===========

JBCWINCONNECT               : 'C:\JBASE30\tmp\jPML_0'
JBCPORTNO                   : Not Set
Connect Port                : '0'
JBCRELEASEDIR               : 'C:\JBASE30'
JBCGLOBALDIR                : 'C:\JBASE30'
HOME                        : 'c:\cws\demo'
JEDIFILEPATH                : '.'
JEDIFILENAME_MD             : 'C:\CWS\DEMO\MD'
MD file is (DICT)           : 'C:\CWS\DEMO\MD]D'
JEDIFILENAME_SYSTEM         : 'C:\CWS\SYSTEM'
SYSTEM File is (DICT)       : 'C:\CWS\SYSTEM]D'
JBCBASETMP (Default)        : 'C:\JBASE30\tmp\jBASEWORK'
JBCNOINTERNAL               : Not Set
JEDI_NOSHMEM                : Not Set
RELEASE Information         : Major 3.4 , Minor 10 , Patch 0373
Spooler dir (JBCSPOOLERDIR) : 'C:\CWS\JSPOOLER'
Spooler directory 'C:\CWS\JSPOOLER' OK
JBCEMULATE                  : Not Set

Executable search Path: c:\cws\demo;C:\WINNT\system32;C:\WINNT;C:\WINNT\system32;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\JBASE30\bin;C:\JBASE30\jDP\bin;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\VC7\BIN;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\COMMON7\IDE;C:\CWS\DEMO\BIN;c:\cws\symbion\bin;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\QuickTime\QTSystem\;C:\JBASE30\bin;C:\CWS\DEMO\BIN
DLL search path: c:\cws\demo;C:\WINNT\system32;C:\WINNT;C:\WINNT\system32;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\JBASE30\bin;C:\JBASE30\jDP\bin;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\VC7\BIN;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\COMMON7\IDE;C:\CWS\DEMO\BIN;c:\cws\symbion\bin;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\QuickTime\QTSystem\;C:\JBASE30\bin;C:\CWS\DEMO\BIN

   Found                    : 'C:\WINNT\system32\libjbase.dll'
   Found                    : 'C:\JBASE30\bin\libinternal.dll'
   Found                    : 'C:\JBASE30\bin\libjcon.dll'
   Found                    : 'C:\JBASE30\lib\libjpq.dll'
   Found                    : 'C:\JBASE30\lib\libqueries.dll'
   Found                    : 'C:\JBASE30\lib\libutils.dll'
   Found                    : 'C:\JBASE30\lib\libjpq.def'
   Found                    : 'C:\JBASE30\lib\libqueries.def'
   Found                    : 'C:\JBASE30\lib\libutils.def'
Object path (JBCOBJECTLIST) : 'C:\cws\demo\lib'
JBC_CCOMPILER_PATH          : C:\Program Files\Microsoft Visual Studio .NET 2003\VC7
JBC_SHAREDIDE_PATH          : C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE
VC++ Registry               : Version 7 (.NET 2003); Path C:\Program Files\Microsoft Visual Studio .NET 2003\VC7
VC++ BIN Path 'C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\bin' OK
VC++ INCLUDE Path 'C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\include' OK
VC++ LIB Path 'C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib' OK
Program dir (Default)       : 'c:\cws\demo\bin'
Program Path 'c:\cws\demo\bin' is in your PATH
Subroutine dir (Default)    : 'c:\cws\demo\lib'
Subroutine path 'c:\cws\demo\lib' is in JBCOBJECTLIST

Full Environent
===============

    ALLUSERSPROFILE=C:\Documents and Settings\All Users.WINNT
    CLASSPATH=.;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=RICK2
    ComSpec=C:\WINNT\system32\cmd.exe
    DiskeeperIcon=C:\Program Files\Executive Software\DiskeeperServer\
    HOME=c:\cws\demo
    HOMEDRIVE=c:
    HOMEPATH=\cws\demo
    INCLUDE=C:\Program Files\Microsoft.NET\SDK\v1.1\include\;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\VC7\INCLUDE
    JBASE_WARNLEVEL=4
    JBCGLOBALDIR=C:\JBASE30
    JBCLOGNAME=DEMO
    JBCOBJECTLIST=C:\cws\demo\lib
    JBCRELEASEDIR=C:\JBASE30
    JBCSPOOLERDIR=C:\CWS\JSPOOLER
    JBCTERM=ANSI
    JBCWINCONNECT=C:\JBASE30\tmp\jPML_0
    JBC_CLIENT_IP=127.0.0.1
    JBC_CLIENT_PORT=14599
    JBC_DESPOOLSLEEP=3
    JBC_TELNET_FLAG=1
    JEDIFILENAME_MD=C:\CWS\DEMO\MD
    JEDIFILENAME_SYSTEM=C:\CWS\SYSTEM
    JEDIFILEPATH=.
    LANG=C
    LIB=C:\Program Files\Microsoft.NET\SDK\v1.1\Lib\;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\VC7\LIB
    NAVROOT=C:\JBASE30\jDP
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    Os2LibPath=C:\WINNT\system32\os2\dll;
    Path=C:\WINNT\system32;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\JBASE30\bin;C:\JBASE30\jDP\bin;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\VC7\BIN;C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO .NET 2003\COMMON7\IDE;C:\CWS\DEMO\BIN;c:\cws\symbion\bin;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\QuickTime\QTSystem\;C:\JBASE30\bin;C:\CWS\DEMO\BIN
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 4, GenuineIntel
    PROCESSOR_LEVEL=15
    PROCESSOR_REVISION=0204
    ProgramFiles=C:\Program Files
    PS5ROOT=C:\Program Files\Roxio\Easy CD Creator 6\PhotoSuite\
    PWD=c:\cws\demo
    QTJAVA=C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
    SHELL=C:\JBASE30\bin\jsh
    SystemDrive=C:
    SystemRoot=C:\WINNT
    TEMP=C:\WINNT\TEMP
    TERM=ANSI
    TMP=C:\WINNT\TEMP
    USERDOMAIN=RICK2
    USERNAME=DEMO
    USERPROFILE=C:\Documents and Settings\Default User.WINNT
    VS71COMNTOOLS=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\
    windir=C:\WINNT
    _=JDIAG

jBase Global Registry
=====================

    JBCRELEASEDIR=C:\JBASE30
    JBCGLOBALDIR=C:\JBASE30
    JBC_PATCHLEVEL=0373
    JBC_VERSION=3.4.10
    JBC_PROCESSOR_ARCHITECTURE=ix86

jBase Current User Registry
===========================

    JBCRELEASEDIR=C:\JBASE30
    JBCGLOBALDIR=C:\JBASE30
    JBC_PATCHLEVEL=0373
    JBC_VERSION=3.4.10
    JBC_PROCESSOR_ARCHITECTURE=ix86
    JBC_CCOMPILER_PATH=C:\Program Files\Microsoft Visual Studio .NET 2003\VC7
    JBC_SHAREDIDE_PATH=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE
    JBCLOGNAME=symbion
    JEDIFILENAME_MD=c:\cws\symbion\MD
    JEDIFILENAME_SYSTEM=c:\cws\SYSTEM
    JEDIFILEPATH=.

Disk Drive Information
======================

Drive C:\
    Total  55.89G    Used  41.20G    Free  14.69G  26%
    SecPerClu 8    BytesPerSec 512    FreeClu 3850635, TotalClu 14651272


Status of jBASE Services
========================

jBASE Telnetd Server         - RUNNING
jBASE License Server         - RUNNING
jBASE jRFS Server            - RUNNING
ISG Navigator Daemon         - RUNNING
There are No warnings, jBASE seems to be loaded correctly

hal...@civicacmi.com

unread,
Jul 6, 2009, 10:05:59 AM7/6/09
to jBASE
If anyone wants an alternate approach to this issue (not necessarily
better, just different), here's what we did in a pinch:

- Create a windows printer using an older HP Laser Jet printer driver
(like a LaserJet III)
- Set it to print to a file
- Print the bmp to this printer, generating a file
- Now you have a PCL stream to print the graphic.
- You then need to edit the stream and delete the first set of pcl
codes up to ^[*t300R. and then everything after the ^[*rB at the end
of the file.
- Then in your Basic program, do your PRINTER ON, then read the above
stream from a file, PRINT it, then print your regular text. The
Graphic print doesn't move the "cursor" on the page, so an ASCII print
will overlay the graphic.


Steve
CMI

Richard Kann

unread,
Jul 6, 2009, 3:18:23 PM7/6/09
to jB...@googlegroups.com
Thanks Dan for the information. As you and I found, for some reason SYSTEM(14) does not pass the input buffer count when it is run in 3.4.x using the spooler under TELNET. It works when you put it in a normal program run under telnet, just not when it is the spooler.

The fix is either running the spooler under the console OR working around the SYSTEM(14) via the special end of job sequence.

Again, thank you for your help. If anyone else needs to know the details they can email me at h...@comp-ware.net or on this group.

Richard Kann
Reply all
Reply to author
Forward
0 new messages