home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2004 March / VPR0403.ISO / talks / 189 / paper.dkb < prev    next >
Encoding:
Extensible Markup Language  |  2003-09-18  |  103.9 KB  |  2,430 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <article id="paper-189-en">
  3. <articleinfo>
  4.  
  5. <author>
  6. <firstname>Till</firstname>
  7. <surname>Kamppeter</surname>
  8. </author>
  9.  
  10. <copyright>
  11. <year>2002</year>
  12. <holder>Till Kamppeter</holder>
  13. </copyright>
  14.  
  15.   <title>linuxprinting.org and Foomatic - The New Generation of Printing with Free Software</title>
  16. </articleinfo>
  17.  
  18. <section>
  19. <title>linuxprinting.org and Foomatic - The New Generation of Printing with Free Software</title>
  20.  
  21. <para><emphasis><emphasis>Till Kamppeter</emphasis></emphasis></para>
  22.  
  23. <section>
  24. <title>Why Foomatic?</title>
  25.  
  26. <para>Formerly, all GNU/Linux distributions and other
  27. Unix-style operating systems used LPD as the printer spooler. This is
  28. technology of the 70th made for the ASCII-text-only line printers of
  29. that time, so any support for printing options, as output quality or
  30. so, were not needed. Due to Unix being used only on mainframes in
  31. computing centers where only experts are operating the computers
  32. newbie-friendliness did not have a high priority, too.</para>
  33.  
  34. <para>Unfortunately LPD was used for a very long time, up
  35. to even nowadays, but printers changed a lot, they could print
  36. graphics, in color, on various paper types and sizes, for internal or
  37. presentation purposes, and so on. And printers got so cheap that many
  38. people have them at home.</para>
  39.  
  40. <para>To make use of modern printers most Unix
  41. applications describe the pages to print in PostScript and send this
  42. data to the printer spooler. As many printers do not understand
  43. PostScript, the spooler has to translate this into the printer's
  44. language. To do so, it calls GhostScript, a software PostScript
  45. interpreter running on the computer. GhostScript contains the printer
  46. drivers, compiled into its executable binary. Every driver knows the
  47. protocols of certain printer models. Due to the drivers being written
  48. by many different programmers, they have all very different options,
  49. to be set on the GhostScript command line or to be inserted into the
  50. PostScript code sent to GhostScript. In addition there are
  51. filter-style drivers: GhostScript generates a standard bitmap format
  52. and the driver as a separate process translates the bitmap format into
  53. the printer's format.</para>
  54.  
  55. <para>This makes manual configuring of printers a very
  56. complicated task. So the distribution manufacturers had to find a
  57. solution to make it possible for the end user to set up as many
  58. different printer models as possible. So systems like the RHS
  59. Printfilters or APS filters were created, but they have still many
  60. disadvantages:</para>
  61.  
  62. <itemizedlist>
  63.   <listitem><para>Every distribution did its own thing.</para></listitem>
  64.   <listitem><para>Only one spooler was supported (Usually LPD).</para></listitem>
  65.   <listitem><para>Not all and the newest drivers were supported.</para></listitem>
  66.   <listitem><para>Options (as resolution, ...) can only be set by the administrator when
  67.     he sets up the queue.</para></listitem>
  68.   <listitem><para>Not all options were available.</para></listitem>
  69.   <listitem><para>Difficult to add new drivers and printers.</para></listitem>
  70. </itemizedlist>
  71.  
  72. <para>In contrary to the older printer support database
  73. and integration systems, Foomatic currently has a database of more
  74. than 1000 printer models, nearly all known free software printer
  75. drivers (around 240) and the complete information how the drivers are
  76. executed and which options are available. Foomatic comes with scripts
  77. to generate Adobe-compliant PPD (<emphasis>Postscript Printer
  78. Description</emphasis>, describes capabilities and user-settable options of
  79. the printer) files or even complete print queues for all known free
  80. spoolers (<ulink url="http://www.cups.org/">CUPS</ulink>, <ulink url="http://sf.net/projects/lpr">LPD</ulink>, <ulink url="http://www.lprng.com/">LPRng</ulink>, <ulink url="http://sf.net/projects/lpr">GNUlpr</ulink>, <ulink url="http://ppr.sf.net/">PPR</ulink>, <ulink url="http://pdq.sf.net/">PDQ</ulink>, <ulink url="http://www.tww.cx/cps.php">CPS</ulink>, and <ulink url="http://www.linuxprinting.org/direct-doc.html">spooler-less
  81. printing</ulink>). Foomatic-based print queues allow the user to adjust
  82. all options of the printer driver on a per-job (and even a per-page)
  83. basis. The development on <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> is done
  84. independent of particular Linux distributions.</para>
  85.  
  86. </section>
  87.  
  88. <section>
  89. <title>How did linuxprinting.org and Foomatic emerge?</title>
  90.  
  91. <para>The <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> website has
  92. evolved from the <ulink url="http://www.linuxprinting.org/howto/">Printing HOWTO</ulink>, which
  93. <ulink url="http://www.picante.com/~gtaylor/">Grant Taylor</ulink> first
  94. wrote in 1992 and has maintained ever since. Starting in 1998, he
  95. began operating a little database of printer support information, and
  96. that little list has now grown into the largest repository of free
  97. software printing-related information around.</para> <!-- start
  98. supplement by Kurt -->
  99.  
  100. <section>
  101. <title>CUPS makes its appearance</title>
  102.  
  103. <para>In June 1999, the new CUPS printing system did
  104. undergo its first public release. Besides the innovative <emphasis>printer
  105. browsing</emphasis> features of its spooler, it contained a
  106. Ghostscript-based PostScript interpreter (the "<emphasis>pstoraster</emphasis>"
  107. filter). PostScript printers were supported by the usage of their
  108. original PPD files (which are part of the Windows/MacOS drivers).</para>
  109.  
  110. </section>
  111.  
  112. <section>
  113. <title>How CUPS uses the original PostScript PPD files</title>
  114.  
  115. <para>The CUPS server associates the appropriate PPD to
  116. each queue. It parses the PPD and extracts the user-available printing
  117. options for the related target printer. Clients get told the PPD
  118. options for the target printer by the server <emphasis>on the
  119. fly</emphasis>. Clients therefore don't need the PPD installed locally:
  120. instead they receive the PPD options as a simple list of choices from
  121. which they can build a commandline. GUI tools can translate the list
  122. of printer options into nice dialogs. The client just selects the
  123. target printer and sends the desired print options as command line
  124. parameters to the CUPS server, along with the data to be printed (in
  125. most cases PostScript). The CUPS server inserts then, based on the
  126. descriptions of the individual options in the PPD, the PostScript
  127. commands needed to execute the option settings into the PostScript
  128. which would go to the printer (or rather, the printer's PostScript
  129. interpreter).  For the first time a UNIX printing system was there,
  130. which supported the same printing options as known in the Windows
  131. world, by simply using the same PPDs that were created by the
  132. manufacturers for each of their PostSript models.</para>
  133.  
  134. </section>
  135.  
  136. <section>
  137. <title>How CUPS extends use of PPDs to the non-PostScript printer world</title>
  138.  
  139. <para>However, CUPS doesn't limit its PPD support to
  140. PostScript printers and their RIPs (<emphasis>Raster Image Processors</emphasis>,
  141. here PostScript interpreters) only. It rather extends it to
  142. non-PostScript models too. Of course, you couldn't get a PPD for
  143. non-PostScript consumer inkjets at the time. And PPDs were never
  144. intended for non-PostScript printers either.</para>
  145.  
  146. <para>But the CUPS developers translated the printing
  147. options (and related low-level printer commands) available for some
  148. popular inkjets, laser printers, and dot matrix printers into a
  149. PPD-conforming syntax and can thusly handle those printers inside the
  150. same framework as the real PostScript models. CUPS adds one simple
  151. line to the PPD ("<emphasis>*cupsFilter...</emphasis>"), which tells the CUPS
  152. server how to handle the data to be printed (for example calling a
  153. software RIP). For the clients, any CUPS printer is a
  154. <emphasis>PostScript</emphasis> printer. To them it is not relevant,
  155. <emphasis>where</emphasis> the RIP is located: the PostScript may be interpreted
  156. by the device itself or by a software RIP on the server. They want
  157. their paper coming out of the printer as required.</para>
  158.  
  159. </section>
  160.  
  161. <section>
  162. <title>Not enough supported printers...</title>
  163.  
  164. <para>CUPS provides a brilliant concept for handling
  165. print options for all printer types through PPDs -- however it doesn't
  166. deliver many PPDs. It ships a few sample PPD files, which are generic
  167. enough to support a few hundred PCL laser (HP LaserJet compatible),
  168. PCL inkjet (HP DeskJet compatible), Epson inkjet, and dot matrix
  169. printers -- but the very <emphasis>generic</emphasis> part of the picture made
  170. them stop short of handling the very specific features of each
  171. model. And it didn't support at all many models which were supported
  172. by GhostScript.</para>
  173.  
  174. <para>Grant initially was no great fan of CUPS. However,
  175. the way CUPS handled the files to be printed with the help of PPDs,
  176. ignited his idea to design a mechanism which would automatically
  177. generate CUPS-compatible PPDs from the contents of his database.</para>
  178.  
  179. </section>
  180.  
  181. <section>
  182. <title>CUPS-O-Matic and Foomatic -- the first incarnations</title>
  183.  
  184. <para>If CUPS could guide the print data through its
  185. "<emphasis>pstoraster</emphasis>" filter (CUPS's own RIP, in that time based on
  186. GNU GhostScript 5.50), couldn't it also be guided through the
  187. system-installed GhostScript? Of course, CUPS' modular design not only
  188. allows for, but even invites developers to contribute additional
  189. filters. Grant didn't want to add an <emphasis>additional</emphasis> filter. He
  190. wanted to get all the printers running with traditional
  191. GhostScript-based spoolers to work with CUPS too. For many drivers his
  192. database contained the complicated GhostScript command line
  193. parameters, which made the GhostScript filters (=<emphasis>devices</emphasis>) and
  194. models work. This info could surely go into a PPD-like file, too,
  195. describing a driver setup for a GhostScript filter/printer model
  196. combo.</para>
  197.  
  198. <para>In early 2000, he threw out the driver half of his
  199. database and designed a new driver information scheme which gives
  200. users of many printing systems vastly enhanced support for the use of
  201. free software drivers. The first version of <emphasis>CUPS-O-Matic</emphasis>
  202. appeared. It was an online-generator for PPD-files to be used with
  203. CUPS. You could use a browser, surf to the CUPS-O-Matic page, select
  204. your model, choose an appropriate driver (or Ghostscript device),
  205. click "OK" and generate on the fly a PPD file. It needed an additional
  206. "<emphasis>cupsomatic</emphasis>" Perl script installed as a CUPS filter, which
  207. did the converting from PostScript to the printer's native data format
  208. with the help of GhostScript. It replaces CUPS's own RIP.</para>
  209.  
  210. </section>
  211.  
  212. <section>
  213. <title><emphasis>PDQ-O-Matic</emphasis> next...</title>
  214.  
  215. <para>Soon after, he also had the first automatic
  216. configuration generator for <emphasis>PDQ</emphasis> in place, which long after
  217. remained his personal favorite printing system recommended to end
  218. users (PDQ however cannot be used as a print server as it has no
  219. daemon listening for incoming jobs). Also an <emphasis>LPD-O-Matic</emphasis> got
  220. added and so the database got the name <ulink url="http://www.linuxprinting.org/foomatic.html"><emphasis>Foomatic</emphasis></ulink>.</para>
  221.  
  222. <!-- end supplement by Kurt -->
  223.  
  224. </section>
  225.  
  226. <section>
  227. <title>Creation of "Linuxprinting.org"</title>
  228.  
  229. <para>In June 2000, Grant moved the whole thing out from
  230. his personal area at <ulink url="http://www.picante.com/">picante.com</ulink>
  231. to the newly acquired domain <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink>, which
  232. better reflects this site's purpose (and which is certainly easier to
  233. remember!).  Later that year, he bought a shiny new server and
  234. collocated the thing to better handle the traffic.</para>
  235.  
  236. </section>
  237.  
  238. <section>
  239. <title>MandrakeSoft goes CUPS!</title>
  240.  
  241. <para>In August 2000, <ulink url="http://www.linuxprinting.org/till/">Till Kamppeter</ulink> was
  242. employed by <ulink url="http://www.mandrakesoft.com/">MandrakeSoft</ulink> in
  243. Paris due to his <ulink url="http://cups.sourceforge.net/xpp/">XPP</ulink>
  244. project. His task was switching from LPD to CUPS as default printing
  245. system in Mandrake Linux 7.2.</para>
  246.  
  247. <para>To make this reality without loosing support for
  248. any printer which was supported under Mandrake Linux 7.1, he made use
  249. of the Foomatic database to integrate the good old GhostScript printer
  250. drivers in the CUPS system. He got write access to the database from
  251. Grant so that he could enter the execution data of all the drivers,
  252. which is essential for the database to generate the PPD files which
  253. CUPS needs to support all printer/driver pairs.</para>
  254.  
  255. </section>
  256.  
  257. <section>
  258. <title>The Database grows up</title>
  259.  
  260. <para>This way the database was not only a collection of
  261. user reports how well printers are supported by free software, but
  262. also a powerful tool to configure printers under various spoolers. In
  263. contrary to other printer configuration database systems (as RHS
  264. Printfilters and APS filters) the <ulink url="http://www.linuxprinting.org/foomatic.html">Foomatic</ulink> system
  265. offered full support to all user-settable options of all free software
  266. printer drivers (to obtain this, Till had often to consult the
  267. driver's source code due to lack of driver documentation) and
  268. supported three spoolers (CUPS, LPD and alike, PDQ).</para>
  269.  
  270. <para>In March 2001, Red Hat 7.1 came out as the second
  271. distribution using Foomatic data for their new printer setup utility
  272. "printconf" and dropping their RHS Printfilters which were the most
  273. used printer setup database before. Red Hat was using LPRng as
  274. printing system that time.</para>
  275.  
  276. </section>
  277.  
  278. <section>
  279. <title>From Postgres to XML</title>
  280.  
  281. <para>Also in March 2001, the original Postgres-based
  282. system was thrown out and replaced with the new XML version of the <ulink url="http://www.linuxprinting.org/foomatic.html">Foomatic</ulink>
  283. configuration and filter system. This made it possible to download the
  284. complete Foomatic database and use it on one's local machine. In
  285. theory this was possible, but the engine to generate the
  286. spooler-specific configuration files from the printer, driver, and
  287. option XML files was very slow and memory consuming (around 150
  288. MB). In addition, it needed something like 10 Perl libraries for the
  289. XML handling, which made it difficult for inexperienced users to
  290. install Foomatic. This was version 1.1 of Foomatic.</para>
  291.  
  292. <para>In July 2001, Grant gave full administration access
  293. to Till so that he could maintain the system. Grant had not much time
  294. for it any more, due to his work at a new start-up company.</para>
  295.  
  296. </section>
  297.  
  298. <section>
  299. <title>C instead of Perl: huge speed improvements for Foomatic</title>
  300.  
  301. <para>By the end of August 2001, Till introduced a C
  302. program into Foomatic to accelerate the generation of the
  303. configuration files substantially, which allowed for the first time to
  304. compute the files on-demand from a local XML database instead of
  305. shipping pre-compiled files for all printer-driver combos. He also did
  306. the full implementation of the "<emphasis>foomatic-configure</emphasis>" and
  307. "<emphasis>foomatic-printjob</emphasis>" scripts which provide printer
  308. configuration and print job handling interfaces which are independent
  309. of the spooler actually used.</para>
  310.  
  311. <para>In October 2001, Mandrake Linux 8.1 came out as the
  312. first distribution supporting three spoolers (CUPS, LPRng, and PDQ)
  313. equally, with the help of the Foomatic system and spooler-specific
  314. configuration files being computed on demand. This was done through a
  315. new version of "printerdrake" (Mandrake's printer setup tool) vastly
  316. improved by Till.</para>
  317.  
  318. <para>April 2002: A second C program added by Till
  319. liberated Foomatic from needing this big amount of Perl libraries. The
  320. libxml-based C program reads XML files and puts out Perl data
  321. structures which can be read directly by Perl programs without special
  322. Perl libraries. This way the installation of Foomatic got much easier,
  323. and the web site got faster. This is the initial work leading to
  324. version 2.0 of Foomatic.</para>
  325.  
  326. </section>
  327.  
  328. <section>
  329. <title>Gathering more support for Foomatic and the Database</title>
  330.  
  331. <para>June 2002: Till met printing developers of Red Hat
  332. and SuSE on a Foomatic workshop which he has given on the LinuxTag
  333. 2002 in Karlsruhe in Germany. They joined the Foomatic developer team
  334. and a new design for Foomatic where all spoolers use PPD files as
  335. printer/driver description files was under discussion.</para>
  336.  
  337. <para>July 2002: Till released the version 2.0.0 of
  338. Foomatic to open a stable branch and to let the development of the new
  339. PPD-centric Foomatic happen in a development branch (version 2.9.x) to
  340. approach version 3.0.</para>
  341.  
  342. <para>Now Foomatic has evolved into to an unofficial
  343. standard: It serves as the printer/driver capabilities database and
  344. driver/spooler integration system for the GNU/Linux distributions
  345. Mandrake, Red Hat, Conectiva, Debian, and others. SuSE was
  346. participating in the development of Foomatic 3.0.x, so they prepared
  347. for using Foomatic. In addition, around 5000 people every day visited
  348. the <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> web
  349. site.</para>
  350.  
  351. <para>September 2002: With Mac OS X Apple switched to a
  352. Unix-based operating system, with a kernel derived from FreeBSD, but
  353. with their own, proprietary desktop environment. From version 10.2 on
  354. Apple used CUPS as the printing system. Tyler Blessing started to make
  355. <ulink url="http://www.linuxprinting.org/macosx/">Mac OS X packages</ulink>
  356. of ESP GhostScript and the most important free software printer
  357. drivers. So many printers for which there are no manufacturer-supplied
  358. printer drivers got working under Mac OS X. Since then, up to the end
  359. of the year the number of visitors per day doubled to around
  360. 10000.</para>
  361.  
  362. <para>December 2002: After <ulink url="http://www.linuxprinting.org/pipermail/foomatic-devel/2002q3/thread.html">longer
  363. e-mail discussion</ulink> on the <ulink url="http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.foomatic.devel">Foomatic
  364. developer forum</ulink>, especially with Johannes Meixner from SuSE, Till
  365. announced the first release in the Foomatic 2.9.x development series,
  366. Foomatic 2.9.0. This was the first version of Foomatic, where PPD
  367. files and the universal "<emphasis>foomatic-rip</emphasis>" filter are used with
  368. all spoolers. "<emphasis>foomatic-rip</emphasis>" makes it also possible for the
  369. first time that manufacturer-supplied PPD files of PostScript printers
  370. can be used with every spooler.</para>
  371.  
  372. <para>April 2003: Mandrake Linux 9.1 is the first
  373. distribution using Foomatic 3.0.x.</para>
  374.  
  375. <para>May 2003: Foomatic 3.0.0 is released and replaces
  376. the old Foomatic 2.0.x series. Besides completely <emphasis>Adobe-compliant
  377. PPD files</emphasis> and "<emphasis>foomatic-rip</emphasis>" there are many new features,
  378. as manufacturer-PPD support for all spoolers, custom page sizes,
  379. applying options to selected pages, composite options, ...</para>
  380.  
  381. </section>
  382.  
  383. </section>
  384.  
  385. <section>
  386. <title>The Foomatic system as it is now</title>
  387.  
  388. <section>
  389. <title>The XML database</title>
  390.  
  391. <para>The core of Foomatic since version 1.1 is an XML
  392. database containing one file for every printer, one file for every
  393. driver, and one file for every adjustable option. These files contain
  394. all the needed information about the printer and driver capabilities
  395. for both forming the database entry pages on <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> and
  396. providing the information about the driver's command lines and their
  397. options.</para>
  398.  
  399. <para>The files contain:</para>
  400. <itemizedlist>
  401.  
  402.   <listitem><para><emphasis>Printers</emphasis>: Contain make, model, mechanism type (inkjet,
  403.     laser, ...), maximum resolution, color/grayscale, how well they
  404.     work under free software, comments, information about consumables,
  405.     ...</para></listitem>
  406.  
  407.   <listitem><para><emphasis>Drivers</emphasis>: Contain name, type, command line prototype,
  408.     comments, list of supported printers, ...</para></listitem>
  409.  
  410.   <listitem><para><emphasis>Options</emphasis>: Contains name, type, for which printer(s) and
  411.     driver(s) they are, default setting (depending on printer/driver),
  412.     list/range of possible settings, names of the settings, for which
  413.     printer(s)/driver(s) each setting is valid, strings to insert into
  414.     the driver's command line.</para></listitem>
  415.  
  416. </itemizedlist>
  417.  
  418. </section>
  419.  
  420. <section>
  421. <title>How does the database work? - A small example</title>
  422.  
  423. <para>To explain how the database is is structured, we
  424. assume that we have a very small database, consisting only of the
  425. entries shown in Fig. 1: 4 printers, 3 drivers, and 2 options. The
  426. real database naturally has many more entries, especially every driver
  427. <emphasis>must</emphasis> have a "PageSize" option to make the spoolers working
  428. correctly. The information contained in the XML files you see in the
  429. colored boxes, the white boxes under the printer entries show what can
  430. be derived from the information stored in the database.</para>
  431.  
  432. <para>At first let's see the "ljet4" driver, a driver for
  433. printers which understand PCL 5e and with maximum resolutions up to
  434. 600 dpi. Its printer list contains all printers which understand PCL
  435. 5e: HP LaserJet 4, HP LaserJet 2100, and Epson EPL-5900. The Epson
  436. Stylus C80 does not understand PCL.</para>
  437.  
  438. <para>The "pxlmono" driver serves for PCL 6 printers with
  439. up to 1200 dpi, in our case the HP LaserJet 2100 and the Epson
  440. EPL-5900.</para>
  441.  
  442. <para>The "gimp-print" driver supports all printers in
  443. our example because it generates various languages, including PCL 5e
  444. for our lasers and ESC/P 2 for the Epson Stylus C80.</para>
  445.  
  446. <para>Note that the printers and the drivers are not
  447. associated by the printer's languages. A printer is only considered as
  448. supported by a driver when it is in the printer list of the
  449. appropriate driver entry.</para>
  450.  
  451. <para>All information about which options and possible
  452. option settings are available for a certain printer/driver pair are
  453. stored in the option XML files as the so-called
  454. constraints. Constraints can qualify or disqualify options or settings
  455. for a certain manufacturer, model, and/or driver. The "Resolution"
  456. option in our example has constraints that qualify it for the "ljet4",
  457. "pxlmono", and "gimp-print" drivers, so it is available for all
  458. drivers in our example. Due to no printer restrictions made here, all
  459. printers/driver combos with one of the three shown drivers will have
  460. the "Resolution" option here.</para>
  461.  
  462. <para>There are three choices "600 dpi", "1200 dpi", and
  463. "720 dpi". If they had no constraints they applied for all
  464. printers/driver combos, but as laser printers and so also dedicated
  465. laser printer drivers only having multiples of 300 dpi as resolutions
  466. and Epson inkjets only having multiples of 360 dpi, we have defined
  467. constraints for the settings, so that the user gets only valid
  468. resolutions presented for his printer. The "600 dpi" resolution is
  469. qualified for the "pxlmono" and "ljet4" drivers for arbitrary
  470. printers. These drivers support only lasers and all lasers in our
  471. example do 600 dpi. For 600 dpi with "gimp-print" we have additional
  472. restrictions to our three lasers because the C80 works with
  473. GIMP-Print, but not with 600 dpi. For the "1200 dpi" we had to impose
  474. the constraint to only "pxlmono". The other two drivers are only PCL
  475. 5e drivers and so they drive laser printers only up to 600 dpi. And as
  476. all lasers not supporting 720 dpi, the "720 dpi" choice is restricted
  477. to exclusively being valid for the C80, independent which driver is
  478. used.</para>
  479.  
  480. <para>
  481. <ulink url="http://www.linuxprinting.org/database.html">
  482. <inlinemediaobject>
  483. <imageobject>
  484. <imagedata fileref="picture-189-01.gif" format="GIF"/>
  485. </imageobject>
  486. </inlinemediaobject>
  487. </ulink> 
  488.  
  489. </para>
  490.  
  491. <para><emphasis>Fig. 1: An example to explain the structure of the
  492. database</emphasis></para>
  493.  
  494. <para>The second option in our example is the numerical
  495. option "Copies", it allows integer numbers from 1 to 999 as settings,
  496. but the file only contains the range, not setting entries for every
  497. possible number. Therefore no constraints can be applied to the
  498. settings. One has to define various "Copies" option entries when there
  499. would be printers with different maximum numbers of copies.</para>
  500.  
  501. <para>Our "Copies" option is not an option of any of the
  502. drivers, it is an option of the printers which can be set by sending a
  503. so-called PJL (Printer Job Language) command to the printer before
  504. sending the job data itself. This facility is available in nearly
  505. every PostScript or PCL laser printer and the commands are the same,
  506. independent whether the job itself is sent in PostScript, PCL 5, or
  507. PCL 6 (PostScript printers usually understand also PCL). So the
  508. commands are independent of the printer driver used for the job
  509. itself. Therefore PJL options have only printer constraints, in our
  510. example the candidates understanding PJL and so also the "Copies"
  511. option are the two HP lasers, the LaserJet 4 and 2100.</para>
  512.  
  513. </section>
  514.  
  515. <section>
  516. <title>What is done to set up a print queue with this data?</title>
  517.  
  518. <para>The first thing needed is a PPD file for the
  519. desired printer/driver combo. The principle of obtaining this is the
  520. same for both generating it on the <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> web site or
  521. with a <ulink url="http://www.linuxprinting.org/foomatic.html">local copy
  522. of Foomatic</ulink>.</para>
  523.  
  524. <para>At first a combo XML file for the chosen
  525. printer/driver combo is generated. After checking that the printer is
  526. in the driver's printer list a C program ("<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db-engine/foomatic-combo-xml.c?rev=3.2&content-type=text/plain"><emphasis>foomatic-combo-xml.c</emphasis></ulink>")
  527. parses the printer entry, the driver entry and then all option
  528. entries. The printer entry is written entirely into the combo XML
  529. file, from the driver entry all except the printer list gets into the
  530. combo file and from the options only the ones which are valid for the
  531. printer/driver combo, with all constraints and invalid settings taken
  532. out. The C program does not use any XML libraries and loads only one
  533. source XML file at a time, parses it sequentially, and writes the read
  534. data directly into the combo XML file if it is needed. This makes the
  535. process very fast and less memory-consuming. The combo XML file is a
  536. spooler-independent XML representation of the capabilities of the
  537. printer/driver combo and of how one prints PostScript files with
  538. it.</para>
  539.  
  540. <para>Now the combo XML file is parsed by another C
  541. program ("<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db-engine/foomatic-perl-data.c?rev=3.11&content-type=text/plain"><emphasis>foomatic-perl-data.c</emphasis></ulink>")
  542. which uses <emphasis>libxml2</emphasis> from <ulink url="http://www.xmlsoft.org"><emphasis>www.xmlsoft.org</emphasis></ulink> to generate
  543. a Perl data structure from the XML file. This is done by a C program
  544. because there is one standard XML library with which the process can
  545. be easily and fastly done. Doing this in Perl is much more
  546. complicated. This still spooler-independent Perl data structure
  547. contains most of the data which the combo XML file provides,
  548. especially all the information about how to execute the driver. This
  549. information goes into the PPD file so that the spooler, client
  550. machines, and the "<emphasis>foomatic-rip</emphasis>" filter script know about how
  551. to use the driver and how to apply the user-supplied option
  552. settings.</para>
  553.  
  554. <para>Now a spooler-independent, completely <ulink url="http://partners.adobe.com/asn/tech/ps/technotes.jsp">Adobe-compliant</ulink>
  555. PPD file is built. In contrary to the former Foomatic 2.0.x in this
  556. PPD file no information is hidden in comment lines. Everything which
  557. cannot be defined with standard keywords (as for example the
  558. GhostScript command line) is defined with special keywords beginning
  559. with "<emphasis>*Foomatic...</emphasis>". The Adobe specification allows custom
  560. keywords and requires applications who do not know a certain keyword,
  561. to ignore it. This PPD file is the file carrying all necessary
  562. information about the printer and the driver in the configuration of
  563. the print queue. Either the user downloads it from <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> or the "<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db-engine/foomatic-configure.in?rev=3.11&content-type=text/plain"><emphasis>foomatic-configure</emphasis></ulink>"
  564. Perl script of a local Foomatic installation creates it when setting
  565. up the print queue.</para>
  566.  
  567. <para>In addition to the PPD file the universal filter
  568. script "<emphasis>foomatic-rip</emphasis>" has to be installed. It will be called
  569. by the spooler to translate the incoming PostScript job data into the
  570. printer's native language.</para>
  571.  
  572. <para>"<emphasis>foomatic-rip</emphasis>" is a Perl script and reads
  573. at first the printer and driver information from the PPD file. For
  574. that no extra Perl libraries or C programs are needed. The
  575. "<emphasis>foomatic-rip</emphasis>" gets the option settings given by the user
  576. either from the spooler via command line option/environment variables
  577. or embedded in the PostScript job data. With this information the
  578. "<emphasis>foomatic-rip</emphasis>" builds the appropriate GhostScript command
  579. line and executes it. It also inserts settings into the job data,
  580. either PostScript or PJL commands.</para>
  581.  
  582. </section>
  583.  
  584. <section>
  585. <title>How does printing with Foomatic work?</title>
  586.  
  587. <para>Fig. 2 shows a diagram of the data flow when
  588. Foomatic is used for printing. On the system there is already a
  589. spooler (dark cyan box) and GhostScript with a driver (cyan box). A
  590. print queue is set up using the <ulink url="http://www.linuxprinting.org/">linuxprinting.org</ulink> web site or
  591. a local Foomatic installation (light yellow box). For this a PPD file
  592. and "<emphasis>foomatic-rip</emphasis>" is installed (yellow boxes).</para>
  593.  
  594. <para>The data to be printed goes usually from the
  595. application program (light red) through a printing frontend (blue) to
  596. the spooler (dark cyan), and from there through the filter (yellow)
  597. and GhostScript with driver (cyan) to the printer.</para>
  598.  
  599. <para>When one executes the printing command in an
  600. application, it usually produces PostScript as output and sends it to
  601. a printing frontend, normally the command line frontend
  602. "<emphasis>lpr</emphasis>". The user can often modify the printing command to
  603. choose a printer and to set options, or to use another command than
  604. "<emphasis>lpr</emphasis>". An "<emphasis>lpr</emphasis>" command line to print with a
  605. resolution of 1200 dpi on the printer "lj" can look like this:</para>
  606.  
  607. <programlisting><![CDATA[   lpr -P lj -o Resolution=1200 file.ps]]></programlisting>
  608.  
  609. <para>The option settings specified on the command line
  610. (red line) accompany the PostScript data (blue line) when the job goes
  611. to the spooler.</para>
  612.  
  613. <para>If the user chooses a graphical printing frontend
  614. ("<ulink url="http://printing.kde.org/"><emphasis>kprinter</emphasis></ulink>", "<ulink url="http://cups.sf.net/xpp/"><emphasis>xpp</emphasis></ulink>", "<ulink url="http://gtklp.sf.net/"><emphasis>gtklp</emphasis></ulink>", "<ulink url="http://sf.net/projects/lpr"><emphasis>gpr</emphasis></ulink>", ...)  as the
  615. printing command in his application, a window pops up and shows a list
  616. of available printers and gives the possibility to open a dialog with
  617. printer-specific options. The frontend must get the information about
  618. the printers and options somehow (brown lines). In case of CUPS as the
  619. spooler all frontends poll this information from the CUPS daemon
  620. (black lines) and CUPS itself takes the printer option information
  621. from the PPD file of the appropriate print queue (brown line). In case
  622. of LPD, LPRng, or GNUlpr being the spooler "<emphasis>gpr</emphasis>" reads the
  623. Foomatic-generated PPD file directly (brown line). "<emphasis>gpr</emphasis>" is a
  624. special GUI frontend: It uses PPD files and stuffs all option settings
  625. into the PostScript data (magenta line), so it works with any spooler
  626. and also if there are different spoolers on the client and on the
  627. server. "<emphasis>kprinter</emphasis>" calls "<emphasis>lpr</emphasis>" with the option
  628. settings on the command line (blue and red lines).</para>
  629.  
  630. <para>
  631. <ulink url="http://www.linuxprinting.org/foomatic.html">
  632. <inlinemediaobject>
  633. <imageobject>
  634. <imagedata fileref="picture-189-02.gif" format="GIF"/>
  635. </imageobject>
  636. </inlinemediaobject>
  637. </ulink> 
  638.  
  639. </para>
  640.  
  641. <para><emphasis>Fig. 2: Data flow when printing with Foomatic</emphasis> 
  642. </para>
  643.  
  644. <para>KDE applications use "<emphasis>kprinter</emphasis>" as their
  645. printing dialog, so they behave as "<emphasis>kprinter</emphasis>".</para>
  646.  
  647. <para>In PPD-aware applications as Star Office,
  648. OpenOffice.org, the GIMP, or Windows/Mac clients using a PostScript
  649. driver, one assigns a PPD file (in our case the Foomatic-generated
  650. one) to every print queue and the application gets the printer
  651. information from that file. The option settings are all embedded in
  652. the PostScript data (magenta line), as with "<emphasis>gpr</emphasis>".</para>
  653.  
  654. <para>The spooler calls "<emphasis>foomatic-rip</emphasis>" and hands
  655. over all the PostScript and option settings data to it. Then
  656. "<emphasis>foomatic-rip</emphasis>" parses the PPD file, builds the GhostScript
  657. command line according to the user's option settings, and executes
  658. it. The resulting data in the printer's language (green line) goes
  659. finally to the printer.</para>
  660.  
  661. </section>
  662.  
  663. <section>
  664. <title>The structure of the XML database</title>
  665.  
  666. <para>Here we want to get deeper into the structure of
  667. the XML data files. Therefore we explain one example printer, driver,
  668. and option XML file. The following text is mainly taken from the <ulink url="http://www.linuxprinting.org/foomatic-db-engine/README"><emphasis>README</emphasis></ulink>
  669. file of the "foomatic-db-engine" package.</para>
  670.  
  671. <section>
  672. <title>An option entry: "PageSize" (<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db/db/source/opt/2.xml?rev=3.2&content-type=text/plain"><emphasis>db/source/opt/2.xml</emphasis></ulink>)</title>
  673.  
  674. <para>Every option exists independently from printers or
  675. drivers, because they might apply to arbitrary combinations of printers
  676. and/or drivers.  In practice, some drivers have wholly unique options
  677. ("gimp-print"/"stp", for example), while others (lots of generic basic
  678. Ghostscript drivers, for example) share some options.</para>
  679. <programlisting><![CDATA[<option type="enum" id="opt/2">]]></programlisting>
  680.  
  681. <para>Options are of a type "enum", "bool", "int",
  682. "float", "string", or "password", options have an ID. The id is also
  683. the filename.</para>
  684.  
  685. <para>The shortname is a spaceless short name for the
  686. thing. It must not contain "/" or ":" (otherwise it will not be
  687. handled correctly in PPD files). It should be one of the standard
  688. Adobe PPD option names if appropriate</para>
  689.  
  690. <programlisting><![CDATA[  <arg_shortname>]]></programlisting>
  691.  
  692. <para>Various things here, and all <comments>, are
  693. internationalized.  They take the usual posit locale codes in the form
  694. ox[shy], where ox is a two-letter is language code, and YY is
  695. two-letter country code to distinguish differing national
  696. dialects.</para>
  697.  
  698. <para>Generally the national dialects won't be very
  699. common or necessary here.  The backends currently require that
  700. <en> content be provided.</para>
  701.  
  702. <programlisting><![CDATA[   <en>PageSize</en><!-- backends only know <en> shortnames! -->
  703.   </arg_shortname>]]></programlisting>
  704.  
  705. <para>The longname is a short phrase describing the thing
  706. in more detail, GUI tools usually show longnames</para>
  707.  
  708. <programlisting><![CDATA[  <arg_longname>
  709.    <en>Page Size</en>
  710.   </arg_longname>]]></programlisting>
  711.  
  712. <para>The comments are used to form documentation.  In
  713. theory these can become man pages or the like.</para>
  714.  
  715. <programlisting><![CDATA[  <!-- A multilingual <comments> block can appear here, too;
  716.        it should be treated as documentation for the user. -->]]></programlisting>
  717.  
  718. <para>The execution section describe how the backend
  719. should execute this option. The order and spot apply to the
  720. <emphasis>driver</emphasis>'s prototype for <arg_substitution /> (once
  721. called commandline) style options, or just the order applies for
  722. <arg_postscript /> and <arg_pjl /> options. The order and
  723. the <arg_section> go into the "*OrderDependency" line of the
  724. appropriate option entry in the PPD file, for this example one would
  725. get</para>
  726.  
  727. <programlisting><![CDATA[   *OrderDependency: 100 DocumentSetup *PageSize]]></programlisting>
  728.  
  729. <para>When no <arg_section> is given, "AnySetup" is
  730. used as a default.</para>
  731.  
  732. <para>For <arg_substitution /> options the
  733. <arg_proto> is inserted into the driver's command line, at the
  734. spot (e.  g. "%A") whose letter is given between the
  735. <arg_spot>...</arg_spot> tags, the <arg_proto> of an
  736. <arg_postscript /> option is a snippet of PostScript code which
  737. is inserted into the PostScript data stream of the job, for
  738. DSC-conforming PostScript into the section specified with
  739. <arg_section>, otherwise in the beginning. The <arg_proto>
  740. lines of <arg_pjl /> options are PJL commands which are sent to
  741. the printer before the output of the driver's command line is
  742. sent. Because this only works reliably when the driver output does not
  743. have its own PJL command header, these options are ignored when the
  744. driver's XML file is marked with a <nopjl /> tag in its
  745. <execution> section. Drivers which produce their own PJL and
  746. therefore are marked with <nopjl /> are for example "hpijs" and
  747. "hl1250". There is also the <arg_composite /> execution style
  748. for composite options, see the "Composite Options" section below. The
  749. user's value gets put into the <arg_proto>'s %s location.</para>
  750.  
  751. <para>The <arg_group>...</arg_group> tags put
  752. the option into the PPD option group named here. In many PPD-based
  753. GUIs ("kprinter", "xpp", OpenOffice.org, ...) every group is shown as
  754. a tab or a tree branch containing the member options of this
  755. group. You can also specify subgroups. Then you have to use a "group
  756. path" similar to directory paths, with the group and subgroup names
  757. separated by slashes (<arg_group>General/Paper</arg_group>
  758. is the "Paper" subgroup in the "General" group). Subgroups are not
  759. recommended as there is no GUI supporting them. If an option is member
  760. of a composite option (See "Composite Options" section below), the
  761. <arg_group>...</arg_group> tags will be ignored.</para>
  762.  
  763. <programlisting><![CDATA[  <arg_execution>
  764.    <arg_group>General</arg_group>
  765.    <arg_order>100</arg_order>
  766.    <arg_section>DocumentSetup</arg_section>
  767.    <arg_spot>Z</arg_spot> <arg_postscript />
  768.    <arg_proto><</PageSize[%s]/ImagingBBox null>>setpagedevice</arg_proto>
  769.    </arg_execution>]]></programlisting>
  770.  
  771. <para>The constraints define what printer/driver
  772. combinations this option applies to.  The <emphasis>most specific</emphasis>
  773. constraint rules the day; it's "sense" says whether or not the option
  774. is "in".  The winning constraint also provides the default value used
  775. when this option applies to that printer and driver.</para>
  776.  
  777. <para>Constraint elements are: driver, make, model.  The
  778. driver is the driver name, or not present to apply to any driver.  The
  779. make is the printer make, or not present to apply to any printer
  780. make. The model is the driver model, or not present to apply to any
  781. printer. Instead of make/model, you can also specify
  782. <printer>id</printer>.</para>
  783.  
  784. <para><emphasis>IMPORTANT</emphasis>: The make and model must match
  785. the one in the printer xml definition, and everywhere else in the
  786. other options. One needs to write a utility to change printer names
  787. sensibly.</para>
  788.  
  789. <itemizedlist>
  790.  
  791.   <listitem><para>It is illegal to have a model with no make.</para></listitem>
  792.  
  793.   <listitem><para>It is illegal to have none of make/model/driver.</para></listitem>
  794.  
  795.   <listitem><para>It is illegal to have <emphasis>no</emphasis> constraints, or at least such
  796.     options are never used.</para></listitem>
  797.  
  798. </itemizedlist>
  799.  
  800. <para>For enum options, the defval is the id of the
  801. enum_val that is the default.  For other option types, it is the
  802. actual default value (i. e, a number, or 1 or 0 for boolean, etc).</para>
  803.  
  804. <programlisting><![CDATA[  <constraints>
  805.      <constraint sense="true">
  806.       <driver>sj48</driver>
  807.       <arg_defval>ev/1</arg_defval>
  808.      </constraint>
  809.      <constraint sense="true">
  810.       <driver>r4081</driver>
  811.       <arg_defval>ev/1</arg_defval>
  812.      </constraint>]]></programlisting>
  813.  
  814. <para>(A gaillion constraints skipped)</para>
  815.  
  816. <programlisting><![CDATA[  </constraints>
  817.   <enum_vals>
  818.    <enum_val id="ev/1">
  819.     <ev_longname>
  820.      <en>US Letter</en>
  821.     </ev_longname>
  822.     <!-- A multilingual <comments> block can appear here, too;
  823.          it should be treated as documentation for the user. -->
  824.     <ev_shortname>
  825.      <en>Letter</en>
  826.      <!-- Until someone tells me how to learn the user locale in 
  827.           backends, the shortname must be monolingual in <en>! -->
  828.     </ev_shortname>]]></programlisting>
  829.  
  830. <para>If present, the driverval is what gets substituted
  831. in for the %s in the option's prototype.  This way the user-visible
  832. stuff can be anything.</para>
  833.  
  834. <programlisting><![CDATA[    <ev_driverval>612 792</ev_driverval>]]></programlisting>
  835.  
  836. <para>This enum_val has no constraints.  It <emphasis>is</emphasis>
  837. OK for enum_vals to have no constraints; they are assumed to apply
  838. unless constrained otherwise.</para>
  839.  
  840. <programlisting><![CDATA[   </enum_val>
  841.    <enum_val id="ev/115">
  842.     <ev_longname>
  843.      <en>A3</en>
  844.     </ev_longname>
  845.     <!-- A multilingual <comments> block can appear here, too;
  846.          it should be treated as documentation for the user. -->
  847.     <ev_shortname>
  848.      <en>A3</en>
  849.      <!-- Until someone tells me how to learn the user locale in 
  850.           backends, the shortname must be monolingual in <en>! -->
  851.     </ev_shortname>
  852.     <ev_driverval>842 1191</ev_driverval>]]></programlisting>
  853.  
  854. <para>Here are some example constraints for an
  855. enum_val. The A3 size paper doesn't fit on lots of printers, so there
  856. are various constraints to make the right thing happen.</para>
  857.  
  858. <programlisting><![CDATA[    <constraints>
  859.      <constraint sense="true">
  860.       <driver>ml85p</driver>
  861.       <arg_defval>na</arg_defval>
  862.      </constraint>
  863.      <constraint sense="true">
  864.       <make>HP</make>
  865.       <model>DeskJet 1000C</model>
  866.       <driver>pnm2ppa</driver>
  867.       <arg_defval>na</arg_defval>
  868.      </constraint>
  869.      <constraint sense="false">
  870.       <make>HP</make>
  871.       <model>DeskJet 820C</model>
  872.       <driver>pnm2ppa</driver>
  873.       <arg_defval>na</arg_defval>
  874.      </constraint>]]></programlisting>
  875.  
  876. <para>(lots more...)</para>
  877.  
  878. <programlisting><![CDATA[    </constraints>
  879.    </enum_val>
  880.   </enum_vals>
  881. </option>]]></programlisting>
  882.  
  883. <para>To allow custom page sizes to be used one has add a
  884. choice with the <ev_shortname> being "Custom" to the "PageSize"
  885. option (example below). This choice will be treated as the custom page
  886. size. When the user selects this choice, he has to provide the width
  887. and the height of the page in addition. These values are converted
  888. into PostScript points (1/72 inches) and inserted into placeholders in
  889. the <ev_driverval> of this choice. The <ev_driverval>
  890. should contain a placeholder "%0" for the page width and "%1" for the
  891. page height. Alternatively the <ev_driverval> can contain two
  892. zeros ("0") from which the first will be replaced by the page width
  893. and the second by the page height. Then one gets Adobe-compliant
  894. entries for the custom page size in the PPD files and one can set a
  895. custom page size with the following commands:</para>
  896.  
  897.   <table frame="none">
  898. <title></title>
  899. <tgroup cols="0">
  900.     <tbody>
  901.       <row>
  902.         <entry><para>CUPS:</para></entry>
  903.     <entry><para><emphasis>lpr -P huge -o PageSize=Custom.500x750cm
  904.             bigposter.ps</emphasis></para></entry>
  905.       </row>
  906.       <row>
  907.         <entry><para>LPRng:</para></entry>
  908.     <entry><para><emphasis>lpr -P huge -Z PageSize=Custom.500x750cm
  909.             bigposter.ps</emphasis></para></entry>
  910.       </row>
  911.       <row>
  912.         <entry><para>GNUlpr:</para></entry>
  913.     <entry><para><emphasis>lpr -P huge -o PageSize=Custom.500x750cm
  914.             bigposter.ps</emphasis></para></entry>
  915.       </row>
  916.       <row>
  917.         <entry><para>LPD:</para></entry>
  918.     <entry><para><emphasis>lpr -P huge -JPageSize=Custom.500x750cm
  919.             bigposter.ps</emphasis></para></entry>
  920.       </row>
  921.       <row>
  922.         <entry><para>PPR (RIP):</para></entry>
  923.     <entry><para><emphasis>ppr -P huge -F "*PageSize Custom" --ripopts 500x750cm
  924.                 bigposter.ps</emphasis></para></entry>
  925.       </row>
  926.       <row>
  927.         <entry><para>PPR (Interf.):</para></entry>
  928.     <entry><para><emphasis>ppr -P huge -F "*PageSize Custom" -i 500x750cm
  929.             bigposter.ps</emphasis></para></entry>
  930.       </row>
  931.       <row>
  932.         <entry><para>PDQ:</para></entry>
  933.     <entry><para><emphasis>pdq -P huge -oPageSize_Custom -aPageWidth=500
  934.                 -aPageHeight=750 -oPageSizeUnit_cm bigposter.ps</emphasis></para></entry>
  935.       </row>
  936.       <row>
  937.         <entry><para>No spooler:</para></entry>
  938.     <entry><para><emphasis>foomatic-rip -P huge -o PageSize=Custom.500x750cm
  939.                 bigposter.ps</emphasis></para></entry>
  940.       </row>
  941.     </tbody>
  942.   </tgroup>
  943. </table>
  944.  
  945. <para>Here is an example for a custom page size
  946. setting:</para>
  947.  
  948. <programlisting><![CDATA[  <enum_val id="ev/PageSize-Custom">
  949.    <ev_longname>
  950.     <en>Custom size</en>
  951.    </ev_longname>
  952.    <!-- A multilingual <comments> block can appear here, too;
  953.         it should be treated as documentation for the user. -->
  954.    <ev_shortname>
  955.     <en>Custom</en>
  956.     <!-- Until someone tells me how to learn the user locale in
  957.          backends, the shortname must be monolingual in <en>! -->
  958.    </ev_shortname>
  959.    <ev_driverval>%0 %1</ev_driverval>
  960.   </enum_val>]]></programlisting>
  961.  
  962. <para>The entry</para>
  963.  
  964. <programlisting><![CDATA[   <ev_driverval>0 0</ev_driverval>]]></programlisting>
  965.  
  966. <para>would have the same effect as the
  967. <ev_driverval> of the example.</para>
  968.  
  969. <para>For numerical (int, float) and bool options there
  970. is no <enum_vals> section. Instead of this section numerical
  971. options have tags to specify minimum and maximum value:</para>
  972.  
  973. <programlisting><![CDATA[  <arg_max>10.0</arg_max>
  974.   <arg_min>0.0</arg_min>]]></programlisting>
  975.  
  976. <para>For the %s in the <arg_proto> a number,
  977. either the user's choice when he has specified this option or the
  978. default value is inserted. Only numbers between the minimum and the
  979. maximum and in case of int options only integer numbers are
  980. allowed.</para>
  981.  
  982. <para>Bool options can be set or not be set. There
  983. <arg_proto> will be inserted if they are set, nothing if they
  984. are not set. A %s in the <arg_proto> is not allowed, there is
  985. nothing to insert for it. As <arg_defval> in the option's
  986. constraints one can use 0 for not setting the option by default or 1
  987. for setting it by default.</para>
  988.  
  989. <para>Bool options need the specification of a name for
  990. the case when they are not set. This will be used by GUIs and in PPD
  991. files:</para>
  992.  
  993. <programlisting><![CDATA[  <arg_shortname_false>
  994.     <en>CorrectBlack</en><!-- Backends only know <en> shortnames! -->
  995.   </arg_shortname_false>]]></programlisting>
  996.  
  997. <para>This name should not contain spaces, ":", or "/".</para>
  998.  
  999. <para>See below for string and password options.</para>
  1000.  
  1001. </section>
  1002.  
  1003. <section>
  1004. <title>A printer entry: <ulink url="http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_4000">HP
  1005. LaserJet 4000</ulink> (<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db/db/source/printer/HP-LaserJet_4000.xml?rev=3.1&content-type=text/plain"><emphasis>db/source/printer/HP-LaserJet_4000.xml</emphasis></ulink>)</title>
  1006.  
  1007. <para>The printer file contains information specific to a
  1008. particular printer.</para>
  1009.  
  1010. <programlisting><![CDATA[<printer id="printer/HP-LaserJet_4000">]]></programlisting>
  1011.  
  1012. <para>Make and model are not internationalized.  There
  1013. will eventually be an "alias" mechanism, but the need is
  1014. different.</para>
  1015.  
  1016. <programlisting><![CDATA[  <make>HP</make>
  1017.   <model>LaserJet 4000</model>]]></programlisting>
  1018.  
  1019. <para>According to the Adobe specifications for PPD files every PPD file
  1020. must contain a unique DOS-compatible file name (the "*PCFileName"),
  1021. a file name with an up to 8 characters log base name and an up to 3
  1022. characters long extension, and upper and lower case letters being
  1023. considered as equal. As every PPD file is for a printer/driver
  1024. combo, we let the first 6 characters being provided by the printer
  1025. entry:</para>
  1026.  
  1027. <programlisting><![CDATA[  <pcmodel>HPLJ4K</pcmodel>]]></programlisting>
  1028.  
  1029. <para>The first two characters should be the manufacturer
  1030. prefix as listed in Appendix D of Adobe's "<ulink url="http://partners.adobe.com/asn/developer/pdfs/tn/5003.PPD_Spec_v4.3.pdf">PostScript
  1031. Printer Description (PPD) File Format Specification Version
  1032. 4.3</ulink>".</para>
  1033.  
  1034. <para>Various stuff about the machine</para>
  1035.  
  1036. <programlisting><![CDATA[  <mechanism>]]></programlisting>
  1037.  
  1038. <para>Printer types can be <laser />, <led
  1039. />, <inkjet />, <dotmatrix />, <impact />,
  1040. <sublimation />, <transfer />. Other types we have to add
  1041. to the CGI script on linuxprinting.org to make the web interface
  1042. displaying them properly.</para>
  1043.  
  1044. <programlisting><![CDATA[    <laser/>]]></programlisting>
  1045.  
  1046. <para>At some point we can make color be less of a
  1047. boolean flag and more of a section full of goodies.</para>
  1048.  
  1049. <programlisting><![CDATA[    <!--not "color"-->
  1050.     <resolution>]]></programlisting>
  1051.  
  1052. <para>In theory this is a list.  In practice We've only
  1053. got one per printer which is the maximum resolution the manufacturer
  1054. claims for this printer.</para>
  1055.  
  1056. <programlisting><![CDATA[      <dpi>
  1057.         <x>1200</x>
  1058.         <y>1200</y>
  1059.       </dpi>
  1060.     </resolution>
  1061.  
  1062.     <consumables>]]></programlisting>
  1063.  
  1064. <para>Information about ink, drums, etc.  The comments
  1065. are supposed to be qualitative ("Separate drum and toner
  1066. cartridges")</para>
  1067.  
  1068. <programlisting><![CDATA[      <comments>
  1069.         <en>toner</en>
  1070.       </comments>]]></programlisting>
  1071.  
  1072. <para>There should be
  1073. <partno>12A1975</partno> elements with manufacturer part
  1074. numbers for the various carts, etc it takes. Then one could have a
  1075. price watcher thingy like there is now for the printers.</para>
  1076.  
  1077. <programlisting><![CDATA[      <!--one or more "partno" elements.-->
  1078.     </consumables>
  1079.   </mechanism>
  1080.  
  1081.   <url>http://www.pandi.hp.com/pandi-db/prod_info.show?model=C4118A&name=LaserJet4000</url>]]></programlisting>
  1082.  
  1083. <para>The lang section.  In practice this will be only
  1084. minimally useful:</para>
  1085.  
  1086. <itemizedlist>
  1087.  
  1088.   <listitem><para>Backends can pstops the ps down a level if needed</para></listitem>
  1089.  
  1090.   <listitem><para>Backends know if pjl options apply</para></listitem>
  1091.  
  1092.   <listitem><para>Backends can know if "quick text" will work</para></listitem>
  1093.  
  1094. </itemizedlist>
  1095.  
  1096. <para>Commonly used language tags: <pcl level="x"
  1097. />, <escp2 />, <proprietary /></para>
  1098.  
  1099. <programlisting><![CDATA[  <lang>
  1100.     <postscript level="2">
  1101.     <!--unknown ppd filename "ppd"--></postscript>
  1102.     <pjl/>
  1103.     <text>
  1104.       <charset>us-ascii</charset>
  1105.     </text>
  1106.   </lang>]]></programlisting>
  1107.  
  1108. <para>The autodetection stuff</para>
  1109.  
  1110. <programlisting><![CDATA[  <autodetect>]]></programlisting>
  1111.  
  1112. <para>There are three ways to auto-detect a printer, via
  1113. the parallel port (<parallel>...</parallel>), the USB
  1114. (<usb>...</usb>), or SNMP (TCP/Socket-connected printer,
  1115. <snmp>...</snmp>). Through these interfaces the printers
  1116. report back an IEEE-1284-compliant ID string from which the fields
  1117. "MFG" (<manufacturer>...</manufacturer>), "MDL"
  1118. (<model>...</model>), "DES"
  1119. (<description>...</description>), and "CMD"
  1120. (<commandset>...</commandset>) are used. The string itself
  1121. can be put between <ieee1284>...</ieee1284> tags, but all
  1122. items which are not constant for all printers of this model, as the
  1123. serial number ("SERN:...;") and the device status ("VSTATUS:...;")
  1124. have to be removed here. As the ID string is usually the same for all
  1125. detection methods, one can put the entries between
  1126. <general>...</general> tags, then the
  1127. <parallel>...</parallel>, <usb>...</usb>, and
  1128. <snmp>...</snmp> are only used for differences to the data
  1129. between the <general>...</general> tags. A complete entry
  1130. could look like:</para>
  1131.  
  1132. <programlisting><![CDATA[  <autodetect>
  1133.     <general>
  1134.       <ieee1284>MFG:HEWLETT-PACKARD;MDL:DESKJET 600;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:Hewlett-Packard DeskJet 600;</ieee1284>
  1135.       <commandset>MLC,PCL,PML</commandset>
  1136.       <description>Hewlett-Packard DeskJet 600</description>
  1137.       <manufacturer>HEWLETT-PACKARD</manufacturer>
  1138.       <model>DESKJET 600</model>
  1139.     </general>
  1140.   </autodetect>]]></programlisting>
  1141.  
  1142. <para>On Linux you find this info for the parallel ports
  1143. (<emphasis>/dev/lp<N></emphasis>, <emphasis><N> = 0, 1, 2, ...</emphasis>) in the
  1144. files</para>
  1145.  
  1146. <programlisting><![CDATA[   /proc/sys/dev/parport/parport0/autoprobe*]]></programlisting>
  1147.  
  1148. <para>for the USB under Linux it is more complicated,
  1149. easiest is to use a little Perl script, called "<ulink url="http://www.linuxprinting.org/download/printing/getusbprinterid.pl"><emphasis>getusbprinterid.pl</emphasis></ulink>":</para>
  1150.  
  1151. <programlisting><![CDATA[#!/usr/bin/perl
  1152.  
  1153. open FILE, "$ARGV[0]" or die;
  1154.  
  1155. my $result;
  1156. # Calculation of IOCTL function 0x84005001 (to get device ID string):
  1157. # len = 1024
  1158. # IOCNR_GET_DEVICE_ID = 1
  1159. # LPIOC_GET_DEVICE_ID(len) = _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
  1160. # _IOC(), _IOC_READ as defined in /usr/include/asm/ioctl.h
  1161.  
  1162. ioctl(FILE, 0x84005001, $result) or die;
  1163. close FILE;
  1164.  
  1165. # Cut resulting string to its real length
  1166. my $length = ord(substr($result, 1, 1)) + (ord(substr($result, 0, 1)) << 8);
  1167. $result = substr($result, 2, $length-2);
  1168.  
  1169. # Remove non-printable characters
  1170. $result =~ tr/[\x0-\x1f]/\./;
  1171. print "$result\n";]]></programlisting>
  1172.  
  1173. <para>Running the program with "<emphasis>./getusbprinterid.pl
  1174. /dev/usb/lp0</emphasis>" returns the ID string of the device on
  1175. <emphasis>/dev/usb/lp0</emphasis>.</para>
  1176.  
  1177. <programlisting><![CDATA[    <!--no known parport probe information-->
  1178.   </autodetect>]]></programlisting>
  1179.  
  1180. <para>Our grading system.  It's US-style letter grades A,
  1181. B, D, and F, which the website shows as "Perfectly", "Mostly",
  1182. "Partially" and "Paperweight". <emphasis>THERE IS NO "C"!!!</emphasis></para>
  1183.  
  1184. <programlisting><![CDATA[  <functionality>A</functionality>]]></programlisting>
  1185.  
  1186. <para>Arguably, the scores should live with the
  1187. printer/driver association and not on the printer, but then it's a big
  1188. hassle to figure out if a printer works... So the score is the one
  1189. reached with the driver working best, the "recommended" driver.</para>
  1190.  
  1191. <para>There's a spot for this "recommended" driver,
  1192. usually the driver which gives the maximum output quality. It is for
  1193. user information on the web site, but newbie-friendly printer setup
  1194. GUIs should use it, too.  Unfortunately, only "printerdrake" of
  1195. Mandrake Linux makes use of it.</para>
  1196.  
  1197. <programlisting><![CDATA[  <driver>Postscript</driver>]]></programlisting>
  1198.  
  1199. <para>The <unverified /> tag was on all printer
  1200. entries which were formerly entered by visitors using the web printer
  1201. input interface as the database was still PostGreSQL-driven.</para>
  1202.  
  1203. <programlisting><![CDATA[  <!--not "unverified"-->]]></programlisting>
  1204.  
  1205. <para>If there is a web site with additional interesting
  1206. info about this printer, it can be mentioned in the entry by putting
  1207. it between <contrib_url>...</contrib_url> tags,</para>
  1208.  
  1209. <programlisting><![CDATA[  <!--no "contrib_url"-->]]></programlisting>
  1210.  
  1211. <para>The regular notes section.  The allowed tags are:
  1212. <p>, <a href="foobar"> </a> and many other simple
  1213. tags (<b>, <i>, <tt>, ...). Note that to distinguish
  1214. what is XML and what is the embedded HTML, make the following
  1215. replacements:</para>
  1216.  
  1217.   <table frame="none">
  1218. <title></title>
  1219. <tgroup cols="0">
  1220.     <tbody>
  1221.       <row>
  1222.         <entry><para><emphasis><</emphasis></para></entry>
  1223.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1224.         <entry><para><emphasis>&lt;</emphasis></para></entry>
  1225.       </row>
  1226.       <row>
  1227.         <entry><para><emphasis>></emphasis></para></entry>
  1228.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1229.         <entry><para><emphasis>&gt;</emphasis></para></entry>
  1230.       </row>
  1231.       <row>
  1232.         <entry><para><emphasis>"</emphasis></para></entry>
  1233.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1234.         <entry><para><emphasis>&quot;</emphasis></para></entry>
  1235.       </row>
  1236.       <row>
  1237.         <entry><para><emphasis>'</emphasis></para></entry>
  1238.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1239.         <entry><para><emphasis>&apos;</emphasis></para></entry>
  1240.       </row>
  1241.       <row>
  1242.         <entry><para><emphasis>&</emphasis></para></entry>
  1243.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1244.         <entry><para><emphasis>&amp;</emphasis></para></entry>
  1245.       </row>
  1246.     </tbody>
  1247.   </tgroup>
  1248. </table>
  1249.  
  1250. <programlisting><![CDATA[  <comments>
  1251.     <en>
  1252.     I don't believe this:<p>
  1253.  
  1254.     <i>1200x1200 dpi only possible with Windows drivers,
  1255.     600x600 can be reached w/o particular software.
  1256.     The difference is visible, but only slightly, so
  1257.     the Functionality got "Mostly"<p></i><p>
  1258.  
  1259.     Do the following:<p>
  1260.  
  1261.     Set the resolution on the front panel to "Prores 1200", not
  1262.     to "Fastres 1200". When you use CUPS with HPs PPD file, turn
  1263.     off "Fastres 1200" in the printer configuration
  1264.     options.<p>
  1265.  
  1266.     Try the generic PostScript PPD file which comes with KUPS 1.0 or newer.
  1267.     </en>
  1268.   </comments>
  1269. </printer>]]></programlisting>
  1270.  
  1271. </section>
  1272.  
  1273. <section>
  1274. <title>A driver entry: "<ulink url="http://www.linuxprinting.org/show_driver.cgi?driver=md2k">md2k</ulink>" (<ulink url="http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db/db/source/driver/md2k.xml?rev=3.2&content-type=text/plain"><emphasis>db/source/driver/md2k.xml</emphasis></ulink>)</title>
  1275.  
  1276. <para>The driver files contain information about
  1277. drivers. There are a few things, but the two biggies are the prototype
  1278. and the printers list</para>
  1279.  
  1280. <programlisting><![CDATA[<driver id="driver/md2k">
  1281.  <name>md2k</name>]]></programlisting>
  1282.  
  1283. <para>According to the Adobe specifications for PPD files every PPD file
  1284. must contain a unique DOS-compatible file name (the "*PCFileName"),
  1285. a file name with an up to 8 characters log base name and an up to 3
  1286. characters long extension, and upper and lower case letters being
  1287. considered as equal. As every PPD file is for a printer/driver combo,
  1288. we let the last 2 characters being provided by the driver entry:</para>
  1289.  
  1290. <programlisting><![CDATA[ <pcdriver>M2</pcdriver>
  1291.  <url>http://plaza26.mbn.or.jp/~higamasa/gdevmd2k/</url>
  1292.  <execution>]]></programlisting>
  1293.  
  1294. <para>Driver types are:</para>
  1295.  
  1296. <table frame="all">
  1297. <title></title>
  1298. <tgroup cols="0">
  1299.   <tbody>
  1300.     <row>
  1301.       <entry><para><emphasis><ghostscript /></emphasis>:  </para></entry>
  1302.       <entry><para>The driver code is compiled into GhostScript</para></entry>
  1303.     </row>
  1304.     <row>
  1305.       <entry><para><emphasis><filter /></emphasis>:  </para></entry>
  1306.       <entry><para>The driver code is a separate executable, either a filter which
  1307.         converts generic bitmap output of GhostScript to the printer's
  1308.         language, a wrapper around GhostScript, or an IJS plug-in.</para></entry>
  1309.     </row>
  1310.     <row>
  1311.       <entry><para><emphasis><uniprint /></emphasis>:  </para></entry>
  1312.       <entry><para>A uniprint driver, consisting of one or more .upp files for
  1313.         GhostScript.</para></entry>
  1314.     </row>
  1315.     <row>
  1316.       <entry><para><emphasis><postscript /></emphasis>:  </para></entry>
  1317.       <entry><para>A driver which has PostScript also as output (for PostScript
  1318.         printers). It usually does not call GhostScript but only applies the
  1319.         user's option settings to the data stream. But GhostScript can be
  1320.         called here, too, as for downgrading to a lower PostScript level.</para></entry>
  1321.     </row>
  1322.   </tbody>
  1323. </tgroup>
  1324. </table>
  1325.  
  1326. <para>The driver type only provides information for the
  1327. web pages, it is not used when generating config files for a
  1328. spooler.</para>
  1329.  
  1330. <programlisting><![CDATA[  <ghostscript />]]></programlisting>
  1331.  
  1332. <para>The driver's <execution> section can also
  1333. contain a</para>
  1334.  
  1335. <programlisting><![CDATA[  <nopjl />]]></programlisting>
  1336.  
  1337. <para>which suppresses the usage of PJL options (options
  1338. which send PJL commands to the printer). This one does with drivers
  1339. where the driver itself already produces a PJL header, the second one
  1340. built by the PJL options would then be ignored by the printer, and so
  1341. this kind of options does not make sense. Such drivers are for example
  1342. "hpijs" and "hl1250".</para>
  1343.  
  1344. <para>The prototype defines what command the backends run
  1345. to drive this printer.  It must take postscript on stdin and generate
  1346. "printer stuff" on stdout.  Various %A, %B, etc substitution "spots"
  1347. are specified; this is where substitution options will be placed.</para>
  1348.  
  1349. <programlisting><![CDATA[  <prototype>gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sDEVICE=md2k%A%Z -sOutputFile=- -</prototype>
  1350.  </execution>
  1351.  <comments>
  1352.   <en>
  1353.     Part of the gdevmd2k-0.2a package by Shinya Umino.  The web page and
  1354.     documentation are in Japanese.
  1355.     <a href="/clippings/MD5000-translation.txt">Here</a>
  1356.     is an English translation of the driver's web page, and <a
  1357.     href="/clippings/alpsmd.txt">here</a> is the README from the
  1358.     driver package.
  1359.   </en>
  1360.  </comments>]]></programlisting>
  1361.  
  1362. <para>The printer list is a simple list of printers that
  1363. this driver works with.  Historically, these "bits" were on the
  1364. printer cgi form page, but now they're put here.</para>
  1365.  
  1366. <programlisting><![CDATA[ <printers>
  1367.   <printer>
  1368.    <id>printer/Alps-MD-1000</id><!-- Alps MD-1000 -->
  1369.   </printer>
  1370.   <printer>
  1371.    <id>printer/Alps-MD-1300</id><!-- Alps MD-1300 -->
  1372.   </printer>
  1373.   <printer>
  1374.    <id>printer/Alps-MD-2000</id><!-- Alps MD-2000 -->
  1375.   </printer>
  1376.   <printer>
  1377.    <id>printer/Alps-MD-4000</id><!-- Alps MD-4000 -->
  1378.   </printer>
  1379.  </printers>
  1380. </driver>]]></programlisting>
  1381.  
  1382. <para>In the printer list it is also possible to place
  1383. comments specific to a certain printer/driver pair:</para>
  1384.  
  1385. <programlisting><![CDATA[  <printer>
  1386.    <id>printer/HP-LaserJet_4050</id><!-- HP LaserJet 4050 -->
  1387.    <comments>
  1388.     <en>to 1200dpi</en>
  1389.    </comments>
  1390.   </printer>]]></programlisting>
  1391.  
  1392. </section>
  1393.  
  1394. <section>
  1395. <title>Composite Options</title>
  1396.  
  1397. <para>This is an option type to make it easier for users
  1398. to choose the best settings for a certain printing task, even if the
  1399. driver has very many options. The idea is to have an enumerated choice
  1400. option which does not directly modify something in the driver's
  1401. command line but sets several of the other options.</para>
  1402.  
  1403. <para>One example is the "PrintoutMode" option which will
  1404. be made available for all printer/driver combos which have at least
  1405. one option regarding the printout quality or document type.</para>
  1406.  
  1407. <para>The possible choices should be the same for every
  1408. printer and driver, so that users (especially newbies) can bring their
  1409. printers in the right mode by choosing one easy to understand item
  1410. from a menu instead of having to switch several cryptic driver
  1411. options. For now the choices are the following:</para>
  1412.  
  1413.   <table frame="all">
  1414. <title></title>
  1415. <tgroup cols="0">
  1416.     <tbody>
  1417.       <row>
  1418.         <entry><para><emphasis>Command line</emphasis></para></entry><entry><para><emphasis>GUI</emphasis></para></entry>
  1419.     <entry><para><emphasis>Intention</emphasis></para></entry>
  1420.       </row>
  1421.       <row>
  1422.         <entry><para><emphasis>Draft</emphasis></para></entry><entry><para>Draft</para></entry>
  1423.     <entry><para>Very fast, ink/toner-saving printout</para></entry>
  1424.       </row>
  1425.       <row>
  1426.         <entry><para><emphasis>Normal</emphasis></para></entry><entry><para>Normal</para></entry>
  1427.     <entry><para>Quick standard quality printout</para></entry>
  1428.       </row>
  1429.       <row>
  1430.     <entry><para><emphasis>High</emphasis></para></entry><entry><para>High Quality</para></entry>
  1431.     <entry><para>High quality for plain paper</para></entry>
  1432.       </row>
  1433.       <row>
  1434.         <entry><para><emphasis>VeryHigh</emphasis></para></entry><entry><para>Very High Quality</para></entry>
  1435.     <entry><para>Highest quality for plain/inkjet paper</para></entry>
  1436.       </row>
  1437.       <row>
  1438.         <entry><para><emphasis>Photo</emphasis></para></entry><entry><para>Photo</para></entry>
  1439.     <entry><para>Highest quality for photo paper</para></entry>
  1440.       </row>
  1441.     </tbody>
  1442.   </tgroup>
  1443. </table>
  1444.  
  1445. <para>These choices can also have one of the following
  1446. modifiers:</para>
  1447.  
  1448.   <table frame="all">
  1449. <title></title>
  1450. <tgroup cols="0">
  1451.     <tbody>
  1452.       <row>
  1453.         <entry><para><emphasis>Modifier</emphasis></para></entry><entry><para><emphasis>Intention</emphasis></para></entry>
  1454.       </row>
  1455.       <row>
  1456.         <entry><para><emphasis>.Gray</emphasis></para></entry>
  1457.     <entry><para>Grayscale printing on a color printer</para></entry>
  1458.       </row>
  1459.       <row>
  1460.         <entry><para><emphasis>.Mono</emphasis></para></entry>
  1461.     <entry><para>Monochrome printing (no grayscales, black or white)</para></entry>
  1462.       </row>
  1463.     </tbody>
  1464.   </tgroup>
  1465. </table>
  1466.  
  1467. <para>Examples:</para>
  1468.  
  1469.   <table frame="all">
  1470. <title></title>
  1471. <tgroup cols="0">
  1472.     <tbody>
  1473.       <row>
  1474.         <entry><para><emphasis>Command line</emphasis></para></entry>
  1475.     <entry><para><emphasis>GUI</emphasis></para></entry><entry><para><emphasis>Comment</emphasis></para></entry>
  1476.       </row>
  1477.       <row>
  1478.         <entry><para><emphasis>High.Gray</emphasis></para></entry>
  1479.     <entry><para>High Quality Grayscale</para></entry><entry></entry>
  1480.       </row>
  1481.       <row>
  1482.         <entry><para><emphasis>Photo</emphasis></para></entry>
  1483.     <entry><para>Photo</para></entry><entry><para>Color photos on color printer</para></entry>
  1484.       </row>
  1485.       <row>
  1486.         <entry><para><emphasis>VeryHigh.Mono</emphasis></para></entry>
  1487.     <entry><para>Very High Quality Monochrome</para></entry>
  1488.     <entry><para>Really black text in highest quality on inkjet printer,
  1489.             not suitable for halftone images.</para></entry>
  1490.       </row>
  1491.       <row>
  1492.         <entry><para><emphasis>Normal</emphasis></para></entry>
  1493.     <entry><para>Normal</para></entry>
  1494.     <entry><para>Standard color in 300/360 dpi on normal paper, grayscale
  1495.             on black-and-white printers</para></entry>
  1496.       </row>
  1497.     </tbody>
  1498.   </tgroup>
  1499. </table>
  1500.  
  1501. <para>Not all choices/combinations of basic choices and
  1502. modifiers must be present. Often modes are simply not available on
  1503. certain printer/driver combos, as "Photo" on most lasers. It is highly
  1504. recommended to have "Normal" available, though (and having this the
  1505. default).</para>
  1506.  
  1507. <para>The GUI names can have additional remarks in
  1508. parantheses, for example when manual intervention (other cartridge,
  1509. photo paper) is needed.</para>
  1510.  
  1511. <para>To add such an option to the database, one only
  1512. needs to add an option XML file like the one below into the
  1513. db/source/opt directory of the database. The file
  1514. db/source/opt/pcl3-PrintoutMode.xml could look like this:</para>
  1515.  
  1516. <programlisting><![CDATA[<option type="enum" id="opt/pcl3-PrintoutMode">
  1517.   <!-- A multilingual <comments> block can appear here, too;
  1518.        it should be treated as documentation for the user. -->
  1519.   <arg_longname>
  1520.    <en>Printout Mode</en>
  1521.   </arg_longname>
  1522.   <arg_shortname>
  1523.    <en>PrintoutMode</en><!-- backends only know <en> shortnames! -->
  1524.   </arg_shortname>
  1525.   <arg_execution>
  1526.    <arg_order>10</arg_order>
  1527.    <arg_section>AnySetup</arg_section>
  1528.    <arg_spot>A</arg_spot>
  1529.    <arg_composite />
  1530.    <!-- <arg_proto></arg_proto> -->
  1531.   </arg_execution>
  1532.   <constraints>
  1533.      <constraint sense="true">
  1534.       <driver>pcl3</driver>
  1535.       <arg_defval>ev/pcl3-PrintoutMode-Normal</arg_defval>
  1536.      </constraint>
  1537.   </constraints>
  1538.   <enum_vals>
  1539.    <enum_val id="ev/pcl3-PrintoutMode-Draft">
  1540.     <ev_longname>
  1541.      <en>Draft</en>
  1542.     </ev_longname>
  1543.     <!-- A multilingual <comments> block can appear here, too;
  1544.          it should be treated as documentation for the user. -->
  1545.     <ev_shortname>
  1546.      <en>Draft</en>
  1547.      <!-- Until someone tells me how to learn the user locale in
  1548.           backends, the shortname must be monolingual in <en>! -->
  1549.     </ev_shortname>
  1550.     <ev_driverval>MediaType=Plain Resolution=150 Quality=Draft IntensityRendering=Halftones Passes=1</ev_driverval>
  1551.    </enum_val>
  1552.    <enum_val id="ev/pcl3-PrintoutMode-Normal">
  1553.     <ev_longname>
  1554.      <en>Normal</en>
  1555.     </ev_longname>
  1556.     <!-- A multilingual <comments> block can appear here, too;
  1557.          it should be treated as documentation for the user. -->
  1558.     <ev_shortname>
  1559.      <en>Normal</en>
  1560.      <!-- Until someone tells me how to learn the user locale in
  1561.           backends, the shortname must be monolingual in <en>! -->
  1562.     </ev_shortname>
  1563.     <ev_driverval>MediaType=Plain Resolution=300 Quality=Normal IntensityRendering=Halftones Passes=1</ev_driverval>
  1564.    </enum_val>
  1565.    <enum_val id="ev/pcl3-PrintoutMode-High">
  1566.     <ev_longname>
  1567.      <en>High</en>
  1568.     </ev_longname>
  1569.     <!-- A multilingual <comments> block can appear here, too;
  1570.          it should be treated as documentation for the user. -->
  1571.     <ev_shortname>
  1572.      <en>High</en>
  1573.      <!-- Until someone tells me how to learn the user locale in
  1574.           backends, the shortname must be monolingual in <en>! -->
  1575.     </ev_shortname>
  1576.     <ev_driverval>MediaType=Plain Resolution=600 Quality=Presentation IntensityRendering=FloydSteinberg Passes=4</ev_driverval>
  1577.    </enum_val>
  1578.    <enum_val id="ev/pcl3-PrintoutMode-Photo">
  1579.     <ev_longname>
  1580.      <en>Photo (on photo paper)</en>
  1581.     </ev_longname>
  1582.     <!-- A multilingual <comments> block can appear here, too;
  1583.          it should be treated as documentation for the user. -->
  1584.     <ev_shortname>
  1585.      <en>Photo</en>
  1586.      <!-- Until someone tells me how to learn the user locale in
  1587.           backends, the shortname must be monolingual in <en>! -->
  1588.     </ev_shortname>
  1589.     <ev_driverval>MediaType=Premium Resolution=600 Quality=Presentation IntensityRendering=FloydSteinberg Passes=4</ev_driverval>
  1590.    </enum_val>
  1591.   </enum_vals>
  1592. </option>]]></programlisting>
  1593.  
  1594. <para>The shown option is only an example, it is neither
  1595. in the CVS nore will it work with all printers which use the "pcl3"
  1596. driver. You can paste it into a file (make the <ev_driverval>s
  1597. being one line, the items separated by spaces) and copy it to
  1598. db/source/opt/ to try it out.</para>
  1599.  
  1600. <para>The "<arg_composite />" tag for the execution
  1601. style specifies it as a composite option. The <arg_spot> and
  1602. <arg_proto> are meaningless in a composite option and the
  1603. "<ev_driverval>"s contain a space-separated list of all settings
  1604. of which the pre-made configuration represented by this choice
  1605. consists. Every choice of the composite option must set <emphasis>exactly
  1606. the same</emphasis> individual options. In no choice it is allowed to leave
  1607. out one of them. These individual options are the member options of
  1608. the composite option. Not all options of a driver/printer combo need
  1609. to be member options of the composite option. It is not allowed to
  1610. have one option being member of more than one composite option. The
  1611. composite option must be an enumerated choice options, the member
  1612. options must be enumerated choice or boolean.</para>
  1613.  
  1614. <para>It is enough to add a composite option as
  1615. shown. The PPD generator (getppd() in lib/Foomatic/DB.pm, package
  1616. "foomatic-db-engine") will take care of the rest. It will</para>
  1617.  
  1618. <itemizedlist>
  1619.  
  1620.   <listitem><para>Order all member options into a group (PPD group, see "Option
  1621.       Grouping" below) named after the composite option.</para></listitem>
  1622.  
  1623.   <listitem><para>Add to every member option the choice "Controlled by '<name
  1624.       of the composite option>'" and make this choice the
  1625.       default. If this is chosen, the composite option will set the
  1626.       value for this member, depending on what value is chosen for the
  1627.       composite option. If the user chooses something else than
  1628.       "Controlled by '<name of the composite option>'" the
  1629.       member option does not obey the setting given by the composite
  1630.       option. So the advanced user can also set the member options
  1631.       individually.</para></listitem>
  1632.  
  1633.   <listitem><para>If necessary the <arg_order> and <arg_section> of
  1634.       the composite option is replaced by other values in the PPD
  1635.       file, so that the composite option will be stuffed into the
  1636.       PostScript data stream always before all its member options. Do
  1637.       not give "0" as the order number to any of the member
  1638.       options.</para></listitem>
  1639.  
  1640. </itemizedlist>
  1641.  
  1642. <para>A composite option can also span only one (but not
  1643. zero) member option. This is for example done with the "PrintoutMode"
  1644. option of the HPIJS driver ("foomatic-db-hpijs" package). This driver
  1645. has only one option for setting resolution and quality, but this
  1646. options has sometimes many choices with rather cryptic names. The
  1647. "PrintoutMode" maps to the most important choices with the
  1648. above-mentioned names, and in addition, these names are the same as of
  1649. the "PrintoutMode" options of other drivers, so the user finds the
  1650. important printing modes more easily.</para>
  1651.  
  1652. <para>The facility of composite options can also be used
  1653. for other things than for a "PrintoutMode" option, for example a
  1654. finisher could be controlled by a composite option (to have the most
  1655. common finishing tasks as "Bound booklet", "Stapled booklet", "Letter
  1656. in envelope", ...).</para>
  1657.  
  1658. </section>
  1659.  
  1660. <section>
  1661. <title>Forced Composite Options</title>
  1662.  
  1663. <para>Forced composite options are very similar to
  1664. composite options, but the user cannot set the individual member
  1665. options, but only the composite option (the user is forced to use the
  1666. composite option). This allows options acting at two or more
  1667. places.</para>
  1668.  
  1669. <para>Example: A printer driver is a filter which
  1670. converts a generic bitmap produced by GhostScript to the printer's
  1671. native format. The command line for converting PostScript to the
  1672. printer's language could look like this</para>
  1673.  
  1674. <programlisting><![CDATA[   gs -q -dBATCH -dSAFER -dNOPAUSE -sDEVICE=bitcmyk -r600 -sOutputFile=- - | filter -size=<width>x<height>]]></programlisting>
  1675.  
  1676. <para>where <width> and <height> is the page
  1677. size in points (1/72 inches). In addition, GhostScript needs to know
  1678. the page size. For this one usually puts the following PostScript code
  1679. into the PostScript input file:</para>
  1680.  
  1681. <programlisting><![CDATA[   <</PageSize[<width> <height>]/ImagingBBox null>>setpagedevice]]></programlisting>
  1682.  
  1683. <para>where <width> and <height> is again the
  1684. page size in points. So we need two options for setting the page size,
  1685. one PostScript option to set the page size for GhostScript and one
  1686. command line option to set the page size for the filter. The user
  1687. would have to change both when he wants to print on another paper
  1688. size, and it does not make sense to have different settings for the
  1689. two. So one could make the "PageSize" option a composite option of the
  1690. two, but then the GUI exposes an ugly "PageSize" group with the two
  1691. individual options. To avoid this, one uses a forced composite option
  1692. ("Forced" because the user is forced to use the composite option, the
  1693. individual member options are not accessible).</para>
  1694.  
  1695. <para>Assuming that the name of the PostScript option for
  1696. the page size is "GSPageSize", the name of the page size option for
  1697. the filter is "filterPageSize" and both have the choices "A4",
  1698. "Letter", and "Legal", the forced composite option named "PageSize"
  1699. would look as follows:</para>
  1700.  
  1701. <programlisting><![CDATA[<option type="enum" id="opt/filter-PageSize">
  1702.   <!-- A multilingual <comments> block can appear here, too;
  1703.        it should be treated as documentation for the user. -->
  1704.   <arg_longname>
  1705.    <en>Page Size</en>
  1706.   </arg_longname>
  1707.   <arg_shortname>
  1708.    <en>PageSize</en><!-- backends only know <en> shortnames! -->
  1709.   </arg_shortname>
  1710.   <arg_execution>
  1711.    <arg_order>10</arg_order>
  1712.    <arg_section>AnySetup</arg_section>
  1713.    <arg_spot>A</arg_spot>
  1714.    <arg_forced_composite />
  1715.   </arg_execution>
  1716.   <constraints>
  1717.      <constraint sense="true">
  1718.       <driver>filter</driver>
  1719.       <arg_defval>ev/filter-PageSize-Letter</arg_defval>
  1720.      </constraint>
  1721.   </constraints>
  1722.   <enum_vals>
  1723.    <enum_val id="ev/filter-PageSize-Letter">
  1724.     <ev_longname>
  1725.      <en>Letter</en>
  1726.     </ev_longname>
  1727.     <!-- A multilingual <comments> block can appear here, too;
  1728.          it should be treated as documentation for the user. -->
  1729.     <ev_shortname>
  1730.      <en>Letter</en>
  1731.      <!-- Until someone tells me how to learn the user locale in
  1732.           backends, the shortname must be monolingual in <en>! -->
  1733.     </ev_shortname>
  1734.     <ev_driverval>GSPageSize=Letter filterPageSize=Letter</ev_driverval>
  1735.    </enum_val>
  1736.    <enum_val id="ev/filter-PageSize-Legal">
  1737.     <ev_longname>
  1738.      <en>Legal</en>
  1739.     </ev_longname>
  1740.     <!-- A multilingual <comments> block can appear here, too;
  1741.          it should be treated as documentation for the user. -->
  1742.     <ev_shortname>
  1743.      <en>Legal</en>
  1744.      <!-- Until someone tells me how to learn the user locale in
  1745.           backends, the shortname must be monolingual in <en>! -->
  1746.     </ev_shortname>
  1747.     <ev_driverval>GSPageSize=Legal filterPageSize=Legal</ev_driverval>
  1748.    </enum_val>
  1749.    <enum_val id="ev/filter-PageSize-A4">
  1750.     <ev_longname>
  1751.      <en>A4</en>
  1752.     </ev_longname>
  1753.     <!-- A multilingual <comments> block can appear here, too;
  1754.          it should be treated as documentation for the user. -->
  1755.     <ev_shortname>
  1756.      <en>A4</en>
  1757.      <!-- Until someone tells me how to learn the user locale in
  1758.           backends, the shortname must be monolingual in <en>! -->
  1759.     </ev_shortname>
  1760.     <ev_driverval>GSPageSize=A4 filterPageSize=A4</ev_driverval>
  1761.    </enum_val>
  1762.   </enum_vals>
  1763. </option>]]></programlisting>
  1764.  
  1765. <para>This looks exactly like a usual composite option
  1766. and works also the same way. The only difference is that instead of an
  1767. "<arg_composite />" tag "<arg_forced_composite />" is
  1768. used. If the PPD generator finds such an option, it hides the member
  1769. options by only using "*Foomatic..." keywords to describe them, not
  1770. any standard PPD keywords as "*OpenUI...", "*OrderDependency...",
  1771. ... This way PPD-aware graphical frontends do not see the member
  1772. options but "<emphasis>foomatic-rip</emphasis>" has all information from them to
  1773. run the driver correctly.</para>
  1774.  
  1775. </section>
  1776.  
  1777. <section>
  1778. <title>String and Password Options</title>
  1779.  
  1780. <para>These options allow the user to supply nearly
  1781. arbitrary strings (within limits of length, characters and structure)
  1782. to the printer driver, for example names of color calibration files,
  1783. fax numbers, passwords for confidential jobs, ... Frequently needed
  1784. strings can be added as enumerated choices, so a frontend can show the
  1785. option as a combo-box. The enumerated choices are also used for
  1786. frontends which only support options as defined by the PPD spec. So
  1787. having enumerated choices is highly recommended for most of these
  1788. options.</para>
  1789.  
  1790. <para>In the XML database string and password options
  1791. look similar to enumerated choice options. The differences are the
  1792. option types "string" or "password" and the additional tags to
  1793. restrict the possible strings.</para>
  1794.  
  1795. <para>The "<arg_maxlength>" tags give a length
  1796. limit, it should once not allow strings longer than around 100
  1797. characters, as otherwise foomatic-configure could generate a line
  1798. longer than the allowed 255 characters in the PPD file when setting
  1799. the default value, and second, which is very important, it should not
  1800. allow strings which are too long for the printer filter or driver so
  1801. that buffer overflows cannot occur. Not using the
  1802. "<arg_maxlength>" tags makes arbitrary long strings to be
  1803. accepted, this is not recommended.</para>
  1804.  
  1805. <para>With "<arg_allowedchars>" the accepted
  1806. strings can be restricted to contain only the characters given in the
  1807. list. This restrictions does not only avoid that the filter chokes on
  1808. a wrong option, it serves mainly for security reasons, for example to
  1809. avoid a string like "|| rm -rf * ||" for a command line option. So if
  1810. the option prototype does not quote the string, command delimiter
  1811. characters, I/O re-directors, and shell special characters (";", "|",
  1812. "&", "<", ">", "*", "?", "[", "]", "{", "}", "(", ")", "$",
  1813. "\", "'", """) should not be allowed. If the string is quoted by
  1814. the option prototype, the closing quote character and the backslash
  1815. should not be allowed, so that one cannot escape from the quoting. The
  1816. allowed characters are checked by a "/^[...]*$/" expression in the
  1817. Perl scripts, so ranges with "-", a list of forbidden characters with
  1818. a leading "^", or special characters as "\w", "\d", "\x07", ...  are
  1819. allowed. To allow a backslash, one has to escape it by using two
  1820. backslashes ("\\").</para>
  1821.  
  1822. <para>"<arg_allowedregexp>" allows also to restrict
  1823. the structure of the string, as it defines an arbitrary Perl regular
  1824. expression (see "man perlre") which has to be matched by the
  1825. string. This serves also for having only strings which are usable by
  1826. the filter and which do not destroy the command line structure. With
  1827. this one can for example forbid a backslash as the last character to
  1828. avoid escaping the closing quote of the option prototype. Regular
  1829. expressions are applied via a '/.../' expression in the Perl
  1830. scripts. To apply the pattern matching modifiers "i", "m", "s", or "x"
  1831. (as "/.../i" for case-insensitive matching) begin the regular
  1832. expression with "(?<modifiers>)" (as "(?i)..." for
  1833. case-insensitive matching).</para>
  1834.  
  1835. <para>It is highly recommended to use at least one of
  1836. "<arg_allowedchars>" and "<arg_allowedregexp>", as
  1837. otherwise all characters are allowed in the user-supplied string and
  1838. so a malicious user can execute arbitrary shell or PostScript
  1839. commands. If both tags are used, both conditions have to be
  1840. fulfilled.</para>
  1841.  
  1842. <para>Note that for the character lists and regular
  1843. expressions in the XML files the following character substitutions
  1844. have to be done:</para>
  1845.  
  1846.   <table frame="none">
  1847. <title></title>
  1848. <tgroup cols="0">
  1849.     <tbody>
  1850.       <row>
  1851.         <entry><para><emphasis><</emphasis></para></entry>
  1852.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1853.         <entry><para><emphasis>&lt;</emphasis></para></entry>
  1854.       </row>
  1855.       <row>
  1856.         <entry><para><emphasis>></emphasis></para></entry>
  1857.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1858.         <entry><para><emphasis>&gt;</emphasis></para></entry>
  1859.       </row>
  1860.       <row>
  1861.         <entry><para><emphasis>"</emphasis></para></entry>
  1862.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1863.         <entry><para><emphasis>&quot;</emphasis></para></entry>
  1864.       </row>
  1865.       <row>
  1866.         <entry><para><emphasis>'</emphasis></para></entry>
  1867.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1868.         <entry><para><emphasis>&apos;</emphasis></para></entry>
  1869.       </row>
  1870.       <row>
  1871.         <entry><para><emphasis>&</emphasis></para></entry>
  1872.         <entry><para><emphasis>  -->  </emphasis></para></entry>
  1873.         <entry><para><emphasis>&amp;</emphasis></para></entry>
  1874.       </row>
  1875.     </tbody>
  1876.   </tgroup>
  1877. </table>
  1878.  
  1879. <para>Here is an example for an option to supply the file
  1880. name for an ICC profile for the "foo2zjs" driver (this option is
  1881. neither in the CVS for the Foomatic database nor tested with this
  1882. driver):</para>
  1883.  
  1884. <programlisting><![CDATA[<option type="string" id="opt/foo2zjs-ICM">
  1885.     <comments>
  1886.     <en>
  1887.     This option controls which .ICM file to use for color correction.
  1888.     ICM files are stored in the directory /usr/share/foo2zjs/icm/.
  1889.     </en>
  1890.     </comments>
  1891.     <arg_longname> <en>ICM Color Profile</en> </arg_longname>
  1892.     <arg_shortname> <en>ICM</en> </arg_shortname>
  1893.     <arg_execution>
  1894.     <arg_group>Adjustment</arg_group>
  1895.     <arg_order>300</arg_order>
  1896.     <arg_spot>A</arg_spot>
  1897.     <arg_required />
  1898.     <arg_substitution />
  1899.     <arg_proto>-G%s </arg_proto>
  1900.     </arg_execution>
  1901.     <arg_maxlength>127</arg_maxlength>
  1902.     <arg_allowedchars>A-Za-z0-9\._-/</arg_allowedchars>
  1903.     <arg_allowedregexp>(?<!\/)$</arg_allowedregexp>
  1904.     <constraints>
  1905.     <constraint sense="true">
  1906.         <driver>foo2zjs</driver>
  1907.         <arg_defval>ev/foo2zjs-ICM-none</arg_defval>
  1908.     </constraint>
  1909.     <constraint sense="true">
  1910.         <make>Minolta</make>
  1911.         <model>magicolor 2300 DL</model>
  1912.         <driver>foo2zjs</driver>
  1913.         <arg_defval>ev/foo2zjs-ICM-DL2312</arg_defval>
  1914.     </constraint>
  1915.     <constraint sense="true">
  1916.         <make>Minolta</make>
  1917.         <model>magicolor 2200 DL</model>
  1918.         <driver>foo2zjs</driver>
  1919.         <arg_defval>ev/foo2zjs-ICM-DL2200RGB</arg_defval>
  1920.     </constraint>
  1921.     </constraints>
  1922.     <enum_vals>
  1923.     <enum_val id="ev/foo2zjs-ICM-none">
  1924.         <ev_longname> <en>No ICM color correction</en> </ev_longname>
  1925.         <ev_shortname> <en>None</en> </ev_shortname>
  1926.         <ev_driverval></ev_driverval>
  1927.     </enum_val>
  1928.     <enum_val id="ev/foo2zjs-ICM-DL2312">
  1929.         <ev_longname> <en>File DL2312.icm</en> </ev_longname>
  1930.         <ev_shortname> <en>DL2312</en> </ev_shortname>
  1931.         <ev_driverval>DL2312.icm</ev_driverval>
  1932.         <constraints>
  1933.             <constraint sense="false">
  1934.                 <make>HP</make> <model>LaserJet 1000</model>
  1935.             </constraint>
  1936.         </constraints>
  1937.     </enum_val>
  1938.     <enum_val id="ev/foo2zjs-ICM-DL2324">
  1939.         <ev_longname> <en>File DL2324.icm</en> </ev_longname>
  1940.         <ev_shortname> <en>DL2324</en> </ev_shortname>
  1941.         <ev_driverval>DL2324.icm</ev_driverval>
  1942.         <constraints>
  1943.             <constraint sense="false">
  1944.                 <make>HP</make> <model>LaserJet 1000</model>
  1945.             </constraint>
  1946.         </constraints>
  1947.     </enum_val>
  1948.  
  1949.     ...
  1950.  
  1951.     </enum_vals>
  1952. </option>]]></programlisting>
  1953.  
  1954. <para>This option allows to choose either one of the
  1955. given file names, either by using the "<ev_shortname>"s or the
  1956. "<ev_driverval>"s, or one can give every arbitrary other file
  1957. name with a maximum length of 127 characters, only containing letters,
  1958. digits, periods, underscores, dashes, and slashes, and not having a
  1959. slash in the end (no directories). Note that in Perl the period must
  1960. be escaped by a backslash to be taken literally, otherwise it stands
  1961. for an arbitrary character. The regukar expression for blocking out
  1962. strings ending with a slash is "(?<!\/)$" (see "man perlre", search
  1963. for "(?"). Here the slash is quoted by a backslash. In the XML file
  1964. the "<" is replaced by "&lt;" so that the XML structure does
  1965. not get broken. "<emphasis>foomatic-rip</emphasis>" translates this back before
  1966. applying the regular expression.</para>
  1967.  
  1968. <para>To be able to offer strings as an enumerated choice
  1969. which are not allowed as an option name in a PPD file, the
  1970. "<ev_shortname>" may differ from the "<ev_driverval>", the
  1971. string inserted at the "%s" place holder in the "<arg_proto>" is
  1972. always the "<ev_driverval>", independent whether the user
  1973. supplies the "<ev_driverval>" directly or the
  1974. "<ev_shortname>". In this example both</para>
  1975.  
  1976. <programlisting><![CDATA[   lpr -o ICM= file.ps]]></programlisting>
  1977.  
  1978. <para>and</para>
  1979.  
  1980. <programlisting><![CDATA[   lpr -o ICM=None file.ps]]></programlisting>
  1981.  
  1982. <para>supply an empty string as the value of the ICM
  1983. option.</para>
  1984.  
  1985. <para>For the default value there must be an enumerated
  1986. choice, if there is none, the PPD generator will create one. So this
  1987. entry is allowed (this option is only an example, it is not in the CVS
  1988. of the Foomatic database):</para>
  1989.  
  1990. <programlisting><![CDATA[<option type="password" id="opt/Password">
  1991.   <!-- A multilingual <comments> block can appear here, too;
  1992.        it should be treated as documentation for the user. -->
  1993.   <arg_longname>
  1994.    <en>Password (for confidential jobs)</en>
  1995.   </arg_longname>
  1996.   <arg_shortname>
  1997.    <en>Password</en><!-- backends only know <en> shortnames! -->
  1998.   </arg_shortname>
  1999.   <arg_execution>
  2000.    <arg_group>General</arg_group>
  2001.    <arg_order>100</arg_order>
  2002.    <arg_spot>B</arg_spot>
  2003.    <arg_substitution />
  2004.    <arg_proto> --pass=%s</arg_proto>
  2005.   </arg_execution>
  2006.   <arg_maxlength>30</arg_maxlength>
  2007.   <arg_allowedchars>A-Za-z0-9\.,_\+\=\:-\/</arg_allowedchars>
  2008.   <constraints>
  2009.      <constraint sense='true'>
  2010.       <driver>mydriver</driver>
  2011.       <arg_defval></arg_defval>
  2012.      </constraint>
  2013.   </constraints>
  2014. </option>]]></programlisting>
  2015.  
  2016. <para>The default value is an empty string here. So the
  2017. PPD generator will add a choice for the empty string.</para>
  2018.  
  2019. <para>Normally, automatically added choices get the same
  2020. "<ev_shortname>" as the string itself, but if the string is not
  2021. allowed as an option name in a PPD file, the "<ev_shortname>"
  2022. will be modified. For an empty string (as in the example above) "None"
  2023. will be used and all characters except numbers, letters, and
  2024. underscores ("_") will be replaced by underscores.</para>
  2025.  
  2026. <para>The option types "string" and "password" are
  2027. treated exactly the same way by the PPD generator and by
  2028. "<emphasis>foomatic-rip</emphasis>", the different names are only for frontends to
  2029. know whether the input field should display the typed characters or
  2030. asterisks on the screen.</para>
  2031.  
  2032. </section>
  2033.  
  2034. <section>
  2035. <title>Option Grouping</title>
  2036.  
  2037. <para>All options should be put in groups (with the tags
  2038. "<arg_group>...</arg_group>" in the
  2039. "<arg_execution>" section of the option XML files, see
  2040. above). This way many GUIs sort the options into tabs or tree branches
  2041. according to the groups. This way one gets only the most important
  2042. options on the first tab and not so often needed ones on additional
  2043. tabs. This also overrides the automatic option grouping of CUPS
  2044. (Groups "General" and "Extra").</para>
  2045.  
  2046. <para>It is recommended to have the options in groups as
  2047. follows (plus perhaps special groups, but not one group for every
  2048. option):</para>
  2049.  
  2050. <para>General</para>
  2051.  
  2052.   <para>Here go options which are most used on a
  2053.   job-by-job basis, as the options for paper type, size, and tray, ink
  2054.   type, duplex, ... and all options affecting the printout quality, as
  2055.   resolution, dithering, ... and especially "PrintoutMode". If a
  2056.   "PrintoutMode" option is present, all quality-related options
  2057.   covered by the "PrintoutMode" option go into the automatically
  2058.   created "PrintoutMode" group (see above). And this is intended,
  2059.   these options are now usually controlled by "PrintoutMode" and so
  2060.   they are not the most important options for the first tab any
  2061.   more.</para>
  2062.  
  2063.   <para>Do not put color/brightness/gamma, ... options
  2064.   here, they go to "Adjustment".</para>
  2065.  
  2066.   <para>Options typically to go here are:</para>
  2067.  
  2068.   <itemizedlist>
  2069.     <listitem><para>PageSize</para></listitem>
  2070.     <listitem><para>InputSlot</para></listitem>
  2071.     <listitem><para>MediaType</para></listitem>
  2072.     <listitem><para>InkType</para></listitem>
  2073.     <listitem><para>Duplex</para></listitem>
  2074.     <listitem><para>PrintoutMode</para></listitem>
  2075.     <listitem><para>Resolution</para></listitem>
  2076.     <listitem><para>REt</para></listitem>
  2077.     <listitem><para>Dither</para></listitem>
  2078.     <listitem><para>FastRes</para></listitem>
  2079.     <listitem><para>Economode</para></listitem>
  2080.     <listitem><para>...</para></listitem>
  2081.   </itemizedlist>
  2082.  
  2083.   <para>All options mentioned after "PrintoutMode" will
  2084.   usually be used as member options for "PrintoutMode", they are only
  2085.   in this group when there is no "PrintoutMode" option.</para>
  2086.  
  2087. <para>PrintoutMode</para>
  2088.  
  2089.   <para>This group only exists if there is a
  2090.   "PrintoutMode" option, because it is generated by this option. It
  2091.   contains the member options of "PrintoutMode". Typical candidates
  2092.   are</para>
  2093.  
  2094.   <itemizedlist>
  2095.     <listitem><para>Resolution</para></listitem>
  2096.     <listitem><para>REt</para></listitem>
  2097.     <listitem><para>Dither</para></listitem>
  2098.     <listitem><para>FastRes</para></listitem>
  2099.     <listitem><para>Economode</para></listitem>
  2100.     <listitem><para>...</para></listitem>
  2101.   </itemizedlist>
  2102.  
  2103.   <para>They do not need an
  2104.   "<arg_group>PrintoutMode</arg_group>" line, they are put
  2105.   into this group automatically. One should better put an
  2106.   "<arg_group>General</arg_group>" line into these
  2107.   options, so that they go into the "General" group when there is a
  2108.   printer/driver combo for which no "PrintoutMode" option applies.</para>
  2109.  
  2110. <para>Adjustment</para>
  2111.  
  2112.   <para>Options for correcting the appearance of colors,
  2113.   contrast, ..., for head alignment, ... etc. Here most numerical
  2114.   options will go, but also things like "Density", also if it is an
  2115.   enumerated choice option. Typical candidates are:</para>
  2116.  
  2117.   <itemizedlist>
  2118.     <listitem><para>Gamma</para></listitem>
  2119.     <listitem><para>Brightness</para></listitem>
  2120.     <listitem><para>Contrast</para></listitem>
  2121.     <listitem><para>Density</para></listitem>
  2122.     <listitem><para>Saturation</para></listitem>
  2123.     <listitem><para>Cyan</para></listitem>
  2124.     <listitem><para>Magenta</para></listitem>
  2125.     <listitem><para>Yellow</para></listitem>
  2126.     <listitem><para>...</para></listitem>
  2127.   </itemizedlist>
  2128.  
  2129. <para>Finishing</para>
  2130.  
  2131.   <para>If a printer has a stapler, folder, cutter,
  2132.   envelope packer, or similar devices to do additional processing on
  2133.   the ready printout, the options to control this stuff go into this
  2134.   group. Examples:</para>
  2135.  
  2136.   <itemizedlist>
  2137.     <listitem><para>Stapling</para></listitem>
  2138.     <listitem><para>Binding</para></listitem>
  2139.     <listitem><para>Cutting</para></listitem>
  2140.     <listitem><para>Booklet</para></listitem>
  2141.     <listitem><para>...</para></listitem>
  2142.   </itemizedlist>
  2143.  
  2144. <para>Miscellaneous</para>
  2145.  
  2146.   <para>Options which do not fit into the mentioned
  2147.   groups and for which it is not worth to make a special group.</para>
  2148.  
  2149. </section>
  2150.  
  2151. <section>
  2152. <title>Unprintable margins</title>
  2153.  
  2154. <para>On most printers you cannot print arbitrarily close
  2155. to the borders of the paper. You usually will have margins of certain
  2156. width on which you cannot print. For filters and application programs
  2157. to know about these margins PPD files have "*ImageableArea" lines
  2158. which define the positions of the lower, the upper, the left, and the
  2159. right borders of the area on which the printer can print. There is one
  2160. line for each paper size listed in the "*PageSize" option.</para>
  2161.  
  2162. <para>To conveniently generating these lines one can use
  2163. the following XML structure in the Foomatic database entries:</para>
  2164.  
  2165. <programlisting><![CDATA[<margins>
  2166.      <general>
  2167.        <!-- The margins here are valid for every paper size for -->
  2168.        <!-- which there is no "exception" section -->
  2169.        <!-- ---------- -->
  2170.        <!-- possible units: -->
  2171.        <!-- pt, inches, mm, cm,
  2172.        <!-- dotsNNNdpi (NNN: resolution in which dots are counted) -->
  2173.        <!-- if "unit" not present, default unit is pt -->
  2174.        <!-- ---------- -->
  2175.        <!-- if a margin is not present, default width is 0 -->
  2176.        <!-- ---------- -->
  2177.        <!-- a missing "general" section assumes zero borders as the -->
  2178.        <!-- general borders and "pt" as the default unit for -->
  2179.        <!-- "exceptions". -->
  2180.        <unit>pt</unit>
  2181.        <top>9</top>
  2182.        <bottom>36</bottom>
  2183.        <left>18</left>
  2184.        <right>18</right>
  2185.      </general>
  2186.      <exception PageSize="Photo4x6TearoffTab">
  2187.        <!-- if one or more of "unit", "top", "bottom", "left", -->
  2188.        <!-- "right" is missing, the appropriate item of the "general" -->
  2189.        <!-- section is used -->
  2190.        <top>0</top>
  2191.        <left>0</left>
  2192.        <right>0</right>
  2193.      </exception>
  2194.      <exception PageSize="A4">
  2195.        <!-- It is also possible to give absolute values in PostScript -->
  2196.        <!-- coordinates where the origin is the lower left corner. To -->
  2197.        <!-- do so, the <absolute /> tag has to be added, otherwise -->
  2198.        <!-- the values are the widths of the unprintable margins -->
  2199.        <absolute />
  2200.        <left>10</left>
  2201.        <right>585</right>
  2202.      </exception>
  2203.      <exception PageSize="...">
  2204.        ...
  2205.      </exception>
  2206.      ...
  2207. <margins>]]></programlisting>
  2208.  
  2209. <para>This structure is allowed in printer entries in the
  2210. "<mechanism>" section and in driver entries in the
  2211. "<execution>" section or inside a "<printer>" entry of the
  2212. driver's printer list. In the "<execution>" section of a driver
  2213. entry the margins are valid for all printers used with this driver, in
  2214. a "<printer>" entry they apply only to the given printer/driver
  2215. combo.</para>
  2216.  
  2217. <para>The shown example could be for the HP PhotoSmart
  2218. 7150/7350, which does full-bleed only on HP's special photo paper with
  2219. an 0.5 inch wide tear-off tab on the lower border (and some other
  2220. paper sizes used in the photo tray). On all other paper sizes the
  2221. printer leaves white borders of half an inch at the top and at the
  2222. bottom and a quarter of an inch on the left and right hand side (1
  2223. inch are 72 pt). In addition, the page size "A4" allows to print up to
  2224. 10 points to the left and the right borders.</para>
  2225.  
  2226. <para>At first we give the general borders
  2227. ("<general>" section) where we choose the unit "pt" (PostScript
  2228. points) for the numbers. These borders are valid for all paper sizes
  2229. which are not explicitly mentioned with an "<exception ...>"
  2230. section. For our printers one of the exceptions is the 4x6 photo paper
  2231. with the tear-off tab (including the tab the paper is 4x6.5 inches
  2232. large). here the printer prints up to the left, right, and top
  2233. borders. Therefore we have margins of zero here. At the lower border
  2234. the printer still leaves half an inch white (therefore probably HP
  2235. introduced the tear-off tab), so we keep the 36 pt of the
  2236. "<general>" section by not mentioning a new lower border. For A4
  2237. we redefine the left and the right border. This is also possible in
  2238. absolute PostScript coordinates measured from the lower left corner,
  2239. as we do here. We indicate this with the "<absolute />" tag. The
  2240. left border is at 10 pt from the left, and as A4 paper is 595 pt wide,
  2241. the right border is at 585 points from the left.</para>
  2242.  
  2243. <para>One hint for the choice of the units: Float numbers
  2244. as border widths are allowed, but it is recommended for having exact
  2245. info to choose a unit which gives integer numbers for the widths
  2246. (which is always possible with the "dotsNNNdpi" unit with NNN being
  2247. the maximum resolution of the printer).</para>
  2248.  
  2249. <para>A "<margins>" section in a printer entry
  2250. should represent the printer's hardware capabilities. Such a section
  2251. in a driver entry should represent how the driver's limitations
  2252. are. If there are margins defined in both the printer and the driver
  2253. entry of the desired printer/driver combo, the more restrictive
  2254. (wider) borders count. If there are no border definitions in both the
  2255. printer and the driver entry, the borders are assumed to be of zero
  2256. width (full-bleed).</para>
  2257.  
  2258. </section>
  2259.  
  2260. <section>
  2261. <title>Adding arbitrary extra entries to the PPD file</title>
  2262.  
  2263. <para>The "<ppdentry>" tags allow to add extra
  2264. lines to the PPD file. The tags can be put into the top level
  2265. ("<printer>") of a printer XML entry, into the
  2266. "<execution>" section of a driver XML entry, or into the
  2267. "<printer>" entries of the printer list in a driver XML
  2268. file. They serve mainly to put a default resolution into PPD files for
  2269. drivers without "Resolution" option. Examples:</para>
  2270.  
  2271. <para>"hpijs" driver, default resolution for HP DeskJet
  2272. 350. For this driver the default resolution depends on the printer
  2273. class. Therefore the appropriate "<ppdentry>"s have to be in the
  2274. printer entries of the printer list:</para>
  2275.  
  2276. <programlisting><![CDATA[<driver id="driver/hpijs">
  2277.   <name>hpijs</name>
  2278.   ...
  2279.   <printers>
  2280.    <printer>
  2281.     <id>printer/HP-DeskJet_350C</id><!-- HP DeskJet 350C -->
  2282.     <ppdentry>
  2283.       *DefaultResolution: 600dpi
  2284.     </ppdentry>
  2285.     <margins>
  2286.      <general>
  2287.       <unit>in</unit>
  2288.       <relative />
  2289.       <left>0.25</left>
  2290.       <right>0.25</right>
  2291.       <top>0.125</top>
  2292.       <bottom>0.67</bottom>
  2293.      </general>
  2294.      <exception PageSize="A4">
  2295.       <left>0.135</left>
  2296.       <right>0.135</right>
  2297.      </exception>
  2298.     </margins>
  2299.    </printer>
  2300.    ...
  2301.   </printers>
  2302. </driver>]]></programlisting>
  2303.  
  2304. <para>"pnm2ppa" driver: This driver has no "Resolution"
  2305. option, and all printers print in 600 dpi with it. So we put the
  2306. "<ppdentry>" into the "<execution>" section:</para>
  2307.  
  2308. <programlisting><![CDATA[<driver id="driver/pnm2ppa">
  2309.   <name>pnm2ppa</name>
  2310.   <url>http://sourceforge.net/projects/pnm2ppa/</url>
  2311.   <execution>
  2312.    <filter />
  2313.    <prototype>gs -q -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600%A%Z 
  2314. -sOutputFile=- - | pnm2ppa%C%B -i - -o -</prototype>
  2315.    <ppdentry>
  2316.     *DefaultResolution: 600dpi
  2317.    </ppdentry>
  2318.   </execution>
  2319.   ...
  2320. </driver>]]></programlisting>
  2321.  
  2322. <para>Note that leading spaces are removed from the lines
  2323. between the "<ppdentry>" tags before they get inserted into the
  2324. PPD file.</para>
  2325.  
  2326. <para>The lines are added at the end of the PPD file
  2327. header, right after the lines for the basic hardware capabilities of
  2328. the printer.</para>
  2329.  
  2330. </section>
  2331.  
  2332. </section>
  2333.  
  2334. </section>
  2335.  
  2336. <section>
  2337. <title>What is planned for the future</title>
  2338.  
  2339. <para>Here are some ideas which we want to implement in
  2340. the next releases of Foomatic. Main focus is the maintainability of
  2341. the Foomatic database. More ideas and discussion you can find on:</para>
  2342.  
  2343. <itemizedlist>
  2344.   <listitem><para>The Foomatic Developers forum/newsgroup/mailing list: <ulink url="http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.foomatic.devel">http://www.linuxprinting.org/newsportal/thread.php3?name=linuxprinting.foomatic.devel</ulink>
  2345.     or <ulink url="http://www.linuxprinting.org/cgi-bin/mailman/listinfo/foomatic-devel">http://www.linuxprinting.org/cgi-bin/mailman/listinfo/foomatic-devel</ulink>,
  2346.     archives <ulink url="http://www.linuxprinting.org/pipermail/foomatic-devel/">http://www.linuxprinting.org/pipermail/foomatic-devel/</ulink></para></listitem>
  2347.   <listitem><para>The TODO list in the "Progamming" section of the "Contributing page":
  2348.     <ulink url="http://www.linuxprinting.org/contribute.html#programming">http://www.linuxprinting.org/contribute.html#programming</ulink></para></listitem>
  2349.   <listitem><para>Some ideas and sketches of implementation: <ulink url="http://www.linuxprinting.org/Foomatic-Devel-Ideas.txt">http://www.linuxprinting.org/Foomatic-Devel-Ideas.txt</ulink></para></listitem>
  2350. </itemizedlist>
  2351.  
  2352. <section>
  2353. <title>Web interface for adding new printer entries on linuxprinting.org</title>
  2354.  
  2355. <para>Most of the printers listed on linuxprinting.org
  2356. were added by users, using a web interface. With the switchover to an
  2357. XML database this web interface disappeared and so an important source
  2358. for printer entries. As keeping the printer database up-to-date is a
  2359. lot of work, the best is to revive the web interface.</para>
  2360.  
  2361. <para>To avoid all the noise (as duplicate or empty
  2362. entries, entries with wrong information) we will let the user's
  2363. contributions go into a queue and make an administrator interface to
  2364. check, correct, and finally submit the entries into the database. We
  2365. could make it possible for driver authors and printer manufacturers to
  2366. directly publish the entered info.</para>
  2367.  
  2368. </section>
  2369.  
  2370. <section>
  2371. <title>Printer/Driver classes</title>
  2372.  
  2373. <para>One problem of the Foomatic database is, that one
  2374. has often to repeat the same comments in many printer entries or that
  2375. one has to add constraints for many individual printers into the
  2376. option entries or into the printer lists of driver entries. This makes
  2377. maintaining the database a lot of work.</para>
  2378.  
  2379. <para>To solve this problem we came to the idea of
  2380. introducing printer classes. A class should contain printers with a
  2381. common capability, as for example PCL-5e printers, wide format
  2382. printers, printers compatible to the HP DeskJet 990C, ... So one can
  2383. simply put the PCL-5e printer class as the only printer entry into the
  2384. printer list of the "ljet4" driver and simply add any new PCL-5e
  2385. printer to the PCL-5e class. Then the printer gets automatically
  2386. associated with the "ljet4" driver. In a "PageSize" option one could
  2387. make all paper sizes bigger than Legal only available to the wide
  2388. format class. There could also be a class of all multi-function
  2389. devices needing HPOJ to be able to scan, this class would add an
  2390. appropriate text paragraph to the printer's web page on
  2391. linuxprinting.org. And when this text piece needs to be updated, one
  2392. updates it in the class entry and it automatically changes on hundreds
  2393. of printer pages.</para>
  2394.  
  2395. <para>This makes it also easier for users to add a
  2396. printer via a web interface, They simply need to pick classes to which
  2397. the printer belongs and so most information and driver/option
  2398. associations are done, the user only needs to add little info by
  2399. filling in the web form, the maintainers of linuxprinting.org need
  2400. only to do some fine tuning.</para>
  2401.  
  2402. <para>Similarly one could also make classes for
  2403. drivers.</para>
  2404.  
  2405. </section>
  2406.  
  2407. <section>
  2408. <title>Option conflicts</title>
  2409.  
  2410. <para>An important structural element of PPD files which
  2411. is not supported yet by Foomatic are option conflicts. Option
  2412. conflicts are definitions in the PPD files which prevent the user from
  2413. making choices which make printing impossible or simply do not make
  2414. sense, as for example duplex on transparencies or A3 paper in the
  2415. envelope feeder. This avoids that users send print jobs with bad
  2416. settings and then complain about something wrong or nothing coming out
  2417. of the printer. This is especially important because most spoolers
  2418. cannot report back error messages of the driver to the user who has
  2419. sent the job. So users do not know why nothing comes out of the
  2420. printer. Or they waste expensive material when nice double-sided
  2421. transparencies come out.</para>
  2422.  
  2423. </section>
  2424.  
  2425. </section>
  2426.  
  2427. </section>
  2428.  
  2429. </article>
  2430.