Home > Blockchain >  Share a pdf to whatsapp number? flutter
Share a pdf to whatsapp number? flutter

Time:10-24

I am using printing 5.9.3 flutter package to preview html in pdf format.I want to share that pdf to spesific whatsapp number.How can i do that.

 Future<Uint8List> doc = Printing.convertHtml(
    format: PdfPageFormat.a4,
    html: htmlString
);



  sahreOnWhatsapp(String phoneNumber,Uint8List doc){
       //share doc to wahtsapp number
 }

CodePudding user response:

You can use whatsapp_share2 package like this:

sahreOnWhatsapp(String phoneNumber,Uint8List doc){
    final directory = (await getApplicationDocumentsDirectory()).path;
    final docPath = await File('$directory/share.pdf').create();
    await docPath.writeAsBytes(doc);

    if (imagePath.path.isNotEmpty) {
      await WhatsappShare.shareFile(
         text: 'Whatsapp share text',
         phone: phoneNumber,
         filePath: [docPath.path],
      );
    }
}

CodePudding user response:

You can use whatsapp_share package.

Link to Documentation.

  • Related