I've made a program for my brother's restaurant, that sends a .txt
file to the Thermal printer. The problem that I am having (or at least, what I am thinking of) is in the file's length.
This is the code that I used for the printing procedure (It's from
And this is how it is being printed out:
CodePudding user response:
I think you need to review your printer's driver settings before doing anything. In driver settings you can set the maximum paper height. You can also use Notepad to print the file to printer and compare the results with your program results. I have some notes about your code as you are printing to thermal printer:
- It is not a good idea to use paper height in your calculation.
- You don't add new page because this will make the printer to cut the paper.
- If you are using Windows and want to know the printer margins you can use something like the following function GetActualMargins.
//This function works on the current printer
//Dpi : Dot per inch
procedure GetActualMargins(var DpiX, DpiY : Integer; var LeftMargin, TopMargin: Single);
begin
try
DpiX := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
DpiY := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
LeftMargin := Round((25.4 * GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX)) / DpiX );
TopMargin := Round((25.4 * GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY)) / DpiY );
except
//you can raise Exception here
end;
end;
CodePudding user response:
I have been using thermal printers for some years but I prefer to use EPOS Commands.
I would suggest you test this;-
procedure TForm1.btnprint(Sender: TObject);
Var F:TextFile;
begin
try
AssignFile(F,<printer port>);// e.g LPT1,LPT2,COM1,COM2...
Except
Begin
ShowMessage('Error in assigning printer.');
End;
End;
Rewrite(F);
Writeln(F,'Test printer');
Writeln(F, chr(29) chr(86) chr(65));//Cut and feed paper
CloseFile(F);
End;