Recent

Author Topic: [solved] POS printing  (Read 13179 times)

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
[solved] POS printing
« on: August 16, 2012, 11:40:29 pm »
I'm looking for a new solution for printing on POS printers, to help someone in modernizing their software. It currently works by communicating directly with the printer via the port it's connected to. Ignoring many different problems that arise from that, there is a main one - more and more printers are becoming USB only, and many modern computers lack the "legacy ports". It is somewhat solved using virtual port drivers and mounting local shares (it's Windows software), which brings another set of problems (say "not working").

So, I'd like to prepare the receipts on a graphics canvas (using TPrinter) and print through the printer driver like any other windows app. The only problem I need to solve is how to control the printer - when printing directly, you simply dump the cut or drawer-open escape sequences and the printer executes them. So, my question is, how can I control the printer hardware the similar way if the printout itself is done through a TPrinter object and the printer driver? I'm pretty much clueless on this one...
« Last Edit: August 18, 2012, 12:05:36 am by TurboRascal »
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: POS printing
« Reply #1 on: August 17, 2012, 12:18:26 am »
Quote
more and more printers are becoming USB only, and many modern computers lack the "legacy ports". It is somewhat solved using virtual port drivers and mounting local shares (it's Windows software)

We develop POS systems, and for some customers we still print directly to the printer using ESC commands.  But you don't need any special drivers / virtual ports.  You can send printer commands directly to your printer via Windows normal print driver.   And of course will then work other Network ports / USB etc.

I'm not at work ATM, but I have a SendDirectToPrinter or something like that I developed, I'll see if I can dig it up, in the mean time you could look at the WritePrinter API documentation.

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: POS printing
« Reply #2 on: August 17, 2012, 02:06:00 pm »
We develop POS systems, and for some customers we still print directly to the printer using ESC commands. 

Yes, that's exactly what I need to do...

I'm not at work ATM, but I have a SendDirectToPrinter or something like that I developed, I'll see if I can dig it up, in the mean time you could look at the WritePrinter API documentation.

So you do it using WinAPI? Even though I'd prefer something more cross-platform, anything that works is welcome :) If you can dig up an example, I would be really grateful, thanks!
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: POS printing
« Reply #3 on: August 17, 2012, 03:48:00 pm »
I think your in luck, My DirectPrint was for Delphi.
But looking at Lazarus Source, it's built in.

Try this ->
Code: [Select]
procedure Test;
var
  test:string;
  w:integer;
begin
  printer.Title:='Test Print';
  printer.RawMode:=true;
  printer.BeginDoc;
  try
    test := 'This is a test of direct print'#12;
    printer.Write(test[1],length(test),w);
  finally
    printer.EndDoc;
  end;
end;

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: POS printing
« Reply #4 on: August 17, 2012, 05:53:27 pm »
I think your in luck, My DirectPrint was for Delphi.
But looking at Lazarus Source, it's built in.

Try this ->
...

I assume printer object is of TPrinter type... This is great, I didn't know of the RawMode property and how to use it until now, and that's exactly what I need! Using TPrinter helps me to fix their Delphi code, but also enables me to convert it to Lazarus and make it multiplatform if needed.

Thanks a million!  ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: POS printing
« Reply #5 on: August 17, 2012, 06:02:45 pm »
No problem,..

One thing I did forget to mention, because it's using a TPrinter class you'll need to make sure your dependencies have printer4Lazarus.  If your currently using TPrinter then you already know this, but just in case your not.

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: POS printing
« Reply #6 on: August 17, 2012, 11:39:58 pm »
It never hurts to mention...  ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: [solved] POS printing
« Reply #7 on: September 11, 2012, 10:45:50 am »
I think your in luck, My DirectPrint was for Delphi.
But looking at Lazarus Source, it's built in.

So, in essence, Delphi doesn't have this ability (so you had to develop a solution), while Lazarus has it built-in in its TPrinter class. That's a "Hooray for Lazarus" :) but obviously I cannot fix their Delphi code, but must make an additional module in Lazarus. Ah, well...
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

 

TinyPortal © 2005-2018