Просмотр исходного кода

Use 10cpi font for printing voucher PINs.
Remove emphasise-on command from printer init string.

Andrew Klopper лет назад: 7
Родитель
Сommit
84b2b3761e

+ 9 - 1
BulkPrinting/BulkPrinting/Globals.cs

@@ -23,6 +23,14 @@ namespace BulkPrinting
23 23
         public static LogUploader LogUploader;
24 24
         public static LogDownloader LogDownloader;
25 25
 
26
-        public static string DefaultPrinterInitString = "1B401B451B55301B4D1B43000C";
26
+        // NOTE: The printer must be in Epson emulation mode for these commands to work. If the printer is in the
27
+        // wrong emulation mode (e.g. IBM PPR) then unexpected things will happen, such as the final '0C' of the 12 inch
28
+        // page length command resulting in an unwanted form feed.
29
+        public static string DefaultPrinterInitString =
30
+            "1B40" +        // Initialise printer
31
+            //"1B45" +        // Emphasise on
32
+            "1B5530" +      // Unidirectional off
33
+            "1B4D" +        // 12cpi, 10.5pt
34
+            "1B43000C";     // Page length 12 inches
27 35
     }
28 36
 }

+ 1 - 1
BulkPrinting/BulkPrinting/PrintAlignmentDialog.cs

@@ -78,7 +78,7 @@ namespace BulkPrinting
78 78
                 //AlignmentPage += "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\r\n";
79 79
                 
80 80
                 AlignmentPage += "\r\n\n\n" +
81
-                "[--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]       [--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]\r\n\n" +
81
+                "\x1B\x50[-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]      [-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]\x1B\x4D\r\n\n" +
82 82
                 "[--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]       [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]\r\n" +
83 83
                 "[--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]       [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]\r\n" +
84 84
                 "[--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]       [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]\r\n" +

+ 1 - 1
BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs

@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
33 33
 // by using the '*' as shown below:
34 34
 // [assembly: AssemblyVersion("1.0.*")]
35 35
 [assembly: AssemblyVersion("1.0.*")]
36
-[assembly: AssemblyFileVersion("1.9")]
36
+[assembly: AssemblyFileVersion("1.10")]

+ 15 - 13
BulkPrinting/BulkPrinting/Utility.cs

@@ -37,7 +37,8 @@ namespace BulkPrinting
37 37
 
38 38
         public static string GetPrinterInitString(DBHelper db)
39 39
         {
40
-            var hex = GetSavedParameter(db, "PrinterInitString");
40
+            //var hex = GetSavedParameter(db, "PrinterInitString");
41
+            var hex = Globals.DefaultPrinterInitString;
41 42
             return Encoding.ASCII.GetString(HexStringToBytes(hex));
42 43
         }
43 44
 
@@ -438,10 +439,10 @@ namespace BulkPrinting
438 439
             string VendorId = Globals.SessionData.Credentials.Payload.Vendor.id.ToString();
439 440
 
440 441
             var PrinterInitString = GetPrinterInitString(db);
441
-            int initJobID = Globals.MaxPrinter.Open("Printer_Init");
442
+            int initJobID = Globals.MaxPrinter.Open("Vouchers");
442 443
             if (initJobID == 0) return;
443 444
             Globals.MaxPrinter.Print(PrinterInitString.ToString());
444
-            Globals.MaxPrinter.Close();
445
+            //Globals.MaxPrinter.Close();
445 446
 
446 447
             List<EventLog> LogEvents = new List<EventLog>();
447 448
 
@@ -453,8 +454,8 @@ namespace BulkPrinting
453 454
             {
454 455
                 using (SQLiteDataReader read = Command.ExecuteReader())
455 456
                 {
456
-                    int JobID = Globals.MaxPrinter.Open("Vouchers");
457
-                    if (JobID == 0) return;
457
+                    //int JobID = Globals.MaxPrinter.Open("Vouchers");
458
+                    //if (JobID == 0) return;
458 459
                     while (read.Read())
459 460
                     {
460 461
                         VoucherCount++;
@@ -477,13 +478,13 @@ namespace BulkPrinting
477 478
                         if (VoucherCount >= 5 || TotalCount == (EndSeqNo - StartSeqNo))
478 479
                         {
479 480
                             RowCount++;
480
-                            string PrintRow = "\r\n\n\n  ";
481
+                            string PrintRow = "\r\n\n\n\x1B\x50  ";
481 482
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
482 483
                             {
483 484
                                 IndividualVoucher = VoucherRow[Column];
484
-                                PrintRow += (Column == 2 ? " " : "") + ("  " + IndividualVoucher.DecryptedPIN).PadRight(30, ' ');
485
+                                PrintRow += (Column == 3 ? " " : "") + (IndividualVoucher.DecryptedPIN).PadRight(25, ' ');
485 486
                             }
486
-                            PrintRow = PrintRow.TrimEnd() + "\r\n\n  ";
487
+                            PrintRow = PrintRow.TrimEnd() + "\x1B\x4D\r\n\n  ";
487 488
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
488 489
                             {
489 490
                                 IndividualVoucher = VoucherRow[Column];
@@ -492,25 +493,25 @@ namespace BulkPrinting
492 493
                                 {
493 494
                                     SerialNumberTrimmed = SerialNumberTrimmed.Substring(0, 24);
494 495
                                 }
495
-                                PrintRow += (Column == 2 ? " " : "") + SerialNumberTrimmed.PadRight(30, ' ');
496
+                                PrintRow += (Column == 3 ? " " : "") + SerialNumberTrimmed.PadRight(30, ' ');
496 497
                             }
497 498
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
498 499
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
499 500
                             {
500 501
                                 IndividualVoucher = VoucherRow[Column];
501 502
                                 int CurrentPage = (int)Math.Ceiling(((decimal)IndividualVoucher.SequenceNumber) / 20);
502
-                                PrintRow += (Column == 2 ? " " : "") + String.Format("{0}/{1}/{2}", IndividualVoucher.BatchId, IndividualVoucher.SequenceNumber, PageCount).PadRight(30, ' ');
503
+                                PrintRow += (Column == 3 ? " " : "") + String.Format("{0}/{1}/{2}", IndividualVoucher.BatchId, IndividualVoucher.SequenceNumber, PageCount).PadRight(30, ' ');
503 504
                             }
504 505
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
505 506
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
506 507
                             {
507 508
                                 IndividualVoucher = VoucherRow[Column];
508
-                                PrintRow += (Column == 2 ? " " : "") + IndividualVoucher.Description.PadRight(30, ' ');
509
+                                PrintRow += (Column == 3 ? " " : "") + IndividualVoucher.Description.PadRight(30, ' ');
509 510
                             }
510 511
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
511 512
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
512 513
                             {
513
-                                PrintRow += (Column == 2 ? " " : "") + VendorId.PadRight(30, ' ');
514
+                                PrintRow += (Column == 3 ? " " : "") + VendorId.PadRight(30, ' ');
514 515
                             }
515 516
 
516 517
                             PrintRow = PrintRow.TrimEnd() + "\r\n\n\n\n\n\n\n\n\n\n";
@@ -536,9 +537,10 @@ namespace BulkPrinting
536 537
                         }
537 538
                         TotalCount++;
538 539
                     }
539
-                    Globals.MaxPrinter.Close();
540
+                    //Globals.MaxPrinter.Close();
540 541
                 }
541 542
             }
543
+            Globals.MaxPrinter.Close();
542 544
             LogBulkEvents(db, LogEvents);
543 545
         }
544 546