Вот только холст, рисующий текст текста и сохраняющий PDF-файл в разделе «Загрузки». Работает нормально
Код: Выделить всё
canvas.drawText(text ,x ,y, paint);
document.finishPage(page);
File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String fileName = "document.pdf";
File file = new File(downloadsDir, fileName);
try {
FileOutputStream fos = new FileOutputStream(file);
document.writeTo(fos);
document.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
showPdf();
Код: Выделить всё
public void showPdf() {
try {
File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String fileName = "document.pdf";
File file = new File(downloadsDir, fileName);
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... in-android
Мобильная версия