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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Paul provided me with the sample code and I applied it to my application. It
worked beautifully!! Thanks a lot, Paul!

Peng
 
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
 
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
 
Hi Paul. Would you please send me a sample of your code? I would
really appreciate it.
 
Paul,
help me please,send me your code,i'm stuck on how to print label to
zebra printer form asp.net!
thank you
 
Hi Paul,

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

Thanks,
Robert Z.
MCS


-
rze
 
Hi Paul,

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

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

Thanks,
Hoang-
 
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
 
Hi Paul. Would you please send me a sample of your code? I would really
appreciate it.

Egarcia
 
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
 
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
 
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
 
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.
 
Back
Top