raw printing throught USB port / WINDOWS

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

raw printing throught USB port / WINDOWS

philippe sylvain levi

I need a solution (unit?) to access printer (matricial like LX80, LX300 and so on) in raw mode throught USB port directly from FPC program build in mode win32 or win64.

apreciate any ideia

thanks

Philippe


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

LacaK
You can use:
    Printer.RawMode := True;
    Printer.BeginDoc;
    ....
    Printer.EndDoc;
-Laco.

I need a solution (unit?) to access printer (matricial like LX80, LX300 and so on) in raw mode throught USB port directly from FPC program build in mode win32 or win64.

apreciate any ideia

thanks

Philippe


_______________________________________________ fpc-pascal maillist - [hidden email] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

philippe sylvain levi

Em 16.12.2014 09:27, LacaK escreveu:

You can use:
    Printer.RawMode := True;
    Printer.BeginDoc;
    ....
    Printer.EndDoc;
-Laco.
Thank you, but that the part I already knew (saw it searching in Google).
The question is how to select the USB port and create Printer ( win32/win64 ).

I need a solution (unit?) to access printer (matricial like LX80, LX300 and so on) in raw mode throught USB port directly from FPC program build in mode win32 or win64.

apreciate any ideia

thanks

Philippe


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

 


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

LacaK
Is the printer already known to Windows (can you print to that printer from others windows applications) ?
If yes, then you can use:
  Printer.SetPrinter('Printer name');
-Laco.

Em 16.12.2014 09:27, LacaK escreveu:

You can use:
    Printer.RawMode := True;
    Printer.BeginDoc;
    ....
    Printer.EndDoc;
-Laco.
Thank you, but that the part I already knew (saw it searching in Google).
The question is how to select the USB port and create Printer ( win32/win64 ).

I need a solution (unit?) to access printer (matricial like LX80, LX300 and so on) in raw mode throught USB port directly from FPC program build in mode win32 or win64.

apreciate any ideia

thanks

Philippe


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
    

 


_______________________________________________ fpc-pascal maillist - [hidden email] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

philippe sylvain levi

good! ... I'll try that ... simple!!!

thank you!

 

Em 16.12.2014 10:35, LacaK escreveu:

Is the printer already known to Windows (can you print to that printer from others windows applications) ?
If yes, then you can use:
  Printer.SetPrinter('Printer name');
-Laco.

Em 16.12.2014 09:27, LacaK escreveu:

You can use:
    Printer.RawMode := True;
    Printer.BeginDoc;
    ....
    Printer.EndDoc;
-Laco.
Thank you, but that the part I already knew (saw it searching in Google).
The question is how to select the USB port and create Printer ( win32/win64 ).

I need a solution (unit?) to access printer (matricial like LX80, LX300 and so on) in raw mode throught USB port directly from FPC program build in mode win32 or win64.

apreciate any ideia

thanks

Philippe


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
    

 


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

 


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

philippe sylvain levi
In reply to this post by LacaK
Em 16.12.2014 10:35, LacaK escreveu:

> Is the printer already known to Windows (can you print to that printer
> from others windows applications) ?
> If yes, then you can use:
> Printer.SetPrinter('Printer name');
> -Laco.
>
>> Em 16.12.2014 09:27, LacaK escreveu:
>>
>>> You can use:
>>> Printer.RawMode := True;
>>> Printer.BeginDoc;
>>> ....
>>> Printer.EndDoc;
>>> -Laco.
>>
>>> Thank you, but that the part I already knew (saw it searching in
>>> Google).
>> The question is how to select the USB port and create Printer (
>> win32/win
>>
>>> 5px; width: 100%;">
>> ; margin-left: 5px; width: 100%;">
>>
>> I need a solution (unit?) to access printer (matricial
>>
>>> win32 or win64.
>>>
>>> apreciate any ideia
>>>
>>> thanks
>>>
>>> Philippe
>>> -------------------------
>>>

I have been busy with other stuff ... back to this topic!

First: could anyone tell me I have the possibility to access USB
printer in raw mode with the "basic" FPC package (not using Lazarus
packages/components)?



> _______________________________________________
> fpc-pascal maillist - [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal [1]



Links:
------
[1] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

Virgo Pärna
On Tue, 13 Jan 2015 10:41:55 -0200, Philippe <[hidden email]> wrote:
>
> First: could anyone tell me I have the possibility to access USB
> printer in raw mode with the "basic" FPC package (not using Lazarus
> packages/components)?
>

    If you have USB printer installed , then winunits-base package has winspool unit.
    Following sample is with string beeing ansisstring and Char AnsiChar.

procedure PrintCodesToPrinter(const APrinterName, APrintData: string);
type
  TDoc_Info_1 = record
    DocName,
    OutputFile,
    Datatype: PChar;
  end;
var
  Written: DWORD;
  DocInfo: TDoc_Info_1;
  PHandle: THandle;
begin
  if APrintData = '' then //nothing to print
    exit;
  DocInfo.DocName := 'POS';
  DocInfo.OutputFile := nil;
  DocInfo.Datatype := 'RAW';
  if not OpenPrinter(PChar(APrinterName), PHandle, nil) then
    raise Exception.CreateFmt('Error opening printer "%s"',
[APrinterName]);
  try
    StartDocPrinter(PHandle, 1, @DocInfo);
    StartPagePrinter(PHandle);
    WritePrinter(PHandle, @APrintData[1], Length(APrintData), Written);
    EndPagePrinter(PHandle);
    EndDocPrinter(PHandle);
  finally
    ClosePrinter(PHandle);
  end;
end;

--
Virgo Pärna
[hidden email]

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: raw printing throught USB port / WINDOWS

Chriss Kalogeropoulos
Hi,

map the USB Port to a Virtual Serial Port and open the Port as File using CreateFile using name "\\.\COMxxx"
Then write to the port with the usual API file commands

Even better wrap  this to a Stream (or FileStream) descendant and use Stream.Write commands
Read and Seek should do nothing

I hope this helps

Chriss


On Tue, Jan 13, 2015 at 3:13 PM, Virgo Pärna <[hidden email]> wrote:
On Tue, 13 Jan 2015 10:41:55 -0200, Philippe <[hidden email]> wrote:
>
> First: could anyone tell me I have the possibility to access USB
> printer in raw mode with the "basic" FPC package (not using Lazarus
> packages/components)?
>

    If you have USB printer installed , then winunits-base package has winspool unit.
    Following sample is with string beeing ansisstring and Char AnsiChar.

procedure PrintCodesToPrinter(const APrinterName, APrintData: string);
type
  TDoc_Info_1 = record
    DocName,
    OutputFile,
    Datatype: PChar;
  end;
var
  Written: DWORD;
  DocInfo: TDoc_Info_1;
  PHandle: THandle;
begin
  if APrintData = '' then //nothing to print
    exit;
  DocInfo.DocName := 'POS';
  DocInfo.OutputFile := nil;
  DocInfo.Datatype := 'RAW';
  if not OpenPrinter(PChar(APrinterName), PHandle, nil) then
    raise Exception.CreateFmt('Error opening printer "%s"',
[APrinterName]);
  try
    StartDocPrinter(PHandle, 1, @DocInfo);
    StartPagePrinter(PHandle);
    WritePrinter(PHandle, @APrintData[1], Length(APrintData), Written);
    EndPagePrinter(PHandle);
    EndDocPrinter(PHandle);
  finally
    ClosePrinter(PHandle);
  end;
end;

--
Virgo Pärna
[hidden email]

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal