Print a pdf downloaded through a webservice in Flutter / Dart

1,625

Use:

var data = await getThePdfData(); // obtain the Uint8List
Printing.sharePdf(bytes: data);
Share:
1,625
Robin Colombier
Author by

Robin Colombier

Updated on December 14, 2022

Comments

  • Robin Colombier
    Robin Colombier over 1 year

    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.

  • Vicky M
    Vicky M about 4 years
    Im also having same issue. But the solution given here is only to share the pdf. I want to print pdf file. How can i print it?
  • Vishali
    Vishali over 2 years
    @VickyM did you found any solution to print pdf files?