/[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 2705 by torben, Fri Sep 4 12:39:33 2015 UTC revision 3047 by torben, Mon Jun 13 08:54:20 2016 UTC
# Line 22  type Line 22  type
22    
23      procedure PrintDaodirekteLabel( RuteNummer, Kommentar, BoghandlerNavn : String) ;      procedure PrintDaodirekteLabel( RuteNummer, Kommentar, BoghandlerNavn : String) ;
24    
25        procedure TestZpl();
26        procedure PrintZPL( ZplData : string);
27    
28      function GetPrinterCount() : Integer;      function GetPrinterCount() : Integer;
29    
30    private    private
# Line 291  begin Line 294  begin
294    
295    
296        Canvas.Font.Size := 9;        Canvas.Font.Size := 9;
297        Canvas.TextOut(110, 240, 'Pakkeshop:');  
298    
299          // Skriv ikke 'Pakkeshop' overskrift hvis det er en shop2direkte
300          if (  (PakkeshopLabel.Shop2Direkte = '') OR (PakkeshopLabel.Shop2Direkte = '0')  ) then
301          begin
302            Canvas.TextOut(110, 240, 'Pakkeshop:');
303          end;
304    
305    
306        Canvas.TextOut(110, 270, PakkeshopLabel.PakkeshopNavn);        Canvas.TextOut(110, 270, PakkeshopLabel.PakkeshopNavn);
307        Canvas.TextOut(110, 300, PakkeshopLabel.PakkeshopAddr);        Canvas.TextOut(110, 300, PakkeshopLabel.PakkeshopAddr);
308        Canvas.TextOut(110, 330, PakkeshopLabel.PakkeshopPostnr);        Canvas.TextOut(110, 330, PakkeshopLabel.PakkeshopPostnr);
# Line 389  begin Line 400  begin
400      Result := p;      Result := p;
401  end;  end;
402    
403    // Online zpl viewer
404    // http://labelary.com/viewer.html
405    procedure TLabelPrint.TestZpl();
406    var
407      zpl: string;
408    begin
409      zpl :=
410    '^XA'#13#10 +
411    '^PON'#13#10 +
412    '^FWN'#13#10 +
413    
414    '^FX Top section with company logo, name and address.'#13#10 +
415    '^CF0,60'#13#10 +
416    '^FO50,50^GB100,100,100^FS'#13#10+
417    '^FO75,75^FR^GB100,100,100^FS'#13#10+
418    '^FO88,88^GB50,50,50^FS'#13#10+
419    '^FO220,50^FDInternational Shipping, Inc.^FS'#13#10+
420    '^CF0,40'#13#10+
421    '^FO220,100^FD1000 Shipping Lane^FS'#13#10+
422    '^FO220,135^FDShelbyville TN 38102^FS'#13#10+
423    '^FO220,170^FDUnited States (USA)^FS'#13#10+
424    '^FO50,250^GB700,1,3^FS'#13#10 +
425    '^XZ'#13#10
426      ;
427    
428      PrintZpl(zpl);
429    end;
430    
431    procedure TLabelPrint.PrintZPL( ZplData : string);
432    var
433      ADevice, ADeviceName, ADevicePort: array[0..255]of Char;
434      PrinterHandle: THandle;
435      DocInfo: TDocInfo1;
436      dwJob: cardinal;
437      dwBytesWritten: cardinal;
438      AUtf8: UTF8string;
439      ADeviceMode: THandle;
440    
441    begin
442    
443    
444      Printer.GetPrinter(ADevice, ADeviceName, ADevicePort, ADeviceMode);
445    
446        if not OpenPrinter(ADevice, PrinterHandle, nil) then
447        begin
448          Exit;
449          parentForm.Msg('error on openprinter');
450        end;
451    
452         //Fill in the structure with info about this "document"
453      DocInfo.pDocName := PChar('Spooler Document Name');
454      DocInfo.pOutputFile := nil;
455      DocInfo.pDatatype := 'RAW';
456    
457       //Inform the spooler the document is beginning
458      dwJob := StartDocPrinter(PrinterHandle, 1, @DocInfo);
459      if dwJob = 0 then
460      begin
461        ClosePrinter(PrinterHandle);
462        PrinterHandle := 0;
463        Exit;
464      end;
465    
466      //Start a page
467      if not StartPagePrinter(PrinterHandle) then
468      begin
469        EndDocPrinter(PrinterHandle);
470        ClosePrinter(PrinterHandle);
471        PrinterHandle := 0;
472        Exit;
473      end;
474    
475      //your zebra code...
476      AUtf8 := UTF8string(ZplData);
477      WritePrinter(PrinterHandle, @AUtf8[1], Length(AUtf8), dwBytesWritten);
478    
479      //End the page
480      if not EndPagePrinter(PrinterHandle) then
481      begin
482        EndDocPrinter(PrinterHandle);
483        ClosePrinter(PrinterHandle);
484        PrinterHandle := 0;
485        Exit;
486      end;
487    
488      //Inform the spooler that the document is ending
489      if not EndDocPrinter(PrinterHandle) then
490      begin
491        ClosePrinter(PrinterHandle);
492        PrinterHandle := 0;
493        Exit;
494      end;
495    
496      //Tidy up the printer handle
497      ClosePrinter(PrinterHandle);
498      PrinterHandle := 0;
499    
500    end;
501    
502    
503  function TLabelPrint.GetPrinterCount() : Integer;  function TLabelPrint.GetPrinterCount() : Integer;
504  begin  begin

Legend:
Removed from v.2705  
changed lines
  Added in v.3047

  ViewVC Help
Powered by ViewVC 1.1.20