News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How Do You Send File to Printer

Started by herge, December 12, 2005, 02:02:25 PM

Previous topic - Next topic

herge

Hi All:

I am trying to send a File to the printer.
I would like to write a Assembler Program
to send a file to the printer.
It's off a USB it's  a HP 845c.
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

hutch--

I moved the topic to the Workshop so you would get more answers. With apologies I don't know the answer, I knew how the older stuff was done but I am not up to date with Windows only printers and later USB stuff.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

farrier

herge,

What kind of file?  Plain text, HP-PCL, PostScript, or are you trying to print from a word processing program?  Each will require a different answer?  What are you trying to do?  DOS, Windows, Linux ?

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

herge

Hi farrier :

I will try to print ASCII text files from a Dos box
in Windows XP.
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

P1

This has been discussed before.  Please use the Search feature to find what has been posted before.

As far as text files go,  I believe you can just copy them to LPT1 and your print driver does the rest.

Regards,  P1  :8)

farrier

herge,

Attached is a program I had to code to sovle a problem I had when a 15 year customer upgraded from a DOS computer network to a WinXP Pro network and their FoxPro for DOS program stopped printing reliably.  What the program does is:

Monitor a specified subdirectory for the creation and closure of a file.
Depending on the name of the newly created file, the corresponding printer is opened
The contents of the file is then sent to the printer
The file is deleted

It may be more than you need, but it contains the code needed to simply send the contents to any local or network printer without user interaction.  The version I will provide is specific to a store which uses 4 different printers.  The files created by the FoxPro program are: LABL, REPT, PB, SALES.  And each is sent to a corresponding printer.  The program is started and hiden to run in the background.

Included is also the C file provided with the WinXP Platform SDK API, RawPrint.c

P1,

You can't "copy" to a USB printer, COM and LPT ports--if present--were all set up as if the were files/file handles, available for input/output.  The USB and FireWire ports are not, as far as I could figure out, and their printers have to be handled by the print driver/server.

hth,

farrier

[attachment deleted by admin]
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

P1

Quote from: farrier on December 12, 2005, 11:06:33 PMYou can't "copy" to a USB printer, COM and LPT ports--if present--were all set up as if the were files/file handles, available for input/output.  The USB and FireWire ports are not, as far as I could figure out, and their printers have to be handled by the print driver/server.
With a little help from clever software.

I could not assume his printer did not come was a capture software, but for those that don't:

http://www.andtechnologies.com/dosprint.html

We still maintain some ancient apps, that print to LPT1, but it has a USB printer installed.  Here was a solution for our problem.  You need to be Administrator to install, then after that you can bump the client down to Power User.

Regards,  P1  :8)

farrier

P1,

That looks interesting, it would have done almost everything I needed it to do!  I kinda enjoyed coding my solution, but my customer wanted it "yesterday" and now they don't even have to think about it.  I've also been able to use it in a number of other DOS and Windows setups with other software.

Thanks for the link!

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

P1

Quote from: farrier on December 13, 2005, 01:28:33 AMThanks for the link!
Your welcome  :U

Programmers helping programmers.

farrier, you have helpped me a number of times by your published work and advice.  Thank You !!!   :clap:

Regards,  P1  :8)

MichaelW

With a DOS HLL this could be as simple as:
SHELL "notepad.exe /p filename.txt"
eschew obfuscation

herge

Hi MichealW:

What's DOS HLL?
Looks like we are shelling to DOS?
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

MichaelW

A DOS High Level Language, QBasic for example.

eschew obfuscation

herge

 Hi Me:

I have found some free software from:
(requires Windows 4.0, 2000, or XP - Windows 9x is not supported)
http://www.andtechnologies.com/dosprint.html

They have some thing callled DOSPRINT.
It's  a 65K Zip file.
You can actual use the Dos Print command
  after DosPrint captures LPt1!
  Copy DOSPrint.exe to the SYSTEM32 directory
Type: dosprint install
Type: net start dosprint

some Commands

DOSPrint LptX printerName   Capture LptX to printerName
DOSPRINT lptX /d      Remove Lptx capture
Dosprint status      Display capture status

Yours Truly:
Herge



[attachment deleted by admin]
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

ChrisLeslie

herge,

The simple way is to do as MichaelW suggested, i.e. calling notepad, from within your program, with with file that you wish to print as an argument, then simply using the notepad print menu. The advantage of that method is that you get to select your printer and font. You could also use qeditor if using masm32. If you wish to use assembler you would do thus:

.386
.model flat,stdcall
option casemap:none
      include \masm32\include\windows.inc
      include \masm32\include\masm32.inc
      include \masm32\include\kernel32.inc
      includelib \masm32\lib\masm32.lib
      includelib \masm32\lib\kernel32.lib
           
.data
    theFile db "qeditor.exe textfile.txt",0
.code

printFile proc
    invoke wshell,ADDR theFile 
    invoke ExitProcess,0
printFile endp 
     
end printFile


You will have to have qeditor and the file to print in the same folder as the program, or if not, specify the file paths as normal.

Chris

herge

 Hi Chris:

It works for me!

Thank you.
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy