Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


xHarbour PrintFileRaw() question

xHarbour PrintFileRaw() question

xHarbour PrintFileRaw() question

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:


local ptr,fil,ret
? str(ret)

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.


RE: xHarbour PrintFileRaw() question


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.

TYPE &prt_file TO PRINT

Jim C.

RE: xHarbour PrintFileRaw() question

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.


RE: xHarbour PrintFileRaw() question

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

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

RE: xHarbour PrintFileRaw() question

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.



RE: xHarbour PrintFileRaw() question

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.


RE: xHarbour PrintFileRaw() question

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close