我想知道如何使用android中的EditText(TextView)中的文本制作PDF。 这是我的代码,但它不起作用。
public boolean onOptionsItemSelected(MenuItem item) {
TextView ocrResultTextView = (TextView) findViewById(R.id.resultText);
// Take appropriate action for each action item click
switch (item.getItemId()) {
case R.id.action_pdf:
// PDF
try {
OutputStreamWriter out = new OutputStreamWriter(openFileOutput("TextFile", MODE_APPEND));
EditText editText=(EditText) findViewById(R.id.resultText);
String text = editText.getText().toString();
out.write(text);
out.write('\n');
out.close();
Toast.makeText(this, "The contents are saved in the file.", Toast.LENGTH_LONG).show();
Toast toast = Toast.makeText(this, tem, Toast.LENGTH_LONG);
toast.show();
} catch (Throwable t) {
Toast.makeText(this, "Exception: " + t.toString(), Toast.LENGTH_LONG).show();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}