2013-04-30 48 views
2

谷歌雲打印爲Android的文件丟失錯誤是什麼?
我正在尋找解決方案,但還沒有找到..請幫助我..谷歌雲打印文件丟失

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); 
    } 
    }); 
+0

你得到這個答案?我也被困在同一個問題上。儘管我還在類PrintDialogJavaScriptInterface中的每個方法上放置了註釋@JavascriptInterface ..但它不起作用 – Gaurang 2015-10-15 08:46:19

+0

親愛的Gaurang。我力求得到答案。這是我的老帖子。 – Raja45 2015-11-05 04:18:04

回答

0

據我知道你的PDF轉換在爲Base64,然後將其發送。最好的方法是使用Android自帶的Base64類,並使用方法encodeToString將文件轉換爲base64字符串。

文件如何轉換爲字節

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(); 
+0

編輯答案,我希望現在更有意義。我希望發送Base 64文件是真正的問題:)在我的情況下,這是NodeJS中的問題。 – 2016-03-11 11:51:34