I am using google cloud print with an android project to print out a pdf file. I am storing the file in the assets folder of the project and when I go to print it say "Document Missing".
Here is my code
public void stevePrint(View view) {
Intent printIntent = new Intent(this, PrintDialogActivity.class);
//Cant find file, why?
File file = new File("/assets/steve.pdf");
printIntent.setDataAndType(Uri.fromFile(file), "document/pdf");
printIntent.putExtra("title", "Steve");
startActivity(printIntent);
Context context = getApplicationContext();
CharSequence text = "Sending to Google Cloud Print";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
Any help is appreciated!
You appear to be using the wrong MIME type. It should read:
printIntent.setDataAndType(Uri.fromFile(file), "application/pdf");
It looks like you're using PrintDialogActivity, from the Google Cloud Print documentation. Make sure to also add the @JavascriptInterface annotations to each method inside PrintDialogJavaScriptInterface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With