0

I am trying to send pdf file to printer as a array of bytes but it is printing in machinary language. Please can anyOne help on this. We are using hp officejet 100 mobile printer, Trying to print via bluetooth tech

//send data

void sendData() throws IOException {
        try {

            InputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/invoices.pdf"));// Where this is Activity

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            int FILE_CHUNK_SIZE = 1024 * 4;
            byte[] b = new byte[FILE_CHUNK_SIZE];
            int read = -1;



            while ((read = is.read(b)) != -1) {
                bos.write(b, 0, read);
            }

            byte[] bytes = bos.toByteArray();

            mmOutputStream.write(bytes);

            is.close();
            bos.close();
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myLabel.setText("Data Sent");
            closeBT();
        }

    }
Maqsood Alam
  • 27
  • 1
  • 7
  • text file is printing.. But not image and Pdf file!!!!! – Maqsood Alam Dec 28 '15 at 05:44
  • http://stackoverflow.com/questions/14530058/how-can-i-print-an-image-on-a-bluetooth-printer-in-android – John Dec 28 '15 at 05:48
  • I assume you may have found this customer thread for the printer: http://h30434.www3.hp.com/t5/Inkjet-Printing/how-can-i-print-to-my-officejet-100-mobile-printer-from-an/td-p/1373379 otherwise a solution like PrintShare probably done all of the work figuring out the protocol to talk to the printer similar to @John SO link – Morrison Chang Dec 28 '15 at 05:56
  • @Morrison Yes its customer requirement. If I am able to send Image then also Ok for me – Maqsood Alam Dec 28 '15 at 07:45

0 Answers0