How to print label on network shared printer in ASP.Net
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
RE: How to print label on network shared printer in ASP.Net
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
"peng" wrote:
> 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
RE: How to print label on network shared printer in ASP.Net
Paul provided me with the sample code and I applied it to my application. It
worked beautifully!! Thanks a lot, Paul!
Peng
"Paul Aspinall" wrote:
> 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
>
>
> "peng" wrote:
>
> > 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
RE: How to print label on network shared printer in ASP.Net
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 Aspinall" wrote:
> 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
>
>
> "peng" wrote:
>
> > 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
Re: How to print label on network shared printer in ASP.Net
Hi Paul and Peng,
This Guru,I am development a project using VB.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.
May any one give 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... my mail id is
guru.net [at] rediffmail.com
Yours sincerely,
guru
KAYIHAN ONUK Wrote:
> 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 Aspinall" wrote:
--
gurumoorthy
------------------------------------------------------------ ------------
gurumoorthy's Profile: http://www.hightechtalks.com/m327
View this thread: http://www.hightechtalks.com/t348274
Re: How to print label on network shared printer in ASP.Net
Paul, could you send me one copy of that sample code? I just began to
learn C#, but my boss want me to write zpl program......I searched for
long time, and still no idea with this issue......So , could you give
me a hand?
--
Kain
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
Re: How to print label on network shared printer in ASP.Net
Hi Paul. Would you please send me a sample of your code? I would
really appreciate it.
--
ctwilliams
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
Re: How to print label on network shared printer in ASP.Net
Paul,
help me please,send me your code,i'm stuck on how to print label to
zebra printer form asp.net!
thank you
ctwilliams wrote:
> *Hi Paul. Would you please send me a sample of your code? I would
> really appreciate it. *
--
caro
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
Re: How to print label on network shared printer in ASP.Net
Hi Paul,
Could you please provide me the code? I am facing this kind of problem
in my ASP.net application.
Regards,
Christie
--
lhueekar
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
Re: How to print label on network shared printer in ASP.Net
Hi Paul,
Would you please send me a sample of your code? I would really
appreciate it.
Thanks,
Robert Z.
MCSD
--
rzey
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
Re: How to print label on network shared printer in ASP.Net
Hi Paul,
Could you also send me a sample of your code please? I would really
appreciate it.
--
khtee
------------------------------------------------------------ ------------
Posted via http://www.codecomments.com
------------------------------------------------------------ ------------
RE: How to print label on network shared printer in ASP.Net
Paul,
Please send me the sample code as well.
Thanks.
Greg
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hello Peng,
Do you still have the sample code? Can you please send me the sample
code.
Thanks,
Hoang-
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hello Paul,
Can you please send me the sample code.
Thanks.
Hoang-
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
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
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Paul. Would you please send me a sample of your code? I would really
appreciate it.
Egarcia
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
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
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
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
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
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
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Could you please send me your code, I would really appreciate.
Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Re: How to print label on network shared printer in ASP.Net
Hi Paul,
Would aapreciate it if you can send the the sample code too. I am stuck
here for weeks, urgently need it by this week.
Thanks.
Jeremy
*** Sent via Developersdex http://www.developersdex.com ***
Re: How to print label on network shared printer in ASP.Net
Hi Paul,
I am new to ASP.NET and ZPL stuff... Could you be kind enough to show me
some sample codes on how to communicate between ASP.NET with the Zebra
Printer? I am communicating to a 140Xilll printer.
Thank you. I greatly appreciate your help.
Newbie
*** Sent via Developersdex http://www.developersdex.com ***
Re: How to print label on network shared printer in ASP.Net
Fairly easy.
First you need to add Zebra printer under account ASP.NET is using to be
able to print.
check out this article
http://support.microsoft.com/kb/184291/en-us
And this
http://support.microsoft.com/kb/324565/en-us
then in case of Zebra Printer you have 2 choices. You can print label as an
image (which is pretty slow) Or you can print label using ZPL II language
( this is the preferred method).
To print a label with ZPL II language you need to send RAW data to printer.
check out this article
http://support.microsoft.com/kb/322091
I recently had to do same thing (not from ASP.NET though).
PS: If you are printing labels for FedEx look out for ^MD30 command in their
ZPL II string for label. For whatever reason they put that in and that
command bumps up the darkness to the top what in case burns out the head on
thermal printer like yours. And those heads are expensive - about $300
I end up with the code like this
int iIndex = _sLabel.IndexOf("^MD");
if (iIndex != -1)
_sLabel = _sLabel.Substring(0, iIndex) + "^MD00" + _sLabel.Substring(iIndex
+ 5);
RawPrinterHelper.SendStringToPrinter("ZebISQ", _sLabel);
George.
<newbee> wrote in message news:eO03mYSQHHA.996 [at] TK2MSFTNGP02.phx.gbl...
> Hi Paul,
>
> I am new to ASP.NET and ZPL stuff... Could you be kind enough to show me
> some sample codes on how to communicate between ASP.NET with the Zebra
> Printer? I am communicating to a 140Xilll printer.
>
> Thank you. I greatly appreciate your help.
>
> Newbie
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
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.
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Please send me the code you have for this sample. Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Dear Paul
Could you please send me your code, I would really appreciate.
pareshmmodi [at] hotmail.com
Thanks
From http://www.developmentnow.com/g/8_2007_1_0_0_712654/How-to-p rint-label-on-network-shared-printer-in-ASP-Net.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
RE: How to print label on network shared printer in ASP.Net
Hey,
I am trying to print to my Zebra printer. Can you please forward me the
code.
Thank you,
-Tom
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
can you please send me this if you have the code, thanks:
Rick
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Paul,
can u pls send barcode printg from asp.net saple.
Thanks
siva
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Peng,
can u send sample code to me.
Thanks and Regards,
Siva
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Please send the sample code
Regards
Adhi.D
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Paul,
I see that his is an old thread. If possible could you forward your
print code?
Regards,
Tom
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Could you please send me the code? I am having problems setting the
permissions so that I can print to my Zebra Printer from a asp website.
josh [at] encoelectronics.com
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Paul:
Could you please send me the code? We are working though some of the
same issues. ejredfern [at] ch.blommer.com
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Paul,
Can you please send me the code?
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Paul,
Could you please send the sample code to perform printing?
Regards,
Narahari
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hi Paul,
Can you please send me the sample code.
Thanks,
Raj Gopal.
*** Sent via Developersdex http://www.developersdex.com ***
RE: How to print label on network shared printer in ASP.Net
Hello Paul,
Can you please send me the sample code.
Thanks.
HB
From http://www.developmentnow.com/g/8_2007_1_0_0_712654/How-to-p rint-label-on-network-shared-printer-in-ASP-Net.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
RE: How to print label on network shared printer in ASP.Net
I've written an Inventory application and users would like labels
printed after they have added the items to the database. This is done
by filling out a form and then pressing submit. Upon submission I would
like to have a label printed.
I'm using a Zebra printer, connected to the users local machine, while
the application resides on a server and I use the barcodenet dll to
create the barcode to place on labels.
I have successfully been able to print labels as long as I'm in the
application on the server and the printer is located there, but this is
not the scenario that I need to implement. The printers will be located
far away from the server so I need to be able to send the print to the
local label printer.
Does anyone have any ideas how I can access the local printers from
within ASP.NET?
*** Sent via Developersdex http://www.developersdex.com ***
Re: How to print label on network shared printer in ASP.Net
"Joanna Bar" <joannab [at] hotmail.com> wrote in message
news:%23l2OsHs%23HHA.1164 [at] TK2MSFTNGP02.phx.gbl...
> I've written an Inventory application and users would like labels
> printed after they have added the items to the database. This is done
> by filling out a form and then pressing submit. Upon submission I would
> like to have a label printed.
>
> I'm using a Zebra printer, connected to the users local machine, while
> the application resides on a server and I use the barcodenet dll to
> create the barcode to place on labels.
>
> I have successfully been able to print labels as long as I'm in the
> application on the server and the printer is located there, but this is
> not the scenario that I need to implement. The printers will be located
> far away from the server so I need to be able to send the print to the
> local label printer.
>
> Does anyone have any ideas how I can access the local printers from
> within ASP.NET?
You can't natively... Modern browsers are designed specifically to prevent
any sort of direct interaction with the hardware or software in the machine
on which they are running, for fairly obvious security reasons...
Does each user absolutely have to have their own Zebra printer?
If not, I would advise you to set up a dedicated print machine with the
printer attached, and write a Windows service which polls your database
server for labels to print...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net