uses ... bpac_TLB,
FPTouchDocument: IDocument;
.
.
FPTouchDocument:= CreateComObject(CLASS_Document)
as IDocument;
.
.
function TdBK_Preferences.GetLabelPrinters: TStrings;
var
I: Integer;
PTouchPrinter: IPrinter;
begin
Result:= FLabelPrinterList;
FIsSDKRegistered:= False;
try
PTouchPrinter:= CreateComObject(CLASS_Printer)
as IPrinter;
// SDK Test
FIsSDKRegistered:= True;
except
// SDK nicht registriert
end;
FLabelPrinterList.Clear;
for I := 0
to Printer.Printers.Count - 1
do
begin
FLabelPrinterList.Add(Printer.Printers[I]);
end;
end;
.
.
procedure TdBK_Print.PrintLabel(Article: TdBK_DataArticle; LabelType: TdBK_LabelType; Count: Cardinal);
var
CurrentLabel:
string;
function FormatText(aText:
string):
string;
begin
Result:= '
';
// Leerzeichen bei leerem Text da sonst Fehler.
if aText <> '
'
then
begin
Result:= aText;
end;
end;
begin
case LabelType
of
ltNormal:
begin
CurrentLabel:= dm.dBK.Preferences.Print.FileNameLabelNormal;
end;
ltOffer:
begin
CurrentLabel:= dm.dBK.Preferences.Print.FileNameLabelOffer;
end;
end;
if FileExists(CurrentLabel)
then
begin
try
FPTouchDocument.SetPrinter(dm.dBK.Preferences.Print.LabelPrinterName, False);
FPTouchDocument.Open(CurrentLabel);
try
FPTouchDocument.StartPrint('
dBK Label', bpoCutAtEnd);
FPTouchDocument.GetObject('
Text1').Text:= FormatText(Article.ArticleName);
FPTouchDocument.GetObject('
Text2').Text:= FormatText(Article.ArticleCaption);
FPTouchDocument.GetObject('
ValueNormal').Text:= FormatText(FloatToStrF(Article.CostGross, ffFixed, 8, 2) + '
' + conCurrencyString);
case LabelType
of
ltNormal:
begin
FPTouchDocument.SetBarcodeData(0, Article.ArticleNumber);
end;
ltOffer:
begin
FPTouchDocument.GetObject('
ValueOffer').Text:= FormatText(FloatToStrF(Article.CostOffer, ffFixed, 8, 2) + '
' + conCurrencyString);
FPTouchDocument.SetBarcodeData(0, '
_' + Article.ArticleNumber);
end;
end;
FPTouchDocument.PrintOut(Count, bpoDefault);
FPTouchDocument.EndPrint;
finally
FPTouchDocument.Close;
end;
except
MessageDlg('
Die Vorlagendatei ' + QuotedStr(CurrentLabel) + '
konnte nicht verarbeitet werden. Bitte prüfen Sie das Layout.', mtError, [mbOK], 0);
end;
end
else begin
MessageDlg('
Die Vorlagendatei ' + QuotedStr(CurrentLabel) + '
konnte nicht gefunden werden. Bitte prüfen Sie die Einstellungen.', mtError, [mbOK], 0);
end;
end;