Closed kinex closed 9 months ago
We have observed that you are attempting to utilize the PdfStandardFont for rendering unicode characters. According to our analysis, using the PdfStandardFont for this purpose is not recommended. We recommend switching to the PdfTruetypefont to address the encountered exception
You can add text using the font data, by initializing PdfFont class as PdfTrueTypeFont class. The font data can be loaded from the disk. The font data can be initialized to PdfTrueTypeFont as a list of bytes or base64 string format. The following code snippet explains this
//Create a new PDF document
PdfDocument document = PdfDocument();
//Draw text
document.pages.add().graphics.drawString('Hello World!!!',
PdfTrueTypeFont(File('Arial.ttf').readAsBytesSync(), 14),
brush: PdfBrushes.black, bounds: Rect.fromLTWH(10, 10, 300, 50));
//Saves the document
File('Output.pdf').writeAsBytes(await document.save());
//Disposes the document
document.dispose();
I am using PdfStandardFont only for drawing things like app name, short date/time and page numbers in the page header/footer. The crash happens in code drawing the app name (which is not different in Greek and contains only normal ASCII characters). Anyway, I will apply your suggested fix and let the user to test it. Thanks!
One user of my app has reported a crash happening when trying to create a PDF. His device language is Greek and the app language is English. This crash log is most probably related to his issue:
Flutter 3.13.3 syncfusion_flutter_pdf 22.2.12