Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xHarbour PrintFileRaw() question

Status
Not open for further replies.
Jul 11, 2002
878
CA
I am trying to set up a legacy app currently generating print output to a disk file to send the disk file to the default Windows printer after completion. I have created a little test file called spool.txt which just has a few lines (132 chars) of plain text.

I try to print it using this little program:

Code:
local ptr,fil,ret
ptr:=getdefaultprinter()
fil:='spool.txt'
ret:=printfileraw(ptr,fil)
clear
? str(ret)
return

It runs, and gives a return code of 1, which indicates success. The print job shows up in the spooler, has the correct length, but sits there for 10 seconds and disappears without printing. This on a HP LJ1000.

When I try another printer (HP Officejet) the spooler gives an error saying the job failed to print, and I have to delete it from the queue.

Environment is XP Pro SP2. xHarbour 0.99.60

Any thought gratefully appreciated.

Jock
 
Jock,

In my clipper app I have a procedure that allows the user to print any PRN file from the source directory. After they have selected the file this codes kicks the output to the default printer. "prt_file" is the macro for the actual file name.

SET DEVICE TO PRINT
TYPE &prt_file TO PRINT
SET DEVICE TO SCREEN

Jim C.
 
Hi, Jim

Yes, that is essentially what the legacy app I am trying to update does now. However I am trying to convert the program so it will be able to print to Windows-defined printers because in many cases there are problems setting printer to a USB or network printer.

The xHarbour getdefaultprinter() function returns the ID of the default printer in windows, and the printfileraw function is supposed to dump the contents of a print image file as raw data to a windows printer. It seems to be almost working - the print job gets created in the windows spooler and has the right number of bytes, but does not print.

Right now I am looking at changing to a different linker to see if that helps, because from what I have read the approach in my sample SHOULD work.

Thanks vm yr reply.

Jock
 
Will your test file print through Windows (via notepad)?

Will your test file print through DOS (redirect to prn)?

 
Hi, DTracy

Print via Notepad: Yes, but of course notepad doesn't pass thru the printer control codes (raw). But it does work.

Print via DOS: No, these are USB printers. However the LJ1000 does have a DOS driver which does work but the objective here is to use the Windows printers. Unfortunately very few USB printers have support for DOS box printing.

I have experimented a bit more ... set up a print to disk dummy printer in Windows and tried using that - it works. Tried to print to a dummy fax printer - it works.

So now I am thinking it is something peculiar about the HP printer drivers. Unfortunately I don't have any others available here, so I am going to try testing elsewhere with more generic drivers. I did update the LJ1000 printer driver with the latest available - no change.

It seems the xHarbour functions are working OK - detect the windows printers correctly and do put the jobs into the appropriate print queues, but once there they either give a print error or else the job just disappears with no print output.

Sigh.

Jock
 
I think I can definitely pin this on the printer drivers now.

I deleted all printers and reinstalled them but eliminated the DOS printer driver. Then shared the LJ1000 and net use'd lpt1 to it. Printing a DOS job to LPT1 behaves EXACTLY like my xHarbour program - the file appears in the spooler, says 'printing', then 'deleting' and disappears without ink ever hitting paper.

Copy a print file to \\computername\printername does exactly the same thing.

So, whatever the problem is, it is not xHarbour.

Thanks to everyone who responded with suggestions.

Jock
 
PS: if anyone using xHarbour could try my program on their system and let me know if they get anything printed I would appreciate knowing.

It would also be useful to know that the OS and printer are.

Many thanks
Jock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top