473,799 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Mar 9 '06
56 14066


Can you please send me the code as well?

*** Sent via Developersdex http://www.developersdex.com ***
Feb 8 '08 #41
Would you please send me your code as well?
*** Sent via Developersdex http://www.developersdex.com ***
Feb 8 '08 #42
Hi Paul,

It looks like you are getting blasted. Any chance you are still sending
the sample? I would appreciate it!
*** Sent via Developersdex http://www.developersdex.com ***
Mar 4 '08 #43

Hi Paul,
Can you please send me the sample code?

Thanks,
Anirudha
*** Sent via Developersdex http://www.developersdex.com ***
Apr 3 '08 #44


Paul;

I know everyone seems to be asking the same question. Me too. Can you
send me the code.
Thanks

David

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #45

Can you also forward this code example to me as well, it seems to be
very popular, and would save me countless hours of trial and error.
Thank you,
*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #46
Here is some sample c# code to print directly to a ZPL or EPL printer

using System;
using System.IO;
using System.Runtime. InteropServices ;

namespace CourierLib
{
/// <summary>
/// Summary description for ZPLPrint.
/// </summary>
public class ZPLPrint
{
public readonly int GENERIC_WRITE = 1073741824;
public readonly int OPEN_EXISTING = 3;
public readonly int FILE_SHARE_WRIT E = 2;
public string LPTPORT;
[DllImport("kern el32.dll", SetLastError=tr ue)]
public static extern IntPtr CreateFile(
string lpFileName,
EFileAccess dwDesiredAccess ,
EFileShare dwShareMode,
IntPtr lpSecurityAttri butes,
ECreationDispos ition dwCreationDispo sition,
EFileAttributes dwFlagsAndAttri butes,
IntPtr hTemplateFile);
[System.Runtime. InteropServices .DllImport("ker nel32",
EntryPoint="Clo seHan
dle")]
public static extern int CloseHandle(int hObject);
int retval;
[StructLayout(La youtKind.Sequen tial)]
public struct SECURITY_ATTRIB UTES
{
private int nLength;
private int lpSecurityDescr iptor;
private int bInheritHandle;
}
[Flags]
public enum EFileAccess : uint
{
GenericRead = 0x80000000,
GenericWrite = 0x40000000,
GenericExecute = 0x20000000,
GenericAll = 0x10000000,
}

[Flags]
public enum EFileShare : uint
{
None = 0x00000000,
Read = 0x00000001,
Write = 0x00000002,
Delete = 0x00000004,
}

public enum ECreationDispos ition : uint
{
New = 1,
CreateAlways = 2,
OpenExisting = 3,
OpenAlways = 4,
TruncateExistin g = 5,
}

[Flags]
public enum EFileAttributes : uint
{
Readonly = 0x00000001,
Hidden = 0x00000002,
System = 0x00000004,
Directory = 0x00000010,
Archive = 0x00000020,
Device = 0x00000040,
Normal = 0x00000080,
Temporary = 0x00000100,
SparseFile = 0x00000200,
ReparsePoint = 0x00000400,
Compressed = 0x00000800,
Offline= 0x00001000,
NotContentIndex ed = 0x00002000,
Encrypted = 0x00004000,
Write_Through = 0x80000000,
Overlapped = 0x40000000,
NoBuffering = 0x20000000,
RandomAccess = 0x10000000,
SequentialScan = 0x08000000,
DeleteOnClose = 0x04000000,
BackupSemantics = 0x02000000,
PosixSemantics = 0x01000000,
OpenReparsePoin t = 0x00200000,
OpenNoRecall = 0x00100000,
FirstPipeInstan ce = 0x00080000
}

public ZPLPrint()
{
//
// TODO: Add constructor logic here
//
}
public void print(string strPrnPath, string sText)
{
FileStream outFile;
IntPtr hPortP;
int hPort;
LPTPORT = strPrnPath;
hPortP = CreateFile(LPTP ORT, EFileAccess.Gen ericWrite,
EFileShare.Writ e,
IntPtr.Zero, ECreationDispos ition.OpenExist ing, EFileAttributes .Normal,
IntP
tr.Zero);
hPort = (int)hPortP;
outFile = new FileStream(hPor tP, FileAccess.Writ e, false);
StreamWriter fileWriter = new StreamWriter(ou tFile);
StreamReader fileReader = new
StreamReader("H :\\VSNet\\Couri erLib\\Parcel
ForceLabelDef.t xt");
fileWriter.Writ e("^XA^FO50,50^ A030,30^FD " + sText + "^FS");
fileWriter.Writ e(Formatting.Ch r(34));
fileWriter.Writ e("^FO50,100^A0 30,30^FD " + sText + "^FS^XZ");
fileWriter.Writ e(Formatting.Ch r(13));
fileWriter.Writ e(Formatting.Ch r(10));
fileWriter.Flus h();
fileWriter.Clos e();
outFile.Close() ;
retval = CloseHandle(hPo rt);

}
}
}
*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #47
Hi Guyz,

after 2 days of finding a solution with out risking the vunerability of
the server. I found the ultimate solution, for me that is, What i did is
to create an aspx page where when the user will click on the button it
will download the EPL file. From there i created a .bat file that
commands it to print the opened file. I set the .bat file as the default
program to open any .epl file.

It works perfectly, whether your in an intranet or internet. I works
because the printer is now in the client side.

MarkV

*** Sent via Developersdex http://www.developersdex.com ***
Jul 30 '08 #48
"Mark Villahermosa" <ma************ **@gmail.comwro te in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
Hi [Guyz] Guys,

after 2 days of finding a solution with out risking the vunerability of
the server. I found the ultimate solution, for me that is, What i did is
to create an aspx page where when the user will click on the button it
will download the EPL file. From there i created a .bat file that
commands it to print the opened file. I set the .bat file as the default
program to open any .epl file.

It works perfectly, whether [your] you're in an intranet or internet.
[i] It works because the printer is now in the client side.
How did you persuade an ASP.NET app to modify the default program for .epl
files on a machine which is connected over the Internet...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 30 '08 #49
the .bat file is on the client side. so its only on the client side pc
you have to configure the .epl file to be opened by the .bat file. you
dont have to configure anything on the server since its just like
downloading any file on the server. Its the way the file is handled on
the client side the you have to configure.

MarkV

*** Sent via Developersdex http://www.developersdex.com ***
Jul 31 '08 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3289
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...
0
1655
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...
0
3259
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
12
2453
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.
13
3045
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....
24
2844
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
3
9536
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...
0
2980
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)
1
3876
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...
0
9688
marktang
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...
0
9544
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,...
0
10490
Oralloy
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...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.