大家好,我正在尝试在创建 pdf 时添加网络图像或图像 url。
基本上,我想实现当用户单击购物车中的下载按钮时,购物车中的所有产品都应与其图像一起添加,到目前为止,图像尚未添加,但其他详细信息已添加到 pdf 中。
我正在使用syncfusion pdf创建一个pdf,我的pdf已成功创建。
我也想用它添加图像。
我的逻辑是下载图像然后将其添加到 pdf 中,但不知何故它崩溃了。
我用了下面的包
https://pub.dev/packages/syncfusion_flutter_pdf
https://pub.dev/packages/image_downloader
下面是我尝试过的代码
List<File> _mulitpleFiles = [];
Future<void> generateInvoice() async {
//Create a PDF document.
final PdfDocument document = PdfDocument();
//Add page to the PDF
final PdfPage page = document.pages.add();
//Get page client size
final Size pageSize = page.getClientSize();
//Draw rectangle
page.graphics.drawRectangle(
bounds: Rect.fromLTWH(0, 0, pageSize.width, pageSize.height),
pen: PdfPen(PdfColor(142, 170, 219, 255)));
//Generate PDF grid.
final PdfGrid grid = getGrid();
//Draw the header section by creating …Run Code Online (Sandbox Code Playgroud)