printing - print pdf417 barcode in zebra printer using c# and zpl -


i try send command zebra printer. use rawprinterhelper class , sendstringtoprinter function proplem nothing typing. got command zebra manual here code:

public class rawprinterhelper {     [dllimport(         "winspool.drv",         entrypoint = "openprintera",         setlasterror = true,         charset = charset.ansi,         exactspelling = true,         callingconvention = callingconvention.stdcall)]     private static extern bool openprinter(         [marshalas(unmanagedtype.lpstr)] string szprinter,         out intptr hprinter,         int32 pdefault);       [dllimport("winspool.drv", entrypoint = "closeprinter", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool closeprinter(intptr hprinter);      [dllimport("winspool.drv", entrypoint = "startdocprinterw", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool startdocprinter(intptr hprinter, int level, ref docinfow pdi);      [dllimport("winspool.drv", entrypoint = "enddocprinter", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool enddocprinter(intptr hprinter);      [dllimport("winspool.drv", entrypoint = "startpageprinter", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool startpageprinter(intptr hprinter);      [dllimport("winspool.drv", entrypoint = "endpageprinter", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool endpageprinter(intptr hprinter);      [dllimport("winspool.drv", entrypoint = "writeprinter", setlasterror = true, charset = charset.unicode,         exactspelling = true, callingconvention = callingconvention.stdcall)]     public static extern bool writeprinter(intptr hprinter, intptr pbytes, int dwcount, ref int dwwritten);      public static bool sendbytestoprinter(string szprintername, intptr pbytes, int dwcount)     {         var hprinter = (intptr)(0);         int dwerror; // last error - in case there trouble.         var di = new docinfow();         int dwwritten = 0;          // set docinfo structure.         di.pdocname = "my visual basic .net raw document";         di.pdatatype = "raw";         // assume failure unless succeed.         bool bsuccess = false;         if (openprinter(szprintername, out hprinter, 0))         {             if (startdocprinter(hprinter, 1, ref di))             {                 if (startpageprinter(hprinter))                 {                     // write printer-specific bytes printer.                     bsuccess = writeprinter(hprinter, pbytes, dwcount, ref dwwritten);                     endpageprinter(hprinter);                 }                 enddocprinter(hprinter);             }             closeprinter(hprinter);         }          if (bsuccess == false)         {             marshal.getlastwin32error();         }         return bsuccess;     }      public static bool sendfiletoprinter(string szprintername, string szfilename)     {         // open file.         var fs = new filestream(szfilename, filemode.open);         // create binaryreader on file.         var br = new binaryreader(fs);         // dim array of bytes large enough hold file's contents.          byte[] bytes = br.readbytes((int)fs.length);          intptr punmanagedbytes = marshal.alloccotaskmem((int)fs.length);          marshal.copy(bytes, 0, punmanagedbytes, (int)fs.length);          bool bsuccess = sendbytestoprinter(szprintername, punmanagedbytes, (int)fs.length);          marshal.freecotaskmem(punmanagedbytes);         return bsuccess;     }       public static object sendstringtoprinter(string szprintername, string szstring)     {          int dwcount = szstring.length;          intptr pbytes = marshal.stringtocotaskmemansi(szstring);          sendbytestoprinter(szprintername, pbytes, dwcount);         marshal.freecotaskmem(pbytes);         return null;     }      [structlayout(layoutkind.sequential, charset = charset.unicode)]     public struct docinfow     {         [marshalas(unmanagedtype.lpwstr)]         public string pdocname;         [marshalas(unmanagedtype.lpwstr)]         public string poutputfile;         [marshalas(unmanagedtype.lpwstr)]         public string pdatatype;     } } 

and here try put command

        var doc = new printdocument();         doc.printpage += (s, e) => zebraprinter.printcoupon(points, offername, description, barcode, expdate, e);          doc.printersettings.printername = "zebra ttp 2030";         doc.printcontroller = new standardprintcontroller();          if (doc.printersettings.isvalid)         {           doc.print();            string command = "^xa^by2,3^fo10,10^b7n,5,5,,83,n^fdyourtexthere^fs^xz";              rawprinterhelper.sendstringtoprinter(doc.printersettings.printername,command);         } 

}

but not print nothing.

any idea;

i found post trying interface ttp-2030 myself. , starting doubt 2030 supports zpl. maybe stuck kpl language.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -