dart_pdf
dart_pdf copied to clipboard
Checkbox Not Displaying
Describe the bug
I have a simple test PDF with a checkbox between two texts. Nothing appears but blank. To Reproduce Code snippet to reproduce the behavior:
Future<Uint8List> makePDF(PdfPageFormat format, Map data) async {
final pdf = pw.Document();
pdf.addPage(
pw.MultiPage(
pageTheme: pw.PageTheme(
pageFormat: PdfPageFormat.letter,
margin: pw.EdgeInsets.only(top: 40, left: 40, right: 40),
theme: pw.ThemeData.withFont(
base: await PdfGoogleFonts.openSansRegular(),
bold: await PdfGoogleFonts.openSansBold(),
icons: await PdfGoogleFonts.materialIcons(), // this line
)),
build: (pw.Context context) {
return [
// debug stuff
pw.Text('start'),
pw.Checkbox(
height: 20,
width: 20,
name: 'sample',
value: true,
tristate: true,
decoration: pw.BoxDecoration(
border: pw.Border.all(
color: PdfColors.black,
width: 2.0,
),
),
),
pw.Text('end'),
];
},
),
); // Page
return pdf.save();
}
Expected behavior
I tried many different parameters and I cannot display a checkbox. This is for a windows app
Desktop (please complete the following information):
- [ ] iOS
- [ ] Android
- [ ] Browser
- [ x] Windows
- [ ] Linux
U can use this : pw.Center( child: pw.Icon(const pw.IconData(0xe3c6), size: 16), ),
also dont forget to aply this :
pdf.addPage(
// Page Ayarları
pw.MultiPage(
maxPages: 100,
theme: pw.ThemeData.withFont(
base: await PdfGoogleFonts.openSansRegular(),
bold: await PdfGoogleFonts.openSansBold(),
icons: await PdfGoogleFonts.materialIcons(), // this line
),
pageFormat: format,
orientation: pw.PageOrientation.portrait,
crossAxisAlignment: pw.CrossAxisAlignment.start,
build: (context) {
return FinalPDF;
}),
);
```