Thanks to everyone's help I was able to successfully print my labels using the following changes:
St: AnsiString;
...
StartDocument(DocName);
StartPage;
Try
For I:=0 to DataToPrint.Count-1 do
Begin
St:=FormatPrintLine(I);
Try
WritePrinter(PrinterHandle,PChar(St),Length(St),N);
Except on E:Exception do
begin
GetWin32ApiErrorMessage(FErrorCode,FErrorText);
Raise EPrinter.CreateFmt('Printer Write Error %d'+#13+
'While Printing To '+PrinterName+#13+
ErrorText,[ErrorCode]);
end;
End;
end;
Finally
EndPage;
EndDocument;
I also had to change to writeprinter instead of escape. Escape did not print anything out after i change st to type AnsiString but writeprinter was successful.