Method: DrawTo

Draws a barcode symbol on the specified canvas. There are several different overloading methods, Syntax 1, Syntax 2, and Syntax 3 (only for Delphi/C++Builder 2009 or later):

Note:

For Delphi 3, the method overload isn't supported, so the method names of Syntax 1 and Syntax 2 are changed to DrawTo1 and DrawTo2.

Note:

The method uses GetDeviceCaps function to retrieves device-specific information for the specified device. When using Printer.Canvas as the target cvanvas, it will fail if a default printer is not set in Windows. Please ensure that a default printer is specified in Windows:

Set default printer for current application:

uses Winapi.Printers;

 

procedure SetAppPrinter(const PrinterName: string);

var

Idx: Integer;

begin

Idx := Printer.Printers.IndexOf(PrinterName);

if Idx <> -1 then

Printer.PrinterIndex := Idx

else

ShowMessage('Printer not found!');

end;

Set the global default printer.

uses Winapi.WinSpool;

 

procedure SetWindowsDefaultPrinter(const PrinterName: string);

begin

if SetDefaultPrinter(PChar(PrinterName)) then

SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)

else

RaiseLastOSError;

end;

Contents