title: Print a postscript document with CUPS and a thermal printer
body: <p>I installed an epson TM-T20 in Ubuntu 12.04, using the official <a href="https://download.epson-biz.com/modules/pos/index.php?page=prod&amp;pcat=3&amp;pid=37&amp;scat=32" rel="nofollow">driver</a>. This is a thermal printer, I'm using 80mm paper.</p>
  
  <p>My problem: When I print an image (using a postscript document) it waste a lot of paper because the image uses around 5cm and the printer before the image sends out 25cm of white paper.</p>
  
  <p>I use the following command to send the document to the printer:</p>
  
  <pre><code>lpr -P tm-t20 -o document.ps
  </code></pre>
  
  <p>The printer prints the image (a 200x200 image), but first sends out a lot of non printed paper.</p>
  
  <p>The printer wasn't recognized by CUPS (using the web interface at localhost:631). Then I installed it using the following procedure:</p>
  
  <pre><code>sudo lpadmin -p tm-t20 -E -v serial:/dev/ttyUSB0 -P /usr/share/ppd/epson-tm-t20-rastertotmt.ppd 
  </code></pre>
  
  <p>Then the printer appeared in the CUPS web interface and I configured it (baud rate, bit parity, etc).</p>
  
  <p>The printer works ok when I send some text.</p>
  
  <p>Here is part of the printer ppd:</p>
  
  <pre><code>*DefaultPageRegion:RP80x297
  *PageRegion RP80x297/Roll Paper 80 x 297 mm: "&lt;&lt;/PageSize[204 841.8]/           ImagingBBox null&gt;&gt;setpagedevice"
  *PageRegion RP58x297/Roll Paper 58 x 297 mm: "&lt;&lt;/PageSize[141.7 841.8]/         ImagingBBox null&gt;&gt;setpagedevice"
  *CloseUI: *PageRegion
  
  *DefaultImageableArea: RP80x297
  *ImageableArea RP80x297/Roll Paper 80 x 297 mm: "0 0 204 841.8"
  *ImageableArea RP58x297/Roll Paper 58 x 297 mm: "0 0 141.7 841.8"
  
  *DefaultPaperDimension: RP80x297
  *PaperDimension RP80x297/Roll Paper 80 x 297 mm: "204 841.8"
  *PaperDimension RP58x297/Roll Paper 58 x 297 mm: "141.7 841.8"
  </code></pre>
  
  <p>I suppose that this waste of paper is because the 297mm of long that appears in the ppd file. Then I tried adding another configuration of 100mm instead of 297mm, but the problem persists.</p>
  
  <p>I also tryied adding the tag %%DocumentMedia to the ps file, but the same problem:</p>
  
  <pre><code>%!PS-Adobe-3.0
  %%Creator: GIMP PostScript file plugin V 1.17 by Peter Kirchgessner
  %%Title: yay.ps
  %%CreationDate: Thu Sep 13 13:44:26 2012
  %%DocumentData: Clean7Bit
  %%LanguageLevel: 2
  %%Pages: 1
  %%BoundingBox: 14 14 215 215
  %%
  %%EndComments
  %%DocumentMedia: Plain 72 72 0 white Plain 
  %%BeginProlog
  % Use own dictionary to avoid conflicts
  10 dict begin
  %%EndProlog
  %%Page: 1 1
  % Translate for offset
  14.173228346456694 14.173228346456694 translate
  % Translate to begin of first scanline
  0 199.99999999999997 translate
  199.99999999999997 -199.99999999999997 scale
  % Image geometry
  200 200 8
  % Transformation matrix
  [ 200 0 0 200 0 0 ]
  % Strings to hold RGB-samples per scanline
  /rstr 200 string def
  /gstr 200 string def
  /bstr 200 string def
  {currentfile /ASCII85Decode filter /RunLengthDecode filter rstr readstring pop}
  {currentfile /ASCII85Decode filter /RunLengthDecode filter gstr readstring pop}
  {currentfile /ASCII85Decode filter /RunLengthDecode filter bstr readstring pop}
  true 3
  %%BeginData:        14759 ASCII Bytes
  </code></pre>
  
  <p>Any idea? </p>