Open nambui2000k opened 3 years ago
Patiently waiting for an update.
Patiently waiting for an update too.
I can implement this functionality but Waiting on this: https://github.com/DavBfr/dart_pdf/issues/313
I have solved my issue by creating this method to convert from an array of data to PDF. I am posting here in case it might help. Cheers.
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:pdf/widgets.dart' as pw;
exportAsPDF() async {
// load data to list
final allData = await getAllData();
List<String> headers = ['DATE', 'SYS', 'DIA', 'PUL', 'TYPE', 'TAGS'];
List<List<String>> bpDocument = [];
allData.forEach((element) {
bpDocument.add(<String>[
element['dateTime'].toDate().toString(),
element['systolic'].toString(),
element['diastolic'].toString(),
element['pulse'].toString(),
element['type'].toString(),
element['tags'].toString(),
]);
});
final pdf = pw.Document();
pdf.addPage(pw.Page(
build: (context) => pw.Table.fromTextArray(
headers: headers,
data: bpDocument,
),
));
final bytes = await pdf.save();
if (kIsWeb) {
// running on the web!
download(bytes,
downloadName: DateFormat('yMMdd').format(DateTime.now()).toString() +
"_export.pdf");
} else {
Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
String filePath = appDocPath +
"/" +
DateFormat('yMMdd').format(DateTime.now()).toString() +
"_export" +
".pdf";
final File file = File(filePath);
await file.writeAsBytes(bytes);
//open share dialog
Share.shareFiles([filePath]);
return file;
}
}
@ya332 That would work for sure, but not for span and merge case-scenario.
Looking forward to updates,I really need this feature
when will there be feature to convert excel to pdf