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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from Windows (NT) Service

Status
Not open for further replies.

jgrieshop

Programmer
Jul 28, 2005
2
US
Hello,

I am looking for any help or suggestions to this problem I am having. Here's the synopsis of what I am trying to do:

- Using a windows NT service print a file (Labels.txt)
- The labels.txt file is a list of print codes that will generate several labels. The actual number of labels could be different for each file.
- When I print I only want to have one spool file being sent to the printer. This can be achieved by a simple DOS command ("print c:\MidmarkLabelService\Labels.txt /d:\\printers\isszbtst"). However, I cannot get DOS commands to work with an NT service by using Shell() or Process.Start(). All of these commands work fine with a normal VB.Net executable, but for some reason they all act different with a service!
- I tried using the PrintDocument object, but it only ever prints the first page. I thought about finding a way to keep track of the # of lines per page, and then putting a loop in the to continue printing until there is no more data. However, it seems as if that approach will give me several spool files (one per label written)...while I was wanting only one spool file for "x" number of labels

I hope I have given enough details for somebody to help me, but if you need more information please feel free to ask. I will send/post anything you need to possibly help.

Thanks!

Jason
 
can't you make a dll or exe that does this for you and will be called from the service?

the printdocument is a bit of a challenge especially if you want to print a second or more pages. and it has something to do with hasmorepages = true untill it is finished and hasmorepages can be false. And think this explains it a bit better.


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Thanks Christiaan. I double-checked...well more like triple-checked how I was doing my printing. I wasn't evaluating the HasMorePages properly. Once I got this fixed everything started to work. Thanks for the link to the article.

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top