1

I'm building an app that has to print a file. I want to use Google cloud print but it keeps saying the file is missing.

The app creates a pdf using iText. This part works, Adobe reader can show it on my phone. Then I run this:

public static final String FILE_URI = Environment.getExternalStorageDirectory().getPath() + "/pdfFile.pdf";

Uri uri = Uri.parse(FILE_URI);

Intent printIntent = new Intent(MainActivity.this, PrintDialogActivity.class);
printIntent.setDataAndType(uri, "pdf");
printIntent.putExtra("title", "pdfFile");
startActivity(printIntent);

It launches the print activity, you can log in to your google account but when you press print it says document missing. Anyone knows what's wrong?

4

1 回答 1

1

而不是使用以下内容:

Uri uri = Uri.parse(FILE_URI); 

printIntent.setDataAndType(uri, "pdf");

利用:

Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/output.pdf"));

printIntent.setDataAndType(uri, "application/pdf");

有用 :)

于 2014-05-16T05:56:09.040 回答