Delphi/Lazarus: Show and Change Printers
Info by Delphian | Last update on 2023-01-29 | Created on 2016-06-13
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
PrintMyFonts is not printing all fonts - What can I do?
Article | 0 Comments
Filelist Creator: How to print a List of Files
Info | 0 Comments
Keyboard Shortcut for Printing Files
Tutorial | 0 Comments
Lazarus: Print with Document Name
Question | 1 Answer
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
Windows: Why you cannot create any files or folders named CON, AUX, NUL, COM1 or LPT1
Info | 0 Comments
Windows: How to make Hibernation available
Tutorial | 0 Comments
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.