User Tools

Site Tools




23.6 Printing

If you want to print something, you need a printer on your PC or access to a printer shared on the network. Alternatively, you can print your data to a file, preferably in PostScript format. PostScript is a page description language for printers from Adobe, among others. The client-server system CUPS (Common Unix Printer System) takes care of printing under Linux by default. If an application wants to print (or have printed), it transfers the data to be printed, for example documents or images, to CUPS. The print system sends the data either via the server using IP protocol to a network printer or to the local printer in the queue (spooler). When it is a print job's turn, CUPS pushes it into a filter that converts the data into PostScript format. A filter contains all the information about a printer that is stored in a file with the extension .ppd (PostScript Printer Description). These filters are often incorrectly referred to as printer drivers. A printer that can handle data in PostScript format prints this data immediately or converts it into the printer-specific page description and then prints.

If you connect a printer directly to a Linux PC and it is recognised, a printer configuration dialogue will open under Ubuntu, for example. Make sure that the settings marked in red are activated, otherwise printing will not be possible:


Figure 23.6.1: Configuration of printer properties (Ubuntu)

Specifying whether the printer should be shared is optional. When a printer is installed, it is configured so that the most important applications can print. However, you also have the option - regardless of your Linux distribution - of calling up the web-based interface of Cups at the web address http://localhost:631 and administering your local printer there.

Frontend CUPS

Figure 23.6.2: The web-based interface of CUPS

Under Ubuntu, you can access a CUPS configuration tool in the session display in the menu list under 'Printers', which you can also call up via the console with the command system-config-printer:


Figure 23.6.3: CUPS configuration tool (Ubuntu)

After right-clicking on the printer icon, a configuration dialogue opens → Figure 23.6.1 You can find suggestions and tips on the topic of 'Printing' on the Internet at the following addresses:

On the last website you will find the graphical frontend GtkLP for CUPS which helps to find the optimal settings for the selected printer.

One of the most interesting tools for printing is the a2ps programme, which not only converts text files into PostScript format. The programme is permanently installed under Ubuntu:

hans@linux:~$ sudo apt-get install a2ps

The syntax is a2ps [options] source file [-o target file]. Without specifying the target option, the converted file is printed immediately. The only drawback: Unicode is currently not supported. Extensive help is available with a2ps -h. In conjunction with the print programme lp, a2ps fulfils all wishes if you want to print a file directly. The authors use the a2ps programme to print Gambas source texts:

hans@linux:~$ a2ps --line-numbers=1 --columns=1 --rows=1 --portrait /home/hans/FMain.class

In conjunction with the Process class and the EXEC and SHELL instructions from Gambas, a2ps can also be used to conveniently print files from a Gambas application. Only if you have special requirements, such as printing the contents of a GridView, should you use the Print, Draw and Printer classes from Gambas.

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k23/k23.6/start.txt · Last modified: 09.03.2024 (external edit)

Page Tools