Old Clipper user looking for printing help

817 views
Skip to first unread message

Ravindra Banthia

unread,
Mar 23, 2016, 4:36:08 PM3/23/16
to Harbour Users

Hi,

I have some old Clipper applications that I need to move to Harbour or HMG.


My current problem areas are as below:


1) Printer settings (Windows)

2) Printing with graphics and variable size font.


I hope someone here can get me started on the right track.


Regards,

Ravi

rathinagiri subbiah

unread,
Mar 24, 2016, 12:20:37 AM3/24/16
to harbou...@googlegroups.com
IMHO it is better to use HMG or HMG Extended.

If you want to make use of printer alone in windows (everything else in non-GUI mode), you can do so by using console and GUI combined mode.

HMG Print System is very easy and intuitive.

Regards,

S. Rathinagiri



--
--
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.



--

Paul Smith

unread,
Mar 24, 2016, 11:27:15 AM3/24/16
to Harbour Users
Hi Ravi

It depends on your printer. 

If it was all working before with clipper and windows then you must have had a printer with inbuilt emulation and the windows printer was set up correctly and it will continue to do so.
In this scenario you must print to a LPT port, usually LPT1. Right click on the windows default printer in control panel/devices and printers. Look at the printer properties (not properties). Under the sharing tab tick share this computer and give it a share name. Under the ports tab tick printer pooling to allow output to multiple ports and then tick LPT1. This means that when your harbour program prints to LPT1 windows will direct output to LPT1. The final bit in this puzzle is to use the net use command to make the windows spooler output get to the printer. Before you start your program at the command prompt type:

net use LPT1: \\<computer name>\<shared printer name>  persistent:yes

The persistent:yes bit means it will be stored in the registry and only has to be done once

Harbour allows new possibilities you can print to a file as a pdf or possibly use your old printer code to print to HP printer codes and then convert the output to a pdf with 

PCL to PDF for Windows,  a program at http://www.columbia.edu/~em36/pcltopdf.html   This can then be printed with any printer or sent by email using win_mapisendmail()


In my own conversion of a clipper program to harbour I have tidied up the printer code for these three possibilities , printing directly to a printer with emulation, printing to a file using HP codes and converting it to a PDF with an external program then printing it, or emailing the pdf.

It sounds daunting but if it worked in clipper it'll work in harbour and on 64 bit machines 

Good Luck
Paul

Ravindra Banthia

unread,
Mar 24, 2016, 12:54:48 PM3/24/16
to Harbour Users

Thanks Rathinagiri,

 

I am planning to migrate to HMG.

 

Regards,

Ravi

Ravindra Banthia

unread,
Mar 24, 2016, 12:56:15 PM3/24/16
to Harbour Users

Hi Paul,

 

Thank you for your advice.

 

I had developed the application to run purely on DOS (some 24 years ago). Those were the days of dot-matrix printers.

 

1) Printer setting (Windows):

 

I am developing an application for distribution.

 

I want the user to be able to set the printing choices (printer and settings) using the usual Windows printer dialog box (from within in my application).

 

I do not want to hardwire the printer setting in the application.

 

Alternately, the user could set the printing choices in the Windows environment.

 

Once the user has set up the print preferences, my application will print to that default printer.

 

2) Printing with graphics and variable size font:

 

I did not use any emulation – just a plain simple print of a text file.

 

Now, I need to have different fonts and font-sizes, plus the company logo (possibly) to be picked up as an image file.

 

I think I need to create an EPS or a PDF file.

 

Right now, all I can think of is using LaTex and PdfLatex.

 

Regards,

Ravi

Klas Engwall

unread,
Mar 24, 2016, 2:52:26 PM3/24/16
to harbou...@googlegroups.com
Hi Paul,

Den 2016-03-24 kl. 16:27, skrev Paul Smith:
> If it was all working before with clipper and windows then you must have
> had a printer with inbuilt emulation and the windows printer was set up
> correctly and it will continue to do so.
> In this scenario you must print to a LPT port, usually LPT1. Right click
> on the windows default printer in control panel/devices and printers.
> Look at the printer properties (not properties). Under the sharing tab
> tick share this computer and give it a share name. Under the ports tab
> tick printer pooling to allow output to multiple ports and then tick
> LPT1. This means that when your harbour program prints to LPT1 windows
> will direct output to LPT1. The final bit in this puzzle is to use the
> net use command to make the windows spooler output get to the printer.
> Before you start your program at the command prompt type:
>
> net use LPT1: \\<computer name>\<shared printer name> persistent:yes

This is not necessary. Harbour can print directly to \\<computer
name>\<shared printer name> without redirection to LPT<n>

Just SET PRINTER TO \\<computer name>\<shared printer name>

Regards,
Klas

Bruno Luciani

unread,
Mar 24, 2016, 5:04:58 PM3/24/16
to harbour-users
How to refer to a NET  ( wifi )  Epson Inkjet Printer

and exist any diference between windows and linux in the command ?

Bruno

--
--
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.



--
Bruno Luciani
Area Ingenieria
Brawnius Tecnologia y Servicios 
BWS Central de Monitoreo
San Francisco Javier 1066
Ramallo - 03407-422178/422185
www.brawnius.com.ar
www.bwsalarmas.com.ar

Klas Engwall

unread,
Mar 24, 2016, 9:01:19 PM3/24/16
to harbou...@googlegroups.com
Hi Bruno,

> How to refer to a NET ( wifi ) Epson Inkjet Printer

That is really what we were talking about, RAW printing to any networked
printer with a NETBIOS name. Whether it is cable connected or connected
over wifi makes no difference in this regard (but wifi may be less
reliable). Talking to the printer directly or to an intermediate print
server also makes no difference, at least theoretically (but see below).

Then it is of course a separate matter if the printer understands the
printer commands sent by the application. Clipper printing is RAW, so
the Clipper application must know the syntax for talking to the printer
in question. Harbour RAW printing has the same requirements.

If the printer allows TCP/IP printing, it is also possible to print via
the hbtcpio contrib using
'tcp:' + <printer IP address> + <cPort> where <cPort> is usually ':9100'

And there is also win_PrintFileRaw() and win_PrintDataRaw() for RAW
printing through the Windows printing system to installed Windows printers

All examples above assume that the printer understands RAW commands.
"Real" Windows printing using the win_Prn() class is of course also an
option.

> and exist any diference between windows and linux in the command ?

NETBIOS printing is not supported except possibly with Samba, but you
will have to talk to real Linux users about the best way to print.
TCP/IP printing should be exactly the same.

And actually, the old kind of NETBIOS printing directly to the printer
without a separate print server is on its way out in Windows too.
Although it is usually possible to find the NETBIOS name with NET VIEW
\\THEPRINTER not all printers work properly. Newer OKI printers, for
example, require TCP/IP based printing and malfunction when NETBIOS
printing is attempted (confirmed by OKI: "by design").

Regards,
Klas

Bruno Luciani

unread,
Mar 24, 2016, 9:13:01 PM3/24/16
to harbour-users
OK !!  thanks !!!



Regards,
Klas

--
--
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.

Jayadev U

unread,
Mar 24, 2016, 10:16:37 PM3/24/16
to harbou...@googlegroups.com

Hi Ravindra,

 

You can try my generic txt2gdi converter available here:

 

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

 

Hope that helps,

 

Warm regards,

 

Jayadev

Ravindra Banthia

unread,
Mar 29, 2016, 8:25:50 AM3/29/16
to Harbour Users

Thank you, Jayadev!

Message has been deleted

Klas Engwall

unread,
Mar 31, 2016, 6:22:37 PM3/31/16
to harbou...@googlegroups.com
Hi Heinz,

> When using back slashes:
> SET PRINTER TO \\<server-name>\<printer-sharename>
> I get DOS Error 67 on Windows 7 Pro

With or without the angle brackets?

> But if I use forward slashes instead:
> SET PRINTER TO //server-name/printer-sharename
> it works correctly, any reason for that?

Microsoft needs to be POSIX compliant. Either way should work. You can
test the same thing on the commandline with something like:

dir > \\server-name\printer-sharename

and

dir > //server-name/printer-sharename

and both should work

https://en.wikipedia.org/wiki/Path_%28computing%29

Regards,
Klas

Przemyslaw Czerpak

unread,
Mar 31, 2016, 6:40:35 PM3/31/16
to harbou...@googlegroups.com
On Fri, 01 Apr 2016, Klas Engwall wrote:

Hi,

> >When using back slashes:
> > SET PRINTER TO \\<server-name>\<printer-sharename>
> >I get DOS Error 67 on Windows 7 Pro
> >But if I use forward slashes instead:
> > SET PRINTER TO //server-name/printer-sharename
> >it works correctly, any reason for that?
> Microsoft needs to be POSIX compliant. Either way should work. You
> can test the same thing on the commandline with something like:
> dir > \\server-name\printer-sharename
> and
> dir > //server-name/printer-sharename
> and both should work

but if it doesn't in your system then use
SET( _SET_DIRSEPARATOR, "/" )
and Harbour will make automatic translation of path separators.
Just like DOS/Win code ported to POSIX systems can execute:
SET( _SET_DIRSEPARATOR, "\" )
for reverted translation, i.e. this code should mask such problems:

#ifdef __PLATFORM__UNIX
SET( _SET_DIRSEPARATOR, "\" )
#else
SET( _SET_DIRSEPARATOR, "/" )
#endif

best regards,
Przemek

bpd...@apollo.co.in

unread,
Apr 1, 2016, 3:20:59 AM4/1/16
to Harbour Users
Demo to use Console to GUI print using HMG

Compile with command : c:\hmg\build Consol2gui.prg
//=========== bpd2000 ===========
//Consol2gui.prg
#include <hmg.ch>

REQUEST HB_GT_WIN_DEFAULT

Function Main
define window dummy at 0,0 width 0 height 0 main nocaption nosysmenu on init startmain() 
end window
activate window dummy
Return

function startmain
setmode(25,80)
cls
?"Now starting Printing Preview Demo."
wait 
HIDECONSOLE()
select printer default preview
start printdoc
start printpage
@ 20,20 print "This is a test print"
end printpage
end printdoc
SHOWCONSOLE()
?"Now ending the program"
wait
endmain()
return nil


function endmain
release window dummy
return nil


/*
* embeded C code
* can be put in separate .c file (without #pragma of course)
*/

#pragma BEGINDUMP

#define COMPILE_HMG_UNICODE
#include "HMG_UNICODE.h"

#include "hbapi.h"
#include "hbapiitm.h"
#include <windows.h>

HB_FUNC(HIDECONSOLE )
{
    HWND hwnd;
    hwnd = FindWindowA("ConsoleWindowClass",NULL);
    ShowWindow((LONG) hwnd, SW_HIDE);                // SW_MINIMIZE
}

HB_FUNC(SHOWCONSOLE )
{
    HWND hwnd;
    hwnd = FindWindowA("ConsoleWindowClass",NULL);
    ShowWindow((LONG) hwnd, SW_RESTORE);           // SW_HIDE
    ShowWindow((LONG) hwnd, SW_SHOW);              // because 1'st time console stays minimized
   SetForegroundWindow ( hwnd );
}

HB_FUNC(SETCONSOLETITLE)
{  char * szTitle=HMG_parc(1);
   SetConsoleTitle(szTitle);
}

#pragma ENDDUMP

//=======================

AL67

unread,
Apr 1, 2016, 5:14:11 AM4/1/16
to Harbour Users


W dniu czwartek, 24 marca 2016 22:04:58 UTC+1 użytkownik bronius napisał:

This is not necessary. Harbour can print directly to \\<computer name>\<shared printer name> without redirection to LPT<n>

Just SET PRINTER TO \\<computer name>\<shared printer name>

Regards,
Klas


Better way is:

SET PRINTER TO \\<computer name>\<shared printer name>\<anyDUMMYfileName>

Adam

Heinz V Bergen

unread,
Apr 1, 2016, 3:18:26 PM4/1/16
to Harbour Users
Hi Klas

-without angle brackets
-actually either forward or back slashes doesn't seem to work
-my previous email only seemed to work because I didn't realize that I already had LPT1 redirected, which in itself is interesting.
-if I remove the LPT1 redirect first via cmd prompt: NET USE LPT1 /DELETE
 then in program: SET PRINTER TO \\PrintServer\PrinterShareName , I get:


      If in program: SET PRINTER TO //PrintServer/PrinterShareName , I get:


Isn't the stuff after the // just ignored as being a comment?

Regarding command line:
    dir > \\server-name\printer-sharename
Yes that works with a file sharename but not with a printer-sharename?
Auto Generated Inline Image 1
Auto Generated Inline Image 2

Klas Engwall

unread,
Apr 1, 2016, 4:42:14 PM4/1/16
to harbou...@googlegroups.com
Hi Heinz,

> -without angle brackets
> -actually either forward or back slashes doesn't seem to work
> -my previous email only seemed to work because I didn't realize that I
> already had LPT1 redirected, which in itself is interesting.
> -if I remove the LPT1 redirect first via cmd prompt: NET USE LPT1 /DELETE
> then in program: SET PRINTER TO \\PrintServer\PrinterShareName , I get:

[DOS Error 67 picture was lost in transit]

> If in program: SET PRINTER TO //PrintServer/PrinterShareName , I get:

[DOS Error 2 picture was lost in transit]

But that error message refers to LPT1, possibly because LPT1 is the
default if no printer is specified, and ...

> Isn't the stuff after the // just ignored as being a comment?

... yes, if you do it literally like that. Do it with
Set(_SET_PRINTFILE) instead.

> Regarding command line:
> dir > \\server-name\printer-sharename
> Yes that works with a file sharename but not with a printer-sharename?

It works with my shared printer with both backslashes and forward
slashes. What does the NET VIEW \\Owpgdhb02 command tell you about
printers the server shares?

Regards,
Klas

Heinz V Bergen

unread,
Apr 1, 2016, 6:48:25 PM4/1/16
to Harbour Users
NET VIEW \\OWPGDHB02  show this:

Share name  Type   Used as  Comment
---------------------------------------------------
hp4250         Print           HP LaserJet 4250 PCL6
HVB_2035    Print           HVB_P2035_USB

Whoops sorry, yes, at cmd prompt: Dir > \\owpgdhb02\hvb_2035  does print the directory listing to the printer.

But prg with either:
   Set(_SET_PRINTFILE, "\\owpgdhb02\hvb_2035") or
   SET PRINTER TO \\owpgdhb02\hvb_2035
still returns DOS error 67

Now whether that's a Windows 7 configuration issue or not, I don't know?
But I've always had to map LPT1 to the shared printer first, see attached prg before I could raw print with Harbour.

Regards,
Heinz
prntest.zip

Paul Smith

unread,
Apr 1, 2016, 10:31:10 PM4/1/16
to Harbour Users
Hi Heinz

As you can see from my previous post I've also been using a long complicated way of printing.
I've just found that in my case where my computer is called acer and the shared printer is called hp That:

set printer to \\acer\hp does not work but
      
set printer to \\acer\hp\ does

This enables me to get rid of the lpt1 mapping and printer pooling

Now if only I could get rid of having to set printer sharing and could just print to the default windows printer

Regards Paul

Heinz V Bergen

unread,
Apr 2, 2016, 1:15:50 AM4/2/16
to Harbour Users
Hello Paul

Wow, thank-you very much, adding the back slash at the end worked!
For so many years I've read people say just Set Printer to \\server\printershare and every two years or so I've tryed it and it never worked. So, when much respected Klas mentioned it again in this thread, I thought I'd push it... Glad I did, thank-you all!

SET PRINTER TO \\server\printershare\

Don't forget the back-slash at the end... :-)

Heinz

vszakats

unread,
Apr 2, 2016, 6:05:20 AM4/2/16
to Harbour Users


On Saturday, April 2, 2016 at 7:15:50 AM UTC+2, Heinz V Bergen wrote:
Hello Paul

Wow, thank-you very much, adding the back slash at the end worked!
For so many years I've read people say just Set Printer to \\server\printershare and every two years or so I've tryed it and it never worked. So, when much respected Klas mentioned it again in this thread, I thought I'd push it... Glad I did, thank-you all!

SET PRINTER TO \\server\printershare\

Don't forget the back-slash at the end... :-)

Or:
   Set( _SET_DEFEXTENSIONS, .F. )

Heinz V Bergen

unread,
Apr 4, 2016, 11:00:54 AM4/4/16
to Harbour Users
Thanks Viktor,
That would explain it, otherwise I assume it will add the .prn default extension and tries to create a print file.
I tested, adding a period at the end also works.
Just out of curiosity, would there ever be a situation where one would or even could create a file in such a \\server\prnfile.prn scenario?
Yes, as \\server\share\prnfile or \dir\prnfile it would make perfect sense.

Regards,
Heinz

vszakats

unread,
Apr 4, 2016, 11:32:37 AM4/4/16
to Harbour Users
Hi Heinz,

On Monday, April 4, 2016 at 5:00:54 PM UTC+2, Heinz V Bergen wrote:
Thanks Viktor,
That would explain it, otherwise I assume it will add the .prn default extension and tries to create a print file.
I tested, adding a period at the end also works.
Just out of curiosity, would there ever be a situation where one would or even could create a file in such a \\server\prnfile.prn scenario?

There would be no such situation that I know of, but 
the same SET is used to set the output to a disk file, 
where .prn extension needs to be added for Cl*pper 
compatibility.

Plus, _SET_DEFEXTENSIONS also disables the 
default extensions all over Harbour, so things like 
extension-less dbf files are possible, while in Cl*pper 
this wasn't possible.

Maybe Harbour could be thought to be clever enough
to recognise "\\" (and other [1] possibly non-file) 
filenames and omit the default extension in such case.
It's probably doable, but it's a slippery slope and not 
very generic either.


-Viktor

Heinz V Bergen

unread,
Apr 4, 2016, 12:49:29 PM4/4/16
to Harbour Users
Hello Viktor,

After reviewing the link, I agree, the slope indeed does get slippery, thanks for the input.

Heinz
Reply all
Reply to author
Forward
0 new messages