Question
“How can I get the printer’s default settings, such as the paper name?”
Solution
The Printer.DefaultPrinterSetup property provides access to the printer’s default settings. Here is an example that iterates over the installed printers and populates a list box with the printer name and default paper name.
Download: DefaultPrinterSetup.zip
Sample Delphi code:
uses
ppPrintr;
procedure TForm1.Button1Click(Sender: TObject);
var
lPrinter: TppPrinter;
liIndex: Integer;
lsDescription: String;
begin
lPrinter := TppPrinter.Create;
// iterate over installed printers
// skip the first two entries (Default and Screen)
for liIndex := 2 to ppPrinters.PrinterNames.Count-1 do
begin
lPrinter.PrinterName := ppPrinters.PrinterNames[liIndex];
// get the default paper name
lsDescription := lPrinter.PrinterName + ': ' + lPrinter.DefaultPrinterSetup.PaperName;
ListBox1.Items.Add(lsDescription);
end;
lPrinter.Free;
end;