Lazarus

Programming => General => Topic started by: odvesims on May 14, 2019, 09:31:53 pm

Title: Problems with printer4Lazarus in Ubuntu
Post by: odvesims on May 14, 2019, 09:31:53 pm
Hey There!

I'm using the Printer4Lazarus package to manage printing on my app. It works fine on Windows, but it doesn't work in ubuntu. This is what I'm doing:

Code: Pascal  [Select]
  1. myPrinter:= Printer.Create;
  2. myPrinter.title = 'someTitle';
  3. myPrinter.RawMode:= True;
  4. myPrinter.BeginDoc;
  5. myPrinter.write(printing[1], Length(printing), printInt);
  6. myPrinter.EndDoc;

My current printer is a Star TPS700 (USB). It's connected and installed in my computer. However when I try printing it throws a 'Star_TPS700' (my printer name) is not a valid printer.

What could be causing?
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: jamie on May 14, 2019, 11:00:50 pm
The printer name may not show as you specified it...

You need to examine the "Printers" property and set the "PrinterIndex" property..

List the "Printers" property to a Memo box so you can see what you have or what is being detected.
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: odvesims on May 15, 2019, 03:35:41 pm
The printer name may not show as you specified it...

You need to examine the "Printers" property and set the "PrinterIndex" property..

List the "Printers" property to a Memo box so you can see what you have or what is being detected.

Hey jamie. I did as you suggested, and I can confirm the printer name is the same as I stated above. Also, I tried setting the printerIndex, and still got the same error.
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: jshah on May 15, 2019, 04:57:56 pm
You dont have create a Printer class.

Just Assign printer name to it Printer.SetPrinter(printer_name);
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: jesusr on May 15, 2019, 05:11:41 pm
Code: Pascal  [Select]
  1. //myPrinter:= Printer.Create;
  2. //myPrinter.title = 'someTitle';
  3. //myPrinter.RawMode:= True;
  4. //myPrinter.BeginDoc;
  5. //myPrinter.write(printing[1], Length(printing), printInt);
  6. //myPrinter.EndDoc;
  7.  
  8. WriteLn(printer.printers.text);
  9. // or ShowMessage(Printer.Printers.Text);
  10.  

What is the output of that?
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: odvesims on May 15, 2019, 05:50:48 pm
Code: Pascal  [Select]
  1. //myPrinter:= Printer.Create;
  2. //myPrinter.title = 'someTitle';
  3. //myPrinter.RawMode:= True;
  4. //myPrinter.BeginDoc;
  5. //myPrinter.write(printing[1], Length(printing), printInt);
  6. //myPrinter.EndDoc;
  7.  
  8. WriteLn(printer.printers.text);
  9. // or ShowMessage(Printer.Printers.Text);
  10.  

What is the output of that?

It shows the name of both printers I have connected:

STAR_TSP700_
EPSON_TM-P2.01
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: odvesims on May 15, 2019, 05:52:33 pm
You dont have create a Printer class.

Just Assign printer name to it Printer.SetPrinter(printer_name);

Okay, this made some progress. However, the printer is not fully properly working. Sometimes it prints ok, sometimes it shows random characters/changes font format. I changed the cable to make sure it's not something with the cable. Still the same.
Title: Re: Problems with printer4Lazarus in Ubuntu
Post by: jshah on May 15, 2019, 06:15:57 pm
You are using RawMode that means you have to send text/command as per Printer.