Reputation: 53
I'm working with Flutter. I have a pdf document that I download from a webservice. The http body response of this pdf sent by http package is typed as Uint8List. Then, I would like to print it with printing which is working with pdf package.
So I need an instance of a PdfDocument from this class. Is there a way that I can convert this Uint8List to pdf ? I tried some other dart packages, but they didn't answer my needs because I need to print pdf, not just view them.
I also looked with flutter_downloader in order to simply get pdf file without bothering myself with Uint8List, but it seems the package is not working at the moment: https://github.com/fluttercommunity/flutter_downloader/issues/132
Thank you very much for answering.
Upvotes: 3
Views: 2234
Reputation: 51751
Use:
var data = await getThePdfData(); // obtain the Uint8List
Printing.sharePdf(bytes: data);
Upvotes: 4