Forum > Packages and Libraries

Setting CUPS Printer Options

(1/1)

tonyw:
This is obviously a platform dependent issue, but one that has been giving me trouble on Linux.

The problem occurs when printing to a Dymo LabelWriter. The PPD is set correctly for the printer and the label size selected correctly in the CUPS Administrator. However, unless the "media" option is also set correctly, the output is always mis-aligned and extra labels printed. This is probably a CUPS problem and is not Lazarus specific as CUPS seems to always require the media option to be set when printing to anything other than A4.

The Lazarus problem is that I can't find a way to set a CUPS option programmatically in the OSPRINTERS unit. That is not without modifying the source code to make the cupsAddOption method of TCUPSPrinter public (it is currently protected). Then it's easy to set the media option using this method and the label prints correctly.

Is there something I am missing, or is this just a bug in TCUPSPrinter giving this meethod the wrong visbiility?

taazz:
I would open a request in the bug tracker to change the visibility of that method and in the mean time I would use one of the following to get access to the method with out changing the original code.

1) subclass the class and add your own public method that calls the protected method of TCUPSPrinter eg

--- Code: ---TmyPrinter = class(TCUPSPrinter)
public
  Procedure MyCupsMethod(....);
end;

Implementation
procedure TmyPrinter.MyCUPSMethod(....)
begin
  self.ProtectedCupsMethod(......);
end;

--- End code ---

2) create a hack class and use that eg.

--- Code: ---type
  THackCUPSPrinter = class(TCUPSPtinter)
  End;

procedure SetTheSize(const aPrinter:TCupsPrinter; aSize:integer);
begin
  THackCUPSPrinter(aPrinter).ProtectedMethod(asize);
end;


--- End code ---

Navigation

[0] Message Index

Go to full version