Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将PDF从android手机打印到打印机?_Android_Printing_Bluetooth - Fatal编程技术网

如何将PDF从android手机打印到打印机?

如何将PDF从android手机打印到打印机?,android,printing,bluetooth,Android,Printing,Bluetooth,我试图将pdf文件作为字节数组发送到打印机,但它是用机器语言打印的。请任何人帮忙。我们正在使用hp officejet 100移动打印机,尝试通过蓝牙技术进行打印 //发送数据 void sendData() throws IOException { try { InputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolu

我试图将pdf文件作为字节数组发送到打印机,但它是用机器语言打印的。请任何人帮忙。我们正在使用hp officejet 100移动打印机,尝试通过蓝牙技术进行打印

//发送数据

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();
        }

    }

正在打印文本文件。。但不是图像和Pdf文件!!!!!我假设您可能已经找到了打印机的客户线程:否则,像PrintShare这样的解决方案可能完成了所有工作,以确定与打印机通信的协议,类似于@John SOlink@Morrison是的,这是客户的要求。如果我能够发送图像,那么对我来说也可以