这是我的代码。它运行良好,但在我的 android 手机中没有 pdf 文件。它在 toast 消息中显示路径storage/emulated/0pdfcc.pdf
,但在我的手机中没有这样的文件。
我能做些什么?
提前致谢
public void PdfCreate(View view){
Toast.makeText(this,"1",Toast.LENGTH_SHORT).show();
try {
Toast.makeText(this,"2",Toast.LENGTH_SHORT).show();
// File root=Environment.getExternalStorageDirectory();
//File directory=new File(root.getAbsolutePath()+"createPDF.pdf");
String path = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/pdfcc.pdf";
Toast.makeText(this," not done" +path,Toast.LENGTH_SHORT).show();
PdfWriter.getInstance(document,new FileOutputStream(path));
document.open();
document.add(new Paragraph(text.getText().toString()));
document.close();
Toast.makeText(this,"done",Toast.LENGTH_SHORT).show();
} catch (DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}