Delphi/Lazarus: Show and Change Printers
Info by Delphian | 2016-06-13 at 15:01
In this tutorial, I would like to show you how you were able to create a list of all available printers and how to change the printer for printing out your documents using Delphi or Lazarus. To make it work, you have to add the unit "printers" to your USES section.
Show available Printers
You can find a list of all printers that are currently available in:
printer.printers
Because printer.printers is just a normal string list (TStringList), you can easily go through the list using a normal loop, for example for adding the printers to a ComboBox for selection.
Read out default Printer
The default printer is always preset in printer.printers. Its index can be read out via printer.printerindex:
printer.printers[printer.printerindex]
You are just accessing the stringlist via the corresponding index.
Change Printer
In order to select another printer for printing, you can use the following commands:
printer.printers.IndexOf('Printer Name') // or printer.setprinter('Printer Name');
Of course, the name "Printer Name" should be one of the names from the list of the available printers, otherwise it is not working.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
Filelist Creator: How to print a List of Files
Info | 0 Comments
Delphi: Show Path in Windows Explorer
Question | 1 Answer
Brother printer says: Toner is empty! How can I still continue printing?
Question | 14 Answers
Lazarus: Print with Document Name
Question | 1 Answer
Delphi/Lazarus: Display current Date and Time
Tip | 0 Comments
Delphi/Lazarus: Create multiple Objects using For-Each-Loop
Question | 1 Answer
3D Printer: Costs and Differences
Question | 1 Answer
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.