0

I'm writing Print Service android app for my web app. When my web app opened from google chrome android device, my print service app must be able to do print job. So I implement this from documentation :

@Override
    protected void onPrintJobQueued(PrintJob printJob) {
         final PrintDocument document = printJob.getDocument();
         ........
    }

As I know, that document is object to print from page of google chrome. So I need the HTML content from that page as String (like : Hello, This is My Web App) but I still cannot get the HTML as string. I use this snippet but when do print to logcat, it have weird symbols.

 final FileInputStream in = new FileInputStream(document.getData().getFileDescriptor());
 final byte[] buffer = new byte[4];
 StringBuilder datax = new StringBuilder("");
 try {
    InputStreamReader isr = new InputStreamReader ( in ) ;
    BufferedReader buffreader = new BufferedReader ( isr ) ;
    String readString = buffreader.readLine ( ) ;
    while ( readString != null ) {
        datax.append(readString);
        readString = buffreader.readLine ( ) ;
    }
    isr.close ( ) ;
 } catch ( IOException ioe ) {
    ioe.printStackTrace ( ) ;
 }
 out.println(datax.toString());  // Weird Symbols
MrX
  • 953
  • 2
  • 16
  • 42

0 Answers0