How to send Printing to USB printer direct from programme in hb

2,244 views
Skip to first unread message

Koshal Agarwal

unread,
Apr 8, 2016, 11:48:19 AM4/8/16
to Harbour Users
hi group I have just come to know to this great tool harbour migrated successfully from clipper to it and able to run my aplication on All windows all bits  
How to send Printing to USB printer direct from programme in hb,Pls help
koshal

Angel Pais

unread,
Apr 8, 2016, 2:30:15 PM4/8/16
to harbou...@googlegroups.com
SET PRINTER TO \\<printserver>\<printer>.

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Koshal Agarwal

unread,
Apr 8, 2016, 11:30:47 PM4/8/16
to Harbour Users
thanks angal i tried it but it is not working it is giving me can not open \\lenovo-pc\hp915.prn 

Jayadev U

unread,
Apr 9, 2016, 3:20:08 AM4/9/16
to harbou...@googlegroups.com

Hi Koshal,

 

You can try my generic txt2gdi converter available here:

 

https://dl.dropboxusercontent.com/u/59333591/txt2gdih.prg

 

Hope that helps,

 

Warm regards,

 

Jayadev

Paul Smith

unread,
Apr 9, 2016, 7:06:05 AM4/9/16
to Harbour Users
Try set printer to \\lenovo-pc\hp915\

that may work
Cheers Paul

Francesco Perillo

unread,
Apr 9, 2016, 7:20:02 AM4/9/16
to harbou...@googlegroups.com

Depending on how you print, you may be interested to create a pdf and then run a pdf reader. The user will print on the printer he chooses.
You may also add other functionality: print an invoice and send it by mail from the program...

--

Klas Engwall

unread,
Apr 9, 2016, 9:46:52 AM4/9/16
to harbou...@googlegroups.com
Hi Koshal,

> thanks angal i tried it but it is not working it is giving me can not
> open \\lenovo-pc\hp915.prn

".prn" is a so called default extension that Harbour adds when it thinks
you are printing to a file. It is the same behaviour as when you open a
.dbf file or a .ntx file, etc, without specifying the extension. And it
is exactly how Clipper worked too (except that Clipper would not
understand the UNC path at all).

You can "trick" Harbour into not adding ".prn" using the technique Paul
suggested, or you can turn off default extensions completely with
SET(_SET_DEFEXTENSIONS,.F.)

But that is a global setting, which means that ".dbf", ".ntx" and other
extensions will also not be added automatically. A workaround for that
can be to turn _SET_DEFEXTENSIONS off temporarily while opening the
printer and then immediately tuning them on again afterwards.

But there are also other printing methods, as has already been mentioned
in this thread. Additional methods include:

win_PrintFileRaw() which uploads a raw text file, including optional
printer commands, to the printer

win_PrintDataRaw() which does the same but from a character variable
instead of from a file

the win_tPrn() class which is a "real Windows printing" solution
available for printers that are installed in Windows.

All those three solutions exist in the hbwin contrib.

Regards,
Klas

Koshal Agarwal

unread,
Apr 10, 2016, 12:10:11 PM4/10/16
to Harbour Users
it worked but came out with a blank page

koshal

Koshal Agarwal

unread,
Apr 10, 2016, 12:35:24 PM4/10/16
to Harbour Users
thanks jayadev I tried to do it with ur prg but it give this error pls suggest
Generating C source output to 'C:\Users\Lenovo\AppData\Local\Temp\hbmk_np88se.di
r\main.c'... Done.
Compiling 'kos.prg'...
Lines 1185, Functions/Procedures 25
Generating C source output to 'C:\Users\Lenovo\AppData\Local\Temp\hbmk_np88se.di
r\kos.c'... Done.
C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.dir/kos.o:kos.c:(.data+0xf8): und
efined reference to `HB_FUN_WINGETPRINTERS'
C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.dir/kos.o:kos.c:(.data+0x158): un
defined reference to `HB_FUN_WIN_PRN'
collect2: ld returned 1 exit status
hbmk2: Error: Running linker. 1
c:\hb30\comp\mingw\bin\gcc.exe C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.di
r/main.o C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.dir/kos.o C:/Users/Lenov
o/AppData/Local/Temp/hbmk_np88se.dir/hbmk_m4cs1y.o    -mwindows -Wl,--start-grou
p -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd
 -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddns
x -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmain
win -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomd
lg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg3
2 -lwininet -lhbpcre -lhbzlib   -Wl,--end-group -oSCR.EXE  -Lc:/hb30/lib/win/min
gw -Lc:/hb30/bin

AL67

unread,
Apr 10, 2016, 1:52:59 PM4/10/16
to Harbour Users


W dniu sobota, 9 kwietnia 2016 05:30:47 UTC+2 użytkownik Koshal Agarwal napisał:
thanks angal i tried it but it is not working it is giving me can not open \\lenovo-pc\hp915.prn 

On Saturday, April 9, 2016 at 12:00:15 AM UTC+5:30, Angel Pais wrote:
SET PRINTER TO \\<printserver>\<printer>.

Correct version (work with Clipper and Harbour) is:

SET PRINTER TO \\<printserver>\<printer>\<fileQueue>
sample:
SET PRINTER TO \\lenovo-pc\hp915.prn\xyz.txt  /* xyz.txt  any name of file for queue */
SET PRINTER ON
 ? "TEST"
SET PRINTER OFF
SET PRINTER TO   /* member close print file !!! */


Yuo can also use:
nH := FCREATE("\\lenovo-pc\hp915.prn\xyz.txt")
FWRITE(nH,"TEST")
FCLOSE(nH)

Adam

Klas Engwall

unread,
Apr 10, 2016, 3:00:32 PM4/10/16
to harbou...@googlegroups.com
Hi Koshal,

> *C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.dir/kos.o:kos.c:(.data+0xf8):
> und*
> *efined reference to `HB_FUN_WINGETPRINTERS'*
> *C:/Users/Lenovo/AppData/Local/Temp/hbmk_np88se.dir/kos.o:kos.c:(.data+0x158):
> un*
> *defined reference to `HB_FUN_WIN_PRN'*
> collect2: ld returned 1 exit status
> hbmk2: Error: Running linker. 1

Let me first suggest that you switch from the old Harbour 3.0 to the
current Harbour 3.2 since 3.2 is miles ahead of 3.0. Almost everyone
here has made that switch although that is the version that is still
under development and may occasionally be broken for a day or two. But
keep an eye on the discussions in the harbour-devel newsgroup, and you
will be fine.

Secondly, all functions with a "win_" prefix exist in the hbwin contrib,
so you need to add "hbwin.hbc" (without the quotes) to your .hbp file.
If you were using Harbour 3.2 it would have hinted that you need to add
that line.

Regards,
Klas

Klas Engwall

unread,
Apr 10, 2016, 3:10:52 PM4/10/16
to harbou...@googlegroups.com
Hi Koshal,

> it worked but came out with a blank page

Then we are getting into the territory of what that printer understands.
So far we have only discussed how to set up the communication. It is
possible that your printer does not understand raw text but needs the
Windows specific GDI kind of printing.

If that is the case, investigate the win_tPrn() class that I mentioned
as my last alternative. It exists in the hbwin contrib. You would have
to study the source code of the class in contrib\hbwin\win_tprn.prg and
the sample programs in contrib\hbwin\tests\prn*.prg

But first check if the printer specs say anything about any printer
emulations that it supports.

Regards,
Klas

Klas Engwall

unread,
Apr 10, 2016, 3:23:47 PM4/10/16
to harbou...@googlegroups.com
Hi Adam,

> Correct version (work with Clipper and Harbour) is:
>
> SET PRINTER TO \\<printserver>\<printer>\<fileQueue>
> sample:
> SET PRINTER TO \\lenovo-pc\hp915.prn\xyz.txt /* xyz.txt any name of
> file for queue */
> SET PRINTER ON
> ? "TEST"
> SET PRINTER OFF
> SET PRINTER TO /* member close print file !!! */

But it should be mentioned that the third part of the printer name, the
<fileQueue> part, is just a trick to fool Harbour into not adding ".prn"
and that <fileQueue> does not exist in reality in the printer or the
print server. So it is not necessarily the "correct" way to do it, only
one way to do it.

If SET(_SET_DEFEXTENSIONS) is .F., then not tricks are needed at all.

Regards,
Klas

Koshal Agarwal

unread,
Apr 11, 2016, 12:15:03 AM4/11/16
to Harbour Users
thanks klas 
I added hbwin.hbc but still  undefined reference to `HB_FUN_WINGETPRINTERS'*  exists yes it removed error hb_fun_win_prn 
pls link a relible source to download harbour 3.2 version

koshal

Mario H. Sabado

unread,
Apr 11, 2016, 2:44:07 AM4/11/16
to harbou...@googlegroups.com
Hi Koshal,

Please see below WIN_PRINT* related functions.

Regards,
Mario

2009-11-24 10:57 UTC+0100 Viktor Szakats (vszakats.net/harbour)
  * contrib/hbwin/Makefile
  * contrib/hbwin/win_prn2.c
  * contrib/hbwin/win_prn3.c
  + contrib/hbwin/legacycp.c
    + Added new names for Windows printer support functions:
        WIN_PRINTEREXISTS()     (old name: PRINTEREXISTS())
        WIN_PRINTERSTATUS()     (old name: XISPRINTER())
        WIN_PRINTERPORTTONAME() (old name: PRINTERPORTTONAME())
        WIN_PRINTERLIST()       (old name: GETPRINTERS())
        WIN_PRINTERGETDEFAULT() (old name: GETDEFAULTPRINTER())
        WIN_PRINTERSETDEFAULT() (old name: SETDEFAULTPRINTER())
        WIN_PRINTFILERAW()      (old name: PRINTFILERAW())
--

AL67

unread,
Apr 11, 2016, 6:25:37 AM4/11/16
to Harbour Users
But the syntax "\\server\printer\anyfile" always works :)
(old 16bit Clipper in Windows 32 also work)

Adam

Koshal Agarwal

unread,
Apr 11, 2016, 12:11:25 PM4/11/16
to Harbour Users
hi jayadev,
i got success using ur programme after making changes in line which was calling win_getprinter but it truncated all character like chr(14) and chr(15) etc.
any idea why this happend

koshal 


On Saturday, April 9, 2016 at 12:50:08 PM UTC+5:30, Jayadev wrote:

Klas Engwall

unread,
Apr 11, 2016, 5:06:49 PM4/11/16
to harbou...@googlegroups.com
Hi Koshal,

> I added hbwin.hbc but still undefined reference to
> `HB_FUN_WINGETPRINTERS'* exists yes it removed error hb_fun_win_prn

Hmmm, that looks like something is missing in the sources you are using.
What does the code surrounding that function call look like?

What it is supposed to provide is probably the same as the hbwin
function win_PrinterList() returns, namely an array of all installed
printers in Windows. The syntax is:

win_PrinterList( [<lPrinterNamesOnly>], [<lLocalPrintersOnly>] ) ->
<aPrinters>

where the two optional arguments limit the results in two different
ways. Then you can examine the <aPrinters> array:

#include "hbwin.ch"
aPrinters := win_PrinterList()
for i := 1 to len( aPrinters )
? aPrinters[ i, HB_WINPRN_NAME ]
next

> pls link a relible source to download harbour 3.2 version

The harbour-project.org website is currently unavailable, for unknown
reasons. But the binaries can be downloaded here:
https://sourceforge.net/projects/harbour-project/files/binaries-windows/nightly/

Normally, those binaries are updated every day. That page is what the
download link at harbour-project.org is pointing to when it is up and
running.

Sources can be downloaded as a zip file from here:
https://github.com/harbour/core or by cloning the Git repository using
the instructions in the README.md file in the Harbour root directory.

Regards,
Klas

Klas Engwall

unread,
Apr 11, 2016, 5:17:24 PM4/11/16
to harbou...@googlegroups.com
Hi Adam,

> But the syntax "\\server\printer\anyfile" always works :)
> (old 16bit Clipper in Windows 32 also work)

Yes, but it is still a trick to defeat the default extension "feature",
and I think it should be labeled as such.

Regards,
Klas

Jayadev

unread,
Apr 12, 2016, 4:17:28 AM4/12/16
to Harbour Users
Hi Koshal,

Please see the #define on top of the program.  If you have some unique combination, please add there and later in the program add a case statement.  If you find it difficult, send me the text file on my email Id. as also the scanned copy of the output on dotmatrix and I shall check.

Warm regards,

Jayadev

Koshal Agarwal

unread,
Apr 12, 2016, 12:32:12 PM4/12/16
to Harbour Users
thanks jayadev i am using hb3.0 and win_getprinters is not locatable so i commented those lines programme started working but behaving a strange that it is sending output to HP915 only while i have set defaulted to pdfcreator also there is no double width appearing as i have given it in my program but in printing it is giving music sign in place of making text as doublewidth 
I am using deskjet & pdf printer not a dot matrix 

Jayadev Urath

unread,
Apr 13, 2016, 1:38:57 AM4/13/16
to Harbour Users
Dear Koshal,

Please heed to Klas's advice.  Migrate to Ver 3.2 which is quite stable.  Most of your problems will be solved.


As I suggested earlier, send the text file to my email ID and I shall have a look.

Warm regards,

Jayadev

Klas Engwall

unread,
Apr 13, 2016, 7:42:43 PM4/13/16
to harbou...@googlegroups.com
Hi Koshal,

> thanks jayadev i am using hb3.0 and win_getprinters is not locatable so
> i commented those lines programme started working but behaving a strange
> that it is sending output to HP915 only while i have set defaulted to
> pdfcreator also there is no double width appearing as i have given it in
> my program but in printing it is giving music sign in place of making
> text as doublewidth
> I am using deskjet & pdf printer not a dot matrix

But you are using dot matrix printer commands, aren't you? The Chr(14)
and Chr(15) commands you mentioned in your other post mean Double Width
and Condensted, respectively, in the ancient Epson emulation that most
dot matrix printers used. I doubt that any modern printer will
understand those commands.

It is often very difficult to find out what commands the modern crop of
printers understand, especielly the HP printer specs seldom mention that
info and only talk about what drivers to use. I am not sure if the HP915
understands raw text at all. The only info I found was that it does not
understand PCL, and that is a bad sign. Besides the "music sign", did
you get any readable text on the paper?

It is possible that the only way to talk to that printer is to use the
win_tPrn() class together with a driver that is already installed in the
computer where the application runs. Or, if you actually did get some
text, check with your printer vendor what commands the printer
understands in order to format that text.

And upgrade to Harbour 3.2 ...

Regards,
Klas

Klas Engwall

unread,
Apr 13, 2016, 7:43:11 PM4/13/16
to harbou...@googlegroups.com
Hi Jayadev,

> Please heed to Klas's advice. Migrate to Ver 3.2 which is quite
> stable.

I think we can actually agree on "very stable" :-)

Regards,
Klas

Koshal Agarwal

unread,
Apr 13, 2016, 11:09:06 PM4/13/16
to Harbour Users
Thanks jayadev and klas I am downloading 3.2 and compling in it i downloaded hmg 3.4.1 but it did not helped me as comiling with /C shows characters on screen inplace of lines and compiled without /C does not run well . today i shall download 3.2 and comile my code with it , here i am atteching my text file to analyse pls jayadev chk it 

regards 
koshal 
KK

Klas Engwall

unread,
Apr 14, 2016, 5:04:32 AM4/14/16
to harbou...@googlegroups.com
Hi Koshal,

> Thanks jayadev and klas I am downloading 3.2 and compling in it i
> downloaded hmg 3.4.1 but it did not helped me as comiling with /C shows
> characters on screen inplace of lines and compiled without /C does not
> run well . today i shall download 3.2 and comile my code with it , here
> i am atteching my text file to analyse pls jayadev chk it

I don't know much about HMG, but line drawing characters displaying as
non-line characters indicate a codepage mismatch. If you SAY chr(196) or
chr(179) etc, you need to use a DOS codepage for them to display like
you want. But in a Windows environment it is probably generally better
to use a Windows codepage, with the side effect that those line drawing
characters do not exist in the codepage you choose.

In Harbour in general you can however mix Windows text with line drawing
using characters from the DOS codepage if you use

@ <nTop>, <nLeft>, <nBottom>, <nRight> ;
BOX <cBoxString> [COLOR <cColorString>]

or the hb_dispBox()function. Those switch the codepage temporarily to a
DOS codepage and then back to the original codepage. Not sure about HMG,
though.

Regards,
Klas

Jayadev Urath

unread,
Apr 14, 2016, 6:06:17 AM4/14/16
to Harbour Users
Hi Koshal,

I have checked your file.  Pls download the updated program txt2gdih.prg from the link below:

https://www.dropbox.com/s/x6fg8x2ngmc6cuv/txt2gdih.prg?dl=0

I have corrected line 106 as aPrn :=  Win_PrinterList()  // shows the printer list in Harbour

Suitable modifications to the program for your desired output.  Compare the earlier program with the modified one, and you will understand that you can easily add the #define structure and CASE statements for the various EPSON codes that are peculiar to your output.

Output is attached for your perusal.

HTH,

Warm regards,

Jayadev

KK.pdf

Koshal Agarwal

unread,
Apr 14, 2016, 11:09:16 AM4/14/16
to Harbour Users
thanks jayadev , 
ur new prg did chr(14) ok but did u noticed it is truncating effact of chr(15) i shall sure compare both programs 
thanks a lot 

Koshal Agarwal

unread,
Apr 18, 2016, 12:16:18 AM4/18/16
to Harbour Users
hi jayadev 
I studied ur text2gdih.prg it is great help to harbour new migrants .  thanks can u provide me a program which is producing direct printing in harbour style it will be a great help 

thanks 
koshal

Jayadev U

unread,
Apr 18, 2016, 12:08:39 PM4/18/16
to harbou...@googlegroups.com

Hi Koshal,

 

You may go through the examples in E:\hb32\contrib\hbwin\tests\  (Substitute E: with the drive letter wherein you have installed Harbour), see samples prn1.prg,prn2.prg,prn3.prg and prn4.prg.

 

HTH,

 

Warm regards,

 

Jayadev

 

 

From: harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On Behalf Of Koshal Agarwal


Sent: Monday, April 18, 2016 9:46 AM
To: Harbour Users

--

Koshal Agarwal

unread,
Apr 19, 2016, 1:13:11 AM4/19/16
to Harbour Users
thanks a lot jayadev i shall go thru these samples 


koshal_ag

Koshal Agarwal

unread,
Apr 20, 2016, 5:41:19 AM4/20/16
to Harbour Users
Hi jayadev , 
Thanks a Lot for ur sugeestion i gone thru samples and able to create my own print document , could u pls guide me where i can get list of all functions like oPrinter:function() or details about so that i shall able to bring most out of it 

koshal_ag

Koshal Agarwal

unread,
Apr 21, 2016, 11:10:46 PM4/21/16
to Harbour Users
hello,
in my printing box is having gap pls suggest how to overcome this problem 
attaching a sample , also pls guide me how can i change thickness and color of box lines drwan using oprinter:box(1,1,100,100)

koshal_ag
sample.pdf

Koshal Agarwal

unread,
Apr 23, 2016, 1:37:56 AM4/23/16
to Harbour Users
OK I have done it using lines and setpen() function 
thanks to u all specially klas and jayadev thanks a lot for ur guidence 

koshal

Klas Engwall

unread,
Apr 23, 2016, 8:47:11 AM4/23/16
to harbou...@googlegroups.com
Hi Koshal,

> OK I have done it using lines and setpen() function
> thanks to u all specially klas and jayadev thanks a lot for ur guidence

It is great to hear that you made progress!

Let me just, at this moment of success, remind you what I said about
Harbour 3.2 generally being very stable but that occasionally a bug can
appear for a day or two.

I suspect that you had a bit of bad luck with your timing as there were
two little issues that appeared, and were fixed, around the time when I
believe you downloaded it. There have now been no more reports about
those issues for the last few days, so it might be a good time to
replace the version you downloaded with the latest one from today.

Regards,
Klas

Koshal Agarwal

unread,
Apr 24, 2016, 6:30:45 AM4/24/16
to Harbour Users
thanks klas i have only comiling my clipper code in harbour not using extra functionality of harbour (may have) just added printing support from harbour i came to know some colour related issue like set color to x is not working colors are lighter than in clipper etc  if u could guide me a book or online for complete functions and commands of harbour with syntexes it will be a great help

koshal

Klas Engwall

unread,
Apr 25, 2016, 3:45:35 PM4/25/16
to harbou...@googlegroups.com
Hi Koshal,

> thanks klas i have only comiling my clipper code in harbour not using
> extra functionality of harbour (may have) just added printing support
> from harbour i came to know some colour related issue like set color to
> x is not working

I use SetColor() instead of SET COLOR TO (but that should not matter
since the preprocessor converts the command to SetColor() anyway) and it
is working as advertised for me. Are you following the correct Clipper
syntax?

> colors are lighter than in clipper etc

Yes, they are a little lighter, or more precisely brighter. That is not
because of differences between Clipper and Harbour but because of
differences between DOS or the NTVDM that Clipper runs in and the Win32
environment Harbour is running in.

I believe that colors can be modified or replaced with different sets of
colors, but I have never felt any need to try that.

> if u could
> guide me a book or online for complete functions and commands of harbour
> with syntexes it will be a great help

Documentation is Harbour's weak point. There was a good attempt around
the turn of the century, but those docs have never been updated and are
quite obsolete today. They can however be found online at
http://www.elektrosoft.it/tutorials.asp together with some tutorials
written by Giovanni Di Maria. Others may suggest additional resources.

xHarbour, which is a Harbour fork, has a commercial reference guide for
sale at www.xharbour.com. I have never seen it, but some people here say
that it is pretty good. But it must be said that the syntax is not
always identical between Harbour and xHarbour, and there are many
extensions in Harbour that do not exist at all in xHarbour.

Many differences between Harbour, xHarbour and Clipper are described in
xhb-diff.txt in Harbour's doc directory. The changelog of course has all
the info about the new and the changed, but it is over 260,000 lines
long :-). There are also many examples in the tests directory in
Harbour's source code tree.

Finally, this newsgroup as well as the harbour-devel newsgroup can be
searched for various topics if you can come up with any useful search
terms for the things you are interested in. But that can of course be
difficult if you do not know what you want to know :-), so following the
discussions in both newsgroups are a good way to get hints about the
things that Harbour can do but did not exist in Clipper. Or ask here for
suggestions.

Regards,
Klas

Koshal Agarwal

unread,
Apr 28, 2016, 4:19:23 AM4/28/16
to Harbour Users
thanks a lot 

cvan...@gmail.com

unread,
Apr 28, 2016, 10:34:21 AM4/28/16
to Harbour Users


On Friday, 8 April 2016 17:48:19 UTC+2, Koshal Agarwal wrote:
hi group I have just come to know to this great tool harbour migrated successfully from clipper to it and able to run my aplication on All windows all bits  
How to send Printing to USB printer direct from programme in hb,Pls help
koshal

Download DOSPRINT.EXE Its not greeware....

Koshal Agarwal

unread,
May 3, 2016, 7:10:10 AM5/3/16
to Harbour Users
I am able to print my documents directly to usb printers using harbour 3.2 but facing one problem on my printed page every next page is starting with one line down it means if a report of 10 pages 10page will start from 10th line what may be the reason pls help also sum .... to .... for ...... is giving error e0032 like if i remove <for> from it works but in clipper it was working fine is there any alternate of it 

Klas Engwall

unread,
May 4, 2016, 4:39:16 PM5/4/16
to harbou...@googlegroups.com
Hi Koshal,

> I am able to print my documents directly to usb printers using harbour
> 3.2 but facing one problem on my printed page every next page is
> starting with one line down it means if a report of 10 pages 10page will
> start from 10th line what may be the reason pls help

Do you use the code that Jayadev posted? I was hoping he would jump in
here and comment on your problem. I don't really know anything about
that code except I spent a few minutes looking at it right now. Could it
be that the handling of the EJECT commands interacts badly with the
EndPage() and StartPage() methods in the win_Prn() class?

Does the one-line-per-page slip happen even if the entire page is not
filled with text?

It looks like there are always two extra empty lines printed at the top
of each new page, so maybe the page gets too tall if the document you
are printing already fills the entire distance between the printer
hardware's top and bottom margins. Maybe you could experiment with
commenting out the two "oPrinter:NewLine()" lines.

> also sum .... to
> .... for ...... is giving error e0032 like if i remove <for> from it
> works but in clipper it was working fine is there any alternate of it

Can you show us the code that triggers this error?

Regards,
Klas

Koshal Agarwal

unread,
May 5, 2016, 3:56:02 AM5/5/16
to Harbour Users
thanks a lot for helping me 
here is code part which is giving error 
■sele temp
sum amt+exp to tot
SUM QTY TO TWGHT
sum pcs to tpcs
sum pcs to bpcs for bardana="Y"
sum  (amt*2/100) to mmtax  for mandi="Y"    //it is giving error in this line 
sum (amt*.5/100) to mvikas  for mandi="Y"   //it is giving error in this line 

I was thinking that endpage() = eject and i am not using eject because i am printing on HP laserjet printer 
can u also guide me how to set CPI and LPI in HP mode i tried with setfont() but could not get desired results ( i think i need to give more time to jayadev's code)

Jayadev Urath

unread,
May 5, 2016, 4:53:35 AM5/5/16
to Harbour Users
Hi Koshal,

The txt2gdih program that I have sent you just reads your text file line by line and converts it to its gdi equivalent.
The problem therefore is in the code that is generating the text file.

I would strongly suggest opening your text file in any editor and actually check it first for line skips.

Regarding your problem, I would suggest please post the code and the generated text file here so that we can check.

Warm regards,

Jayadev


--

Klas Engwall

unread,
May 5, 2016, 6:45:59 AM5/5/16
to harbou...@googlegroups.com
Hi Koshal,

> sum pcs to bpcs for bardana="Y"
> sum (amt*2/100) to mmtax for mandi="Y" //it is giving error in this line
> sum (amt*.5/100) to mvikas for mandi="Y" //it is giving error in this line

But the first FOR is not giving you an error?

Check the data type of the MANDI field. It is probably not a character
field.

> I was thinking that endpage() = eject and i am not using eject because i
> am printing on HP laserjet printer

Then Jayadev's code will not find any chr(12) characters in the file, so
it will never execute the EndPage(). Instead of 10 normal pages you will
get one single page that is the equal of 10 pages tall. And the page
breaks will then happen where the printer decides to put them, not where
you want them to be.

Put the ejects back in your program, but also take care that you do not
fill the pages with more lines than the printer can handle, or you will
get an extra (possibly entirely empty) printed page when the printer
gets too much data for one page.

> can u also guide me how to set CPI and LPI in HP mode i tried with
> setfont() but could not get desired results ( i think i need to give
> more time to jayadev's code)

Since Jayadev's code uses the win_Prn() class, it never sends the raw
escape codes to the printer. It is really of no interest at all what
kind of escape codes this particular printer understands as long as
there is a driver for that printer installed in the computer that runs
the application.

There are some printer code translations at the beginning of
txt2gdih.prg, but no LPI codes and only one CPI code. And as far as I
can see, those translations follow the Epson syntax.

You would have to add the other codes you want, also following the Epson
syntax for consistency, and also add code similar to the existing
handling of CPI12 further down in txt2gdih.prg in the PrintLine() and
ChangeFont() functions. That requires that you read the entire
txt2gdih.prg code carefully so you understand how it works.

Regards,
Klas

Koshal Agarwal

unread,
May 5, 2016, 7:40:08 AM5/5/16
to Harbour Users
thanks i compiled with 3.2 version and error did not appeared


Koshal Agarwal

unread,
May 11, 2016, 6:28:24 AM5/11/16
to Harbour Users
Hi all once again with a query hope will be resolved like all previous 

is there any preview command or method etc for viewing output before printing like oPrinter:Askproperties:=.t.

Koshal Agarwal

unread,
May 13, 2016, 10:35:52 AM5/13/16
to Harbour Users
hello klas and jayadev

pls answer my query you may have solution to it 


Klas Engwall

unread,
May 13, 2016, 3:22:34 PM5/13/16
to harbou...@googlegroups.com
Hi Koshal,

> hello klas and jayadev
>
> pls answer my query you may have solution to it
>
> koshal.ag
>
> On Wednesday, May 11, 2016 at 3:58:24 PM UTC+5:30, Koshal Agarwal wrote:
>
> Hi all once again with a query hope will be resolved like all previous
>
> is there any preview command or method etc for viewing output before
> printing like oPrinter:Askproperties:=.t.

I was hoping someone would have a nice idea to share, because checking
the hbwin contrib I could not find any ready-to-use solutions. And
googling for "win32 print preview" and "msdn print preview" I can see
that it is not a trivial problem to solve.

Maybe printing to PDF using either the hbhpdf contrib or installing a
PDF printer (like for example Foxit Reader PDF Printer - others may
suggest other similar tools) and print to it using the win_Prn() class
could be the way to go. Then you would always get a PDF as output from
your reports and use any PDF viewer for on screen preview and on paper
printing in a second step.

Sorry, but that is the best I can do for you.

Regards,
Klas

Anderson Cardoso Silva

unread,
Jun 4, 2018, 3:24:56 PM6/4/18
to Harbour Users

Tarun Vaghasia

unread,
Apr 15, 2019, 10:08:30 PM4/15/19
to Harbour Users
Could you please post the code which is working?
Reply all
Reply to author
Forward
0 new messages