convertToBytes method
Implementation
Future<Uint8List?> convertToBytes({
required String html,
PdfPageSize? pageSize,
}) async {
final newpdf = Document();
List<Widget> widgets = await HTMLToPdf().convert(html);
// Use pageSize if provided, otherwise use default
final pdfPageFormat = pageSize != null
? PdfPageFormat(pageSize.width, pageSize.height)
: PdfPageFormat.a4;
newpdf.addPage(MultiPage(
pageFormat: pdfPageFormat,
maxPages: 200,
build: (context) {
return widgets;
}));
return await newpdf.save();
}