Код: Выделить всё
_createPdf(PlatformFile file) async {
final pdf = pw.Document();
final image = pw.MemoryImage(
File(file.path!).readAsBytesSync(),
);
pdf.addPage(pw.Page(build: (pw.Context context) {
return pw.Center(
child: pw.Image(image),
); // Center
}),); // Page
final String dir = (await getApplicationDocumentsDirectory()).path;
final String path = '$dir/pdfExemplo.pdf';
final File newFile = File(path);
newFile.writeAsBytesSync(await pdf.save());
openFile2(newFile);
}
Я передаю изображение внутри файла файла, создаю PDF-файл, а затем пытаюсь добавить изображение в этом созданном PDF-файле
Подробнее здесь: https://stackoverflow.com/questions/783 ... th-flutter
Мобильная версия