简体   繁体   中英

How to print pdf file which comes from firebase url in API response in flutter?

I want to print a pdf file and i am using

syncfusion_flutter_pdfviewer

to display the pdf and i need to print that displayed pdf file. Using print button i want that pdf going to start print.

I used this but its showing that 'Sorry, that didn't work'.

    await Printing.layoutPdf(onLayout: (_) => 'Your Firebase Url' as Uint8List);

在此处输入图像描述

I got answer of this problem. Convert your string url to URI, please make sure you are adding http

http: ^0.13.4

import 'package:http/http.dart' as http;

 Uri uri = Uri.parse('Your link here');
                        http.Response response = await http.get(uri);
                        var pdfData = response.bodyBytes;
                        await Printing.layoutPdf(onLayout: (PdfPageFormat 
                        format) async => pdfData);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM