title: How can i get printjob document text
body: <p>Hello guys i want to print from printservice and i need to get printjob document text because i want to add styles. How can i do this?
  I've been trying for a long time, but I've been trying to find it
  Here is my code.</p>
  <pre><code>PrinterInfo mThermalPrinter;
  
  @Override
  public void onCreate() {
      mThermalPrinter = new PrinterInfo.Builder(generatePrinterId(&quot;USB&quot;),
              &quot;Printer&quot;, PrinterInfo.STATUS_IDLE).build();
  }
  
  @Override
  protected void onPrintJobQueued(PrintJob printJob) {
      Toast.makeText(getApplicationContext(), &quot;MOST NYOMTAT&quot;, Toast.LENGTH_SHORT).show();
  
  
      try {
              BluetoothConnection connection = BluetoothPrintersConnections.selectFirstPaired();
              if (connection != null) {
                  EscPosPrinter printer = new EscPosPrinter(connection, 203, 48f, 32, new EscPosCharsetEncoding(&quot;cp852&quot;, 18));
                  printer.printFormattedText(printJob.getDocument().toString());
              } else {
                  Toast.makeText(this, &quot;No printer was connected!&quot;, Toast.LENGTH_SHORT).show();
              }
      } catch (Exception e) {
          Log.e(&quot;APP&quot;, &quot;Can't print&quot;, e);
      }
      
      
      /*InputStream in = null;
      try {
          in = new FileInputStream(printJob.getDocument().getData().getFileDescriptor());
  
          byte[] buffer = new byte[1024];
          int read;
          while ((read = in.read(buffer)) != -1) {
              System.out.print(buffer);
              System.out.print(read);
              System.out.println(&quot;Test &quot; + new String(buffer));
          }
          in.close();
  
  
      } catch (IOException ioe) {
  
      }*/
      printJob.cancel();
  }
  </code></pre>