title: Printing on "Bixolon Thermal Printer" using JAVA, "No pages found!" error
body: <p>I have been trying to use a thermal-printer "Bixolon SRP-F310" and print some text using JAVA's PrintService. Printer is detected and there is no exception while calling the print function. I can see in the web interface of Cups that the print event is called. However the printer doesn't print and the error message "No pages found!" can be seen in the web-interface of Cups. Any help will be appreciated. I have included the screenshot of the Cups web-interface and the error logs. </p>
  
  <pre><code>import javax.print.*;
  import java.util.Arrays;
  import java.util.List;
  
  public class Printer {
      static Printer INSTANCE;
  
      public static void main(String[] args) {
          INSTANCE = new Printer();
  
          List&lt;PrintService&gt; services = INSTANCE.getServicesByName("BIXOLON_SRP-F310");
          if(services == null) {
              throw new RuntimeException("No printer services available");
          }
          INSTANCE.printServices(services);
  
          try {
              INSTANCE.print(services.get(0), "Hello");
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public List&lt;PrintService&gt; getServicesByName(String serviceName) {
          //Find printer service by name
          AttributeSet aset = new HashAttributeSet();
          aset.add(new PrinterName(serviceName, null));
          return Arrays.asList(PrintServiceLookup.lookupPrintServices(null, aset));
      }
  
      public void print(PrintService service, String printData) throws Exception {
          if(service == null) {
              throw new Exception("Service is not valid");
          }
          if(printData == null) {
              throw new Exception("Nothing to print");
          }
  
          PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
          pras.add(new Copies(1));
          pras.add(new PrinterResolution(180,180,PrinterResolution.DPI));
  
          DocPrintJob job = service.createPrintJob();
          DocAttributeSet das = new HashDocAttributeSet();
          das.add(new PrinterResolution(180,180,PrinterResolution.DPI));
  
          byte[] desc = printData.getBytes();
          Doc doc = new SimpleDoc(desc, DocFlavor.BYTE_ARRAY.AUTOSENSE, das);
  
          try {
              job.print(doc, pras);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public void printServices(List&lt;PrintService&gt; services) {
          System.out.println("Printer Services found:");
          for (PrintService service : services) {
              System.out.println("\t" + service);
          }
      }
  }
  </code></pre>
  
  <p>Web Interface of Cups:</p>
  
  <p><img src="https://i.stack.imgur.com/tNVqh.png" alt="Web Interface of Cups showing the printing job added, but with the error &quot;No pages found!&quot;"></p>
  
  <p>Error Logs:</p>
  
  <p><a href="http://pastebin.com/kYiKGsSn" rel="nofollow noreferrer">http://pastebin.com/kYiKGsSn</a></p>