{"id":98,"date":"2007-09-28T17:51:43","date_gmt":"2007-09-29T01:51:43","guid":{"rendered":"http:\/\/www.outflux.net\/blog\/archives\/2007\/09\/28\/cups-banner-template-variables\/"},"modified":"2007-09-28T17:51:43","modified_gmt":"2007-09-29T01:51:43","slug":"cups-banner-template-variables","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2007\/09\/28\/cups-banner-template-variables\/","title":{"rendered":"CUPS banner template variables"},"content":{"rendered":"<p>A while back, I wanted to design some banner pages for a shared network printer that would show the name of the host that sent the request (none of the standard CUPS banners report this).  It was easy enough to define a custom banner page:<\/p>\n<blockquote>\n<pre>\r\n&lt;Printer lj4200&gt;\r\n...\r\nJobSheets shared-banner none\r\n...\r\n&lt;\/Printer&gt;\r\n<\/pre>\n<\/blockquote>\n<p>Then, I could drop a modified banner into <code>\/usr\/share\/cups\/banners<\/code> with the filename &#8220;shared-banner&#8221;.  The banner is just a regular PostScript file, so I could muck around with it.  While looking at the &#8220;standard&#8221; banner, I saw some PS variables being used that had been defined by CUPS:<\/p>\n<blockquote>\n<pre>\r\n...\r\n  (Job ID: ) RIGHT\r\n  2 copy                % Copy X & Y\r\n  moveto\r\n  ({<strong>printer-name<\/strong>}-{<strong>job-id<\/strong>}) show\r\n...\r\n<\/pre>\n<\/blockquote>\n<p>I couldn&#8217;t find documentation on the available variables, but managed to track down some of the list at cupsGetJobs2 in <a href=\"http:\/\/svn.easysw.com\/public\/cups\/trunk\/cups\/util.c\">cups\/utils.c<\/a>:<\/p>\n<blockquote><p>\njob-id<br \/>\njob-priority<br \/>\njob-k-octets<br \/>\njob-state<br \/>\ntime-at-completed<br \/>\ntime-at-creation<br \/>\ntime-at-processing<br \/>\njob-printer-uri<br \/>\ndocument-format<br \/>\njob-name<br \/>\njob-originating-user-name\n<\/p><\/blockquote>\n<p>None of these had the sending host listed, so I continued searching.  Additional ones are defined in <a href=\"http:\/\/svn.easysw.com\/public\/cups\/trunk\/scheduler\/ipp.c\">scheduler\/ipp.c<\/a>, including:<\/p>\n<blockquote><p>\nprinter-name<br \/>\njob-id<br \/>\njob-billing<br \/>\njob-hold-until<br \/>\njob-sheets<br \/>\njob-media-sheets-completed<br \/>\njob-originating-host-name\n<\/p><\/blockquote>\n<p>&#8220;job-originating-host-name&#8221; did the trick for my banner:<\/p>\n<blockquote>\n<pre>\r\n...\r\n  (Host: ) RIGHT\r\n  moveto\r\n  ({job-originating-host-name}) show\r\n...\r\n<\/pre>\n<\/blockquote>\n<p>I&#8217;ve seen some other <a href=\"http:\/\/dvinfo.ifh.de\/Cups_Admin#head-5d68564088ae2fa8fc15300ff6a1bc81f29bb43a\">partial<\/a> <a href=\"http:\/\/www.easysw.com\/printpro\/howto.php?all\">lists<\/a>, but I haven&#8217;t found an official complete list.  It&#8217;d be handy to see this documented better, since some variables aren&#8217;t valid until after the job is processed (job-sheets), so it&#8217;s only valid in the trailing banner, not the leading banner.<\/p>\n<p style='text-align:left'>&copy; 2007, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back, I wanted to design some banner pages for a shared network printer that would show the name of the host that sent the request (none of the standard CUPS banners report this). It was easy enough to define a custom banner page: &lt;Printer lj4200&gt; &#8230; JobSheets shared-banner none &#8230; &lt;\/Printer&gt; Then, I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,14],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/98"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}