/[projects]/dao/DelphiScanner/LabelPrint.pas
ViewVC logotype

Diff of /dao/DelphiScanner/LabelPrint.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3037 by torben, Fri Dec 4 14:07:48 2015 UTC revision 3038 by torben, Tue May 31 11:50:42 2016 UTC
# Line 6  uses Line 6  uses
6    ParentForm,    ParentForm,
7    PakkeshopLabels,    PakkeshopLabels,
8    Configuration,    Configuration,
9    StBarc;    StBarc,
10      PrtRaw;
11    
12    
13  type  type
# Line 22  type Line 23  type
23    
24      procedure PrintDaodirekteLabel( RuteNummer, Kommentar, BoghandlerNavn : String) ;      procedure PrintDaodirekteLabel( RuteNummer, Kommentar, BoghandlerNavn : String) ;
25    
26        procedure TestZpl();
27        procedure PrintZPL( ZplData : string);
28    
29      function GetPrinterCount() : Integer;      function GetPrinterCount() : Integer;
30    
31    private    private
# Line 397  begin Line 401  begin
401      Result := p;      Result := p;
402  end;  end;
403    
404    // Online zpl viewer
405    // http://labelary.com/viewer.html
406    procedure TLabelPrint.TestZpl();
407    var
408      zpl: string;
409    begin
410      zpl :=
411    '^XA'#13#10 +
412    '^PON'#13#10 +
413    '^FWN'#13#10 +
414    
415    '^FX Top section with company logo, name and address.'#13#10 +
416    '^CF0,60'#13#10 +
417    '^FO50,50^GB100,100,100^FS'#13#10+
418    '^FO75,75^FR^GB100,100,100^FS'#13#10+
419    '^FO88,88^GB50,50,50^FS'#13#10+
420    '^FO220,50^FDInternational Shipping, Inc.^FS'#13#10+
421    '^CF0,40'#13#10+
422    '^FO220,100^FD1000 Shipping Lane^FS'#13#10+
423    '^FO220,135^FDShelbyville TN 38102^FS'#13#10+
424    '^FO220,170^FDUnited States (USA)^FS'#13#10+
425    '^FO50,250^GB700,1,3^FS'#13#10 +
426    '^XZ'#13#10
427      ;
428    
429      PrintZpl(zpl);
430    end;
431    
432    procedure TLabelPrint.PrintZPL( ZplData : string);
433    var
434      ADevice, ADeviceName, ADevicePort: array[0..255]of Char;
435      PrinterHandle: THandle;
436      DocInfo: TDocInfo1;
437      dwJob: cardinal;
438      dwBytesWritten: cardinal;
439      AUtf8: UTF8string;
440      ADeviceMode: THandle;
441    
442    begin
443    
444    
445      Printer.GetPrinter(ADevice, ADeviceName, ADevicePort, ADeviceMode);
446    
447        if not OpenPrinter(ADevice, PrinterHandle, nil) then
448        begin
449          Exit;
450          parentForm.Msg('error on openprinter');
451        end;
452    
453         //Fill in the structure with info about this "document"
454      DocInfo.pDocName := PChar('Spooler Document Name');
455      DocInfo.pOutputFile := nil;
456      DocInfo.pDatatype := 'RAW';
457    
458       //Inform the spooler the document is beginning
459      dwJob := StartDocPrinter(PrinterHandle, 1, @DocInfo);
460      if dwJob = 0 then
461      begin
462        ClosePrinter(PrinterHandle);
463        PrinterHandle := 0;
464        Exit;
465      end;
466    
467      //Start a page
468      if not StartPagePrinter(PrinterHandle) then
469      begin
470        EndDocPrinter(PrinterHandle);
471        ClosePrinter(PrinterHandle);
472        PrinterHandle := 0;
473        Exit;
474      end;
475    
476      //your zebra code...
477      AUtf8 := UTF8string(ZplData);
478      WritePrinter(PrinterHandle, @AUtf8[1], Length(AUtf8), dwBytesWritten);
479    
480      //End the page
481      if not EndPagePrinter(PrinterHandle) then
482      begin
483        EndDocPrinter(PrinterHandle);
484        ClosePrinter(PrinterHandle);
485        PrinterHandle := 0;
486        Exit;
487      end;
488    
489      //Inform the spooler that the document is ending
490      if not EndDocPrinter(PrinterHandle) then
491      begin
492        ClosePrinter(PrinterHandle);
493        PrinterHandle := 0;
494        Exit;
495      end;
496    
497      //Tidy up the printer handle
498      ClosePrinter(PrinterHandle);
499      PrinterHandle := 0;
500    
501    end;
502    
503    
504  function TLabelPrint.GetPrinterCount() : Integer;  function TLabelPrint.GetPrinterCount() : Integer;
505  begin  begin

Legend:
Removed from v.3037  
changed lines
  Added in v.3038

  ViewVC Help
Powered by ViewVC 1.1.20