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

  • Thread starter Thread starter Guest
  • Start date Start date
Hi Paul

Would you please send me a sample of your code?
You are helping me out.

Thank you
 
Hi Paul,

It looks like you are getting blasted. Any chance you are still sending
the sample? I would appreciate it!
 
Paul;

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

David
 
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,
 
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_WRITE = 2;
public string LPTPORT;
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr CreateFile(
string lpFileName,
EFileAccess dwDesiredAccess,
EFileShare dwShareMode,
IntPtr lpSecurityAttributes,
ECreationDisposition dwCreationDisposition,
EFileAttributes dwFlagsAndAttributes,
IntPtr hTemplateFile);
[System.Runtime.InteropServices.DllImport("kernel32",
EntryPoint="CloseHan
dle")]
public static extern int CloseHandle(int hObject);
int retval;
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
private int nLength;
private int lpSecurityDescriptor;
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 ECreationDisposition : uint
{
New = 1,
CreateAlways = 2,
OpenExisting = 3,
OpenAlways = 4,
TruncateExisting = 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,
NotContentIndexed = 0x00002000,
Encrypted = 0x00004000,
Write_Through = 0x80000000,
Overlapped = 0x40000000,
NoBuffering = 0x20000000,
RandomAccess = 0x10000000,
SequentialScan = 0x08000000,
DeleteOnClose = 0x04000000,
BackupSemantics = 0x02000000,
PosixSemantics = 0x01000000,
OpenReparsePoint = 0x00200000,
OpenNoRecall = 0x00100000,
FirstPipeInstance = 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(LPTPORT, EFileAccess.GenericWrite,
EFileShare.Write,
IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.Normal,
IntP
tr.Zero);
hPort = (int)hPortP;
outFile = new FileStream(hPortP, FileAccess.Write, false);
StreamWriter fileWriter = new StreamWriter(outFile);
StreamReader fileReader = new
StreamReader("H:\\VSNet\\CourierLib\\Parcel
ForceLabelDef.txt");
fileWriter.Write("^XA^FO50,50^A030,30^FD " + sText + "^FS");
fileWriter.Write(Formatting.Chr(34));
fileWriter.Write("^FO50,100^A030,30^FD " + sText + "^FS^XZ");
fileWriter.Write(Formatting.Chr(13));
fileWriter.Write(Formatting.Chr(10));
fileWriter.Flush();
fileWriter.Close();
outFile.Close();
retval = CloseHandle(hPort);

}
}
}
 
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
 
Paul,

I am working on an application in c# trying to do the same thing you
have done. Can you send me your sample code.

Thanks,
Zewdi
 
Hello Paul,

Is the code still avaliable? I would really appreciate if you send me a
copy.

Thanks.
 
Hi Paul,
CAn you please send me your ASP.net code to print to a network shared
printer?

Thanks in advance.
Matique.
 
Hi Paul,

Could you also send me a sample of your code please? I am facing the
same problem. Actually, I am getting the response from UPS in the binary
format but i do not know , How to print it on zebra thermal printer. i
am using LP2844 thermal printer.

Thanks in Advance,
Ishwar
 
Hi Paul,

Could you please provide me with the sample code. Also if the zebra
printers are wireless is there a way to identify the nearest active
zebra printer when printing? Thanks in Advance!



Salma
 
Paul, can you please provide me with the sample code. You can email the
code to (e-mail address removed) .

Thank you
 
Can you please send me the sample to check how to print labels from
ASP.Net.

Thanks in advance.
 
Paul -

I am having similar issue. I would really thankfull if you could send me
the sample code.

Prashant
(e-mail address removed)
 
Hi Paul,

am also facing the same prob, could you please send me the code?

Regards,
Suresh Kumar R.
 
Paul are you implying using the win32 api calls within asp.net shall
allow someone to call a networked printer on another machine?

If so would you be so kind to send me the code so I can take a look at
this please.?

Regards
D
 
Back
Top