printAppointment method
Implementation
Future<void> printAppointment(
DataAppointment reportData,
String paperSize, // 'A4', 'A5', 'A6', 'A7'
) async {
final pdf = pw.Document();
pdf.addPage(
await AppointmentTemplate.buildAppointment(
paperSize,
patientName: reportData.patientName,
appointmentDateTime: reportData.appointmentDateTime,
appointmentWeekDay: reportData.appointmentWeekDay,
doctorName: reportData.doctorName,
clinicName: reportData.companyName!,
clinicAddress: reportData.companyAddress!,
clinicPhone: reportData.companyPhone!,
printedBy: reportData.printedBy,
language: reportData.language,
patientSequence: reportData.pateintSequence,
notes: reportData.note,
),
);
final pdfBytes = await pdf.save();
if (kIsWeb ||
UniversalPlatform.isWindows ||
UniversalPlatform.isLinux ||
UniversalPlatform.isMacOS) {
await Printing.layoutPdf(onLayout: (format) async => pdfBytes);
} else {
final tempDir = await getTemporaryDirectory();
final tempFilePath = '${tempDir.path}/appointment_card.pdf';
final tempFile = File(tempFilePath);
await tempFile.writeAsBytes(pdfBytes);
await OpenFile.open(tempFilePath);
}
}