简体   繁体   中英

Google cloud print Document Missing

What is document missing error in google cloud print for android?
I am searching for solutions but not yet found.. Kindly help me..

  final Uri docUri = Uri.parse("/mnt/sdcard/downloads");
  final String docMimeType = "pdf";
  final String docTitle = "Android Interview Questions";
  btn_print.setOnClickListener(new OnClickListener() {

@Override
 public void onClick(View v) {
    Intent printIntent = new Intent(PrintDialogActivity.this, PrintActivity.class);
    printIntent.setDataAndType(docUri, docMimeType);
    printIntent.putExtra("title", docTitle);
    startActivity(printIntent);
    }
    });

As far as I know you have to convert the PDF in to base64 and then send it. The best approach to do this would be to use the built in Base64 class that comes with Android and use the method encodeToString to convert your file in to a base64 string.

How to convert file to bytes

File file = new File(path);
int size = (int) file.length();
byte[] bytes = new byte[size];

BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(file));
buffer.read(bytes, 0, bytes.length);
buffer.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM