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 56 14053
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
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
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=tru e 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
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
------------------------------------------------------------------------
Hi Paul. Would you please send me a sample of your code? I would
really appreciate it.
--
ctwilliams
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
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
------------------------------------------------------------------------
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
------------------------------------------------------------------------
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
------------------------------------------------------------------------ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KohlerTommy |
last post by:
In my application I need to give the user the ability to print duplex if the
selected printer supports duplex printing. Many of the printer options do
not make much sense in my application, and many of the settings in the common
printer dialog would have a negative impact on my printing process. To
handle this strict printing constraint on which my application imposes I do
not want to show the common print dialog. I want to be able to...
|
by: Pete Petersen |
last post by:
We are trying to send the results page to a Zebra LP2844 Printer with 4" x 2"
Thermal Transfer Label loaded on the network. The share is \\server01\ups
and it is installed on the Web Server that the clients are accessing.
I need to built a script to send the results page to this printer.
If i open Notepad and select this printer and set the Page Size to 4 x 2 and
the Margin to .01 all around I can send the job successfully from the...
|
by: Tessa |
last post by:
Is there any security reason why you cannot print to a network printer from
ASP.NET under IIS6 on Windows 2003 server?
I'm using ASP.NET code to print to a server print queue using
PrintDocument.Print()
(.NET framework v 1.1)
I can print to a local printer plugged into LPT1 on the web server, but not
to a network printer.
The same printing code to a network printer works in a .NET web app when
|
by: Peter Lin |
last post by:
Hey,
I am just wondering if anyone has got any idea of setting up a new class
so that you could just print like the old ways with the printer class,
since I am writing a program that really requires simple black and white
text printing, but there is alot to print and it's needed at various
places, which is why I find that the new printing style with the
printdocument a bit too clumsy.
Any help would be appreciated.
|
by: Daniel Crespo |
last post by:
Hi to all,
I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.
For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it....
| |
by: Tony Girgenti |
last post by:
Hello.
Developing a Windows Form program in VS.NET VB, .NET Framework 1.1.4322 on a
windows XP Pro, SP2.
Before printing a document, i want to set the font to a font that is only
available with the printer that i am printing to(Zebra TLP2844).
When i open Word and look at the fonts available for the default printer, it
does not show the fonts i want. If i cahnge the printer to the printer that
|
by: Santosh |
last post by:
Hii..
i am printing crystal reports in asp.net for that purpose i am using
PrintTo Printer method but for that it is needed me to pass printer
name which is installed on my local computer but when i upload it on
server then it gives me an error no default printer . for printing
purpose their is another method in java script window.print() but it
print whole window which includes report toolbar and other buttons but
i want to print only...
|
by: John Smith |
last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of
Crystal Reports. Sometimes the users will preview a report in a
Crystal report viewer, and sometimes they will send the report directly
to the printer bypassing the Crystal report viewer altogether.
When sending the job directly to the printer I use the PrintToPrinter
command
CR.PrintToPrinter(1, False, 0, 0)
|
by: =?Utf-8?B?SmJhcmJlcg==?= |
last post by:
All users in my XP Professional PC were able to print to a network printer
until now. Now, the only account that can print to the network printer is the
admin account. I have an HP PSC 2200 series PC. The PC is shared in a PC
running windows 98. I have printing and file sharing enable in the windows 98
PC. I have also installed Norton 360, but I do not think this is the problem
as I uninstalled Norton 360 and limited user accounts were...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |