How to print label on network shared printer in ASP.Net

G

Guest

Hi,

I am development a project using C#.Net. Inside application, it needs to
print labels on different Zebra label printers on the network. I used a shell
script, but it only worked on the server machine locally. Anybody knows how
to do it?

Thanks,
Peng
 
G

Guest

Hi
I've just done exactly this.....
I went down a few dead ends before getting there....

I initially formatted my Zebra label in ZPL in a txt file, and used a CMD
line TYPE label.txt > \\computername\printershare

The label printed fine. However, I then started to code this using interop
making calls to the Win32 API to direct print.

The prints did not happen, and I was baffled. I wasn't sure why it wasn't
printing, so I then had my code shell out to a CMD line, and run the same
TYPE redirect to the printer.
This didn't work!! It worked from my own command line, but not when the code
shelled it....

Its a permission problem. The ASPNET account doesn't have permissions to the
printer in a corporate network environment.
To get round this I added the following line to web.config
<Identity Impersonate = true />

This makes the requests on the server run in the security context of the web
requestor (ie. a valid user, and not the ASPNET account)

I expected this to work..... but it did not..... :-((

The problem was that I was still shelling out to execute the TYPE, and when
you do this, the account runs under ASPNET again!!!
I re-instated my direct print code in windows, and it worked straight away!!!

To summise:
- add <identity impersonate = true /> to your web.config file
- make an interop call back to the Win32 API to execute direct printing to a
printer share.

I have some sample code if you would like it.

Good luck.. HTH


Paul
MCSD, MCDBA
 
G

Guest

Paul provided me with the sample code and I applied it to my application. It
worked beautifully!! Thanks a lot, Paul!

Peng
 
G

Guest

Hi Paul,

May I have your code please? I didn't understand what you mean with "make an
interop call back to the Win32 API to execute direct printing to a printer
share"

I'm experiencing the same problem when trying to print to a shared printer
from an ASP.net application. impersonate=true doesn't help alone... Thanks in
advance. I need your solution immediately...

Yours sincerely,

Kayıhan Onuk
 
K

Kain

Paul, could you send me one copy of that sample code? I just began t
learn C#, but my boss want me to write zpl program......I searched fo
long time, and still no idea with this issue......So , could you giv
me a hand


-
Kai
 
C

ctwilliams

Hi Paul. Would you please send me a sample of your code? I would
really appreciate it.
 
C

caro

Paul,
help me please,send me your code,i'm stuck on how to print label to
zebra printer form asp.net!
thank you
 
R

rzey

Hi Paul,

Would you please send me a sample of your code? I would reall
appreciate it.

Thanks,
Robert Z.
MCS


-
rze
 
K

khtee

Hi Paul,

Could you also send me a sample of your code please? I would really
appreciate it.
 
H

Hoang Nguyen

Hello Peng,

Do you still have the sample code? Can you please send me the sample
code.

Thanks,
Hoang-
 
W

wendy zhu

Hi Paul,

I have the same issue. Could you send me a sample of your code please? I
would really appreciate it.

Thanks in advance,
Wendy
 
E

Edison Garcia

Hi Paul. Would you please send me a sample of your code? I would really
appreciate it.

Egarcia
 
Joined
Aug 14, 2006
Messages
1
Reaction score
0
Please Help Me

Hi Paul. Would you please send me a sample of your code? I would
really appreciate it.

Minning
 
N

Nitin

Hi Paul,
I am using .net to fire a print to zebra printer.The label is simple
one, no bar codes involved, so i just created string with new line
characters '\r\n' after every field. the output format is correct on
local network laserjet printer.But when i replace this printer path with
that os zebra printer, unable to get the output, rather a blank print
label.I am using the code recommended by msdn
http://support.microsoft.com/?kbid=322091.Can u please share your code
and advice me on this issue.
Thanks
Nitin
 
N

Nitin

Hi Paul,
I am using .net to fire a print to zebra printer.The label is simple
one, no bar codes involved, so i just created string with new line
characters '\r\n' after every field. the output format is correct on
local network laserjet printer.But when i replace this printer path with
that os zebra printer, unable to get the output, rather a blank print
label.I am using the code recommended by msdn
http://support.microsoft.com/?kbid=322091.can u please send your code
and advice me on this issue.
Thanks
Nitin
 
C

Christophe Crausaz

Hi Paul,

I am also facing the same problem.... May I ask you to also send me you
your code sample.

Thanks a lot in advance

Christophe
 
P

Peter Eggleston

Hi Paul!

My boss just told me to do a project to print label, but I am not
sure I can do it. Would you please send me a sample of your code? I
would really appreciate it.


Peter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top