Printing/ru

Этот документ описывает установку и поддержку принтеров, использующих CUPS и Samba. Он охватывает локальную и сетевую установки, также содержит инструкции по использованию общих принтеров из других операционных систем. За информацией о использовании команд и  для печати документов смотрите отличную документацию от CUPS.

Используйте правильные инструменты
Linux имеет отличную поддержку принтеров; правильным инструментом для работы является CUPS (Common Unix Printing System). С самого начала проекта, в 1999, установка и поддержка CUPS существенно улучшилась.

В этом документе мы опишем как использовать CUPS для настройки локального или сетевого принтера. Не будем углубляться в подробности, так как проект имеет отличную документацию, описывающий все тонкости использования.

Введение
Когда пользователь хочет установить принтер в системе, сперва нужно узнать как принтер будет к ней подсоединен. Будет ли подключение осуществляться через локальный порт, например LPT или USB, или он будет подключен по сети? Если принтер сетевой, будет ли он использовать протокол межсетевой печати (Internet Printing Protocol (IPP)) или протокол Microsoft Windows CIFS (Microsoft Windows Sharing)?

Следующие несколько разделов объясняют какая минимальная конфигурация ядра необходима для подключения принтера к Gentoo. Конечно же, это зависит от того, как принтер будет подключен к системе, поэтому для удобства инструкции разделены.

Перейдем к и запустим, чтобы войти в меню конфигурации ядра. Если ранее использовался для конфигурации ядра, нужно все равно выполнить эти шаги, чтобы убедиться, что ничего не пропущено. Не полагайтесь на genkernel, чтобы настроить все в системе автоматически; печать - эта та область, где сложно автоматически определить верные настройки.

В следующих примерах конфигурации будет добавлена необходимая поддержка в ядро, а не в качестве модулей. Такая сборка ядра необязательна; если необходимо, можно с легкостью добавить поддержку модулей, но удостоверьтесь, что впоследствии не забыли загрузить необходимые модули!

Теперь перейдите к соответствующему разделу для конфигурации (или проверки) ядра.

Локально подключенный принтер (LPT)
LPT порт обычно используется для идентификации параллельного порта принтера. Вам потребуется сначала включить поддержку параллельного порта, затем поддержку параллельного порта "PC-style" (если только не используется система SPARC), после чего включить поддержку принтера с параллельным интерфейсом.

Вот и все! Выйдите из конфигурации ядра и пересоберите ядро.

Теперь переходите к CUPS.

Локально подключенный принтер (USB)
To print via USB, USB support must be enabled in the kernel. See USB host controllers in the Gentoo kernel configuration guide.

It is also recommended to compile with USB support enabled as some printer drivers require the usblp kernel module.

Удаленно подключенный принтер (IPP и LDP)
To be able to connect to a remotely attached printer through the Internet Printing Protocol or the Line Printer Daemon protocol the kernel needs to have networking support. Assuming the kernel has that already, continue with CUPS.

Удаленно подключенный принтер (CIFS)
Ядро должно поддерживать CIFS:

After configuration for CIFS is complete, exit the kernel configuration and rebuild the kernel. Do not forget to copy the new kernel image to the location (and don't forget to mount  if needed) and update the boot loader configuration prior to rebooting the system. Note the root commands in the LPT Printer Configuration step above for how to perform these steps.

Теперь переходите к CUPS.

Установка
Установка CUPS на Gentoo проще простого. CUPS имеет несколько дополнительных функций, которые могут быть интересными. Чтобы включить или отключить эти функции, используйте USE-флаги, связанные с ними.

Проверьте текущие настройки USE-флагов. Чтобы отклониться от текущих настроек USE-флагов только для CUPS, добавьте подходящие USE-флаги в файл.

Если результат устраивает, установим CUPS.

Чтобы включить поддержку SAMBA, пакет должен быть установлен с поддержкой CUPS. Отредактируйте файл или каталог, чтобы задействовать USE-флаг :

Затем (пере)установим Samba:

If the printer is attached to the system locally, and the printer needs to be available every boot, the CUPS daemon will need to load automatically on start-up. Make sure the printer is attached and powered on before the CUPS daemon is started.

Конфигурация
Конфигурация сервера CUPS расположенная в является для большинства пользователей достаточной. Однако, некоторым пользователям может понадобиться сделать некоторые изменения в конфигурации CUPS.

В следующем разделе описывается несколько изменений, которые часто бывают необходимы:


 * Allow other systems to use the printer attached to this Linux workstation.
 * Grant access to the CUPS administration from remote systems.
 * Configure CUPS to support Windows PCL drivers. This is advised for Windows systems to be able to use a SAMBA-shared printer since most Windows drivers are PCL drivers.
 * Configure this system to use a printer attached to another system (not Windows share).

Удаленный доступ к принтеру
For other systems to use the printer through IPP, explicit access to the printer must be granted in the file. To share the printer using SAMBA, this change is not needed.

Open up in a favorite text editor and add in an   line for the system(s) that should be able to reach to the printer. In the next example, access is granted to the printer from localhost and from any system whose IP address starts with.

This line broadcasts browsing information to the clients on the network; it will let network users know when the printer is available:

The port CUPS listens to will also need to be specified so that it will respond to printing requests from other machines on the network:

Удаленное администрирование CUPS
If remote administration is needed, then access to the CUPS administration will need to be granted from more systems than the localhost. Edit the file and have explicit access granted to each system that requires access. For instance, to grant access to a system with an IP address of 192.168.0.3:

Do not forget to restart the CUPS daemon after making changes to by issuing the  command.

Enable support for Windows PCL drivers
PCL drivers send raw data to the print server. To enable raw printing on CUPS, edit and uncomment the   line if it is not already uncommented. Then edit and do the same, if it is not already uncommented.

Do not forget to restart the CUPS daemon after making these changes by running.

Установка удаленного принтера
If the printers are attached to a remote CUPS-powered server the system can be easily configured to use the remote printer by modifying the file.

Assuming the printer is attached to a system called, open up  with a favorite text editor and set the   directive:

The remote system will have a default printer setting which will be used. To change the default printer, use the command.

Сначала перечислите доступные принтеры:

Установите HP LaserJet 5P в качестве принтера по умолчанию:

Введение
If the printer to be configured is remotely available through a different print server (running CUPS) then the following instructions are not needed. Instead, read Setting up a Remote Printer.

Detecting the printer
If a USB printer or parallel port printer was powered on when the Linux system booted, it might be possible to retrieve information from the kernel stating successful detection of the printer. This is merely an indication of print detection and not a requirement.

Для USB принтера:

lpinfo
To list all available drivers, execute the following command:

is not chatty and can be a little tricky to use. If any issue arises, see for more information.

Установка принтера
Чтобы установить принтер на систему, запустите браузер и направьте его на http://localhost:631. Будет отображен веб-интерфейс CUPS, из которого можно выполнить все задачи администрирования.

Go to and enter the root login and password information of the box. Then, when the administrative interface has been reached, click on. A new screen will be displayed allowing the following information to be entered:


 * The spooler name, a short but descriptive name used on the system to identify the printer. This name should not contain spaces or any special characters. For instance, for the HP LaserJet 5P could be titled.
 * The location, a description where the printer is physically located (for instance "bedroom", or "in the kitchen right next to the dish washer", etc.). This is to aid in maintaining several printers.
 * The description, a full description of the printer. A common use is the full printer name (like "HP LaserJet 5P").

The next screen requests the device the printer listens to. The choice of several devices will be presented. The next table covers a few possible devices, but the list is not exhaustive.

If installing a remote printer, the URL to the printer will be queried:


 * An LPD printer server requires a  syntax.
 * An HP JetDirect printer requires a  syntax.
 * An IPP printer requires a  or   syntax.

Next, select the printer manufacturer in the adjoining screen along with the model type and number in the subsequent screen. For many printers multiple drivers will be available. Select one now or search on OpenPrinting Printer List for a good driver. Drivers are easily able to be changed later.

Once the driver is selected, CUPS will inform that the printer has been added successfully to the system. Navigate to the printer management page on the administration interface and select to change the printer's settings (resolution, page format, ...).

Testing and reconfiguring the printer
To verify if the printer is working correctly, go to the printer administration page, select the printer and click on.

If the printer does not seem to work correctly, click on to reconfigure the printer. The same screens as during the first installation will appear but the defaults will now be the current configuration.

If the printer does not function, clues may be found by looking at the CUPS error log located at In the next example a permission error is discovered, probably due to a wrong  setting in the  file.

Installing the best driver
Many printer drivers exist; to find out which one has the best performance the job, visit the OpenPrinting Printer List. Select the brand and type/model of the printer to find out what driver the site recommends. For instance, for the HP LaserJet 5P, the site recommends the  driver.

Download the PPD file from the site and place it in then run  as root. This will make the driver available through the CUPS web interface. Now reconfigure the printer as described above.

Введение
Some printers require specific drivers or provide additional features that are not enabled through the regular configuration process (described above). This chapter will discuss a selection of printers and how they are made to work with Gentoo Linux.

Gutenprint driver
The gutenprint drivers are high-quality, open source printer drivers for various Canon, Epson, HP, Lexmark, Sony, Olympus and PCL printers supporting CUPS. They also support ghostscript, The Gimp, and other applications.

Gentoo's Portage tree contains an ebuild for the gutenprint drivers. Run to install them. Note the ebuild requests to quite a few USE flags. At minimum  and   must enabled for gutenprint drivers to work properly.

Когда процесс сборки завершится, драйвера gutenprint будут доступны через веб-интерфейс CUPS.

HPLIP driver
См. Драйвер HPLIP.

PNM2PPA driver
PPA is an HP technology that focuses on sending low-level processing to the system instead of the printer which makes the printer cheaper but more resource consuming.

If the OpenPrinting site informs the pnm2ppa driver is the best option, then the  filter will need to be installed on the system:

Once installed, download the PPD file for the printer OpenPrinting and put it in the folder. Then configure the printer using the steps explained above.

SpliX driver
SpliX is a set of CUPS printer drivers for SPL (Samsung Printer Language) printers. While SpliX drivers are available through OpenPrinting as well, the package allows for quick portage-managed installation of these drivers. To install, run:

and restart.

Brother printer drivers
See Brother networked printer.

Canon CAPT driver
See Canon CAPT Driver.

Configuring a Windows client for IPP
Microsoft Windows supports IPP (Windows 9x and ME users need to install it separately). To install a printer on Windows that is attached to a Linux box, fire up the wizard and select. When asked for the URI, use the  syntax.

Configuring a Windows client for a Samba shared printer
To share the printer on the CIFS network SAMBA must be installed and configured correctly. Doing this is beyond the scope of this article, however a quick configuration of SAMBA for shared printers will be covered.

Open with a favorite text editor and add a   section to it:

Navigate to the top of the file until inside the   section. Locate the  and   settings and set each of them to   (see the example below):

Make sure to enable windows pcl support in CUPS. Then, restart the smb service to have the changes take effect.

Configuring a Linux client for a Windows print server
First make sure the printer is shared on Windows systems and that  has been emerged with the   USE flag enabled (as instructed above).

To find the desired printer's URI, run the following command, substituting  with the computer that is to probe for samba-shared printers:

In the CUPS web interface, configure the printer as previously described. Notice CUPS has added another driver called. Select it and use the  or   syntax for the URI.

Введение
Many tools exist to help configure a printer, use additional printing filters, add features to printing capabilities, etc. This chapter will list a few of them. Be aware the list is not exhaustive and not meant to discuss each tool in great detail.

Gtk-LP - A GTK-powered printer configuration tool
With, the installation, modification and configuration of a printer can be performed from a stand-alone Gtk application. It uses CUPS and provides all standard CUPS capabilities. It is definitely worth checking out if the CUPS Web interface is disliked or if a stand-alone application for day-to-day printing routines is desired.

Install via:

Printer configuration tool for KDE 4
KDE 4 also has a printer config tool called. It works with CUPS and provides a user-friendly interface to configure printers. Install it as follows:

Error: Unable to convert file 0 to printable format
While having printing troubles and shows this message:

Re-emerge with the   USE flag. You can either add  to the system USE flags in  or enable it only for ghostscript-gpl as shown:

Then run. When it has finished compiling, be sure to restart  afterward:

Ссылки

 * Using Network Printers - Documentation at CUPS.org.
 * Command-Line Printing and Options - Documentation at CUPS.org.