How correct print on Epson TM 30 (receipt printer)

123 views Asked by At

I'm going crazy with this topic, and I'll try to be clear as possible.

  • IDE Delphi 11.0
  • Working devices: 2 pc and 1 Epson Tm 30
  • Working condition: Epson TM 30 is connected via USB with pc1 (Client4), pc2 (Client3) print on TM 30 on LAN (\client4\epsontm30)

When I print some string, the printer does the job, but not well.

Here all the code I use:

// Get correct printer
Printer.PrinterIndex:=Printer.Printers.IndexOf('EpsonTM30');
S:='PC di stampa : ' + ComputerName; // Print computer name

// Impostazioni X,Y di partenza ...
StartX:=1;
StartY:=5;
PrintX:=StartX - 91; // Need because GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY) = 100
PrintY:=StartY;

Printer.BeginDoc;
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style + [fsBold];
PrintX:=(Printer.PageWidth - Printer.Canvas.TextWidth(S)) Div 2 ;

Printer.Canvas.TextOut(PrintX, PrintY, S);
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style - [fsBold];

PrintY:=PrintY + Printer.Canvas.TextHeight(S) + 3;

S:=LongDayName[DayoftheWeek(DP.Date)];
S:=FirstCharUp(S);
S:=S + #32 + FormatDateTime('dd/mm/yyyy', DP.Date);
Printer.Canvas.TextOut(StartX, PrintY, 'Data : ');
PrintX:=StartX + Printer.Canvas.TextWidth('Data : ') + 3;
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style + [fsBold];
Printer.Canvas.TextOut(PrintX, PrintY, S);
PrintY:=PrintY + Printer.Canvas.TextHeight(S) + 20;
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style - [fsBold];
PrintX:=StartX;
Printer.Canvas.TextOut(PrintX, PrintY, ' ');

S:='Chiusura : ';
Printer.Canvas.TextOut(PrintX, PrintY, S);
PrintX:= PrintX + Printer.Canvas.TextWidth(S) + 3;
S:='0,00'; 
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style + [fsBold];
Printer.Canvas.TextOut(PrintX, PrintY, S);
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style - [fsBold];
PrintY:=PrintY + Printer.Canvas.TextHeight(S) + 3;
PrintX:=StartX;
TX:=StartX + Printer.Canvas.TextWidth('Chiusura : ');

S:='Pos : ';
while PrintX < TX - Printer.Canvas.TextWidth(S) do PrintX := PrintX + 1; // In order to align the string
Printer.Canvas.TextOut(PrintX, PrintY, S);
PrintX := PrintX + Printer.Canvas.TextWidth(S) + 3;
S:='0,00';
while Printer.Canvas.TextWidth(S)<Printer.Canvas.TextWidth(CassaEdt.Text) do S:=#32 + S;
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style + [fsBold];
Printer.Canvas.TextOut(PrintX, PrintY, S);
Printer.Canvas.Font.Style:=Printer.Canvas.Font.Style - [fsBold];
PrintY:=PrintY + Printer.Canvas.TextHeight(S) + 3;
PrintX:=StartX;
Printer.EndDoc;

What is happened is this result on both computers enter image description here

Not only do I have 10 mm fixed left margin, but another 10 mm more on left margin. This mean that the printing starts at 20 mm from left margin.

I read several thread about this problem without any solution.

To tell the true, sometimes (I do not understand why) on client4 the left margin is reduced to 10 mm.... sometime!!

My target is, at least, start printing at GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY) if it is possible starting at left offset of 50 (GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY) Div 2) on both PCs.

Just for notice, printer driver is Epson driver for TM 30 last version. (Even with Epson utility TM not able to solve this problem).

1

There are 1 answers

0
Daniele On

After asked to a hardware technician this problem, i got a solution. The solution is placed into windows printer driver setup and, in some circumstances, also in software side. Here the solution for anyone have, still, this problem. Excuse me if this is in italian language. First of all open the printer setting in windows setting and:

  1. Click to preference
  2. Click on Advanced setting TAB
  3. Click on Advance Setting button in the middle of the tabsheet. Now another program will runs called APDS UTILITY. After runned go to LAYOUT menu on the left side.
  4. Uncheked "Regola e stampa automaticamente" under "Carta non supportata".

Save and print. Now all the margins (left and rigth) are removed. enter image description here

Now Two more question:

  1. This is a "roll paper" with 80mm large (width) well supported by this printer type (so i do not understand why "Carta non supportata" (Not supported paper).

  2. How is possibile via software (best some example in delphi) check/uncheck this "feature" stored in the printer driver. This in order to check the availability of this feature, if yes and it is checke via software set it to off (uncheked), print and, as last operation, set it to on (checked).

Thank's for the attention.