Reputation: 235
i am trying to use pdf in my flutter project but getting error
Helvetica has no Unicode support see https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management
i just copy the sample from the flutter package page and got this error i tried to use fonts from the local assets file also but didn't work basically i have no idea what i need to do and what i am doing so please guide me
Upvotes: 6
Views: 17433
Reputation: 1
Please use it like this in the example
final font = await PdfGoogleFonts.nunitoExtraLight();
reference : https://pub.dev/packages/printing/example
Upvotes: 0
Reputation: 235
Helvitica has no Unicode support is just a suggestion it is not an Error(I used to thought because since the day i started use of pdf package it shows only this message Never show the pdf which i was expecting ) The error was in OpenFile(in my view) as when i used PdfViewer Package it showed me the desired pdf file
Upvotes: 4
Reputation: 1702
I think you used a non unicoded font in a widget and try to generate a pdf includes it. You need to add this family to your project to use in pdf. Add your font family to your pubspec.yaml file. Should find Helvetica family.
fonts:
- family: Montserrat
fonts:
- asset: assets/open-sans.ttf
Get in code and pass it to your pdf.something widget generator.
final font = await rootBundle.load("assets/open-sans.ttf");
final ttf = Font.ttf(font);
pdf.addPage(Page(
build: (Context context) {
return Center(
child: Text('Dart is awesome', style: TextStyle(font: ttf, fontSize: 40)),
); // Center
}));
Reference : also_check_the_link
Upvotes: 5