Showing
5 changed files
with
13 additions
and
7 deletions
@@ -106,7 +106,7 @@ class Category extends StatelessWidget { | @@ -106,7 +106,7 @@ class Category extends StatelessWidget { | ||
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | -Future<PdfDocument> generateDocument(PdfPageFormat format) async { | 109 | +Future<Document> generateDocument(PdfPageFormat format) async { |
110 | final PdfDoc pdf = PdfDoc(title: 'My Résumé', author: 'David PHAM-VAN'); | 110 | final PdfDoc pdf = PdfDoc(title: 'My Résumé', author: 'David PHAM-VAN'); |
111 | 111 | ||
112 | final PdfImage profileImage = await pdfImageFromImageProvider( | 112 | final PdfImage profileImage = await pdfImageFromImageProvider( |
@@ -198,5 +198,5 @@ Future<PdfDocument> generateDocument(PdfPageFormat format) async { | @@ -198,5 +198,5 @@ Future<PdfDocument> generateDocument(PdfPageFormat format) async { | ||
198 | ]) | 198 | ]) |
199 | ]), | 199 | ]), |
200 | )); | 200 | )); |
201 | - return pdf.document; | 201 | + return pdf; |
202 | } | 202 | } |
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; | @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; | ||
7 | import 'package:flutter/rendering.dart'; | 7 | import 'package:flutter/rendering.dart'; |
8 | 8 | ||
9 | import 'package:pdf/pdf.dart'; | 9 | import 'package:pdf/pdf.dart'; |
10 | +import 'package:pdf/widgets.dart' as pdf; | ||
10 | import 'package:printing/printing.dart'; | 11 | import 'package:printing/printing.dart'; |
11 | 12 | ||
12 | import 'package:printing_example/document.dart'; | 13 | import 'package:printing_example/document.dart'; |
@@ -33,7 +34,7 @@ class MyAppState extends State<MyApp> { | @@ -33,7 +34,7 @@ class MyAppState extends State<MyApp> { | ||
33 | 34 | ||
34 | Future<void> _sharePdf() async { | 35 | Future<void> _sharePdf() async { |
35 | print('Share ...'); | 36 | print('Share ...'); |
36 | - final PdfDocument pdf = await generateDocument(PdfPageFormat.a4); | 37 | + final pdf.Document document = await generateDocument(PdfPageFormat.a4); |
37 | 38 | ||
38 | // Calculate the widget center for iPad sharing popup position | 39 | // Calculate the widget center for iPad sharing popup position |
39 | final RenderBox referenceBox = | 40 | final RenderBox referenceBox = |
@@ -44,7 +45,8 @@ class MyAppState extends State<MyApp> { | @@ -44,7 +45,8 @@ class MyAppState extends State<MyApp> { | ||
44 | referenceBox.localToGlobal(referenceBox.paintBounds.bottomRight); | 45 | referenceBox.localToGlobal(referenceBox.paintBounds.bottomRight); |
45 | final Rect bounds = Rect.fromPoints(topLeft, bottomRight); | 46 | final Rect bounds = Rect.fromPoints(topLeft, bottomRight); |
46 | 47 | ||
47 | - Printing.sharePdf(document: pdf, filename: 'my-résumé.pdf', bounds: bounds); | 48 | + await Printing.sharePdf( |
49 | + bytes: document.save(), filename: 'my-résumé.pdf', bounds: bounds); | ||
48 | } | 50 | } |
49 | 51 | ||
50 | Future<void> _printScreen() async { | 52 | Future<void> _printScreen() async { |
@@ -3,13 +3,14 @@ import 'dart:io'; | @@ -3,13 +3,14 @@ import 'dart:io'; | ||
3 | import 'package:flutter_test/flutter_test.dart'; | 3 | import 'package:flutter_test/flutter_test.dart'; |
4 | 4 | ||
5 | import 'package:pdf/pdf.dart'; | 5 | import 'package:pdf/pdf.dart'; |
6 | +import 'package:pdf/widgets.dart' as pdf; | ||
6 | 7 | ||
7 | import 'package:printing_example/document.dart'; | 8 | import 'package:printing_example/document.dart'; |
8 | 9 | ||
9 | void main() { | 10 | void main() { |
10 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { | 11 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { |
11 | - final PdfDocument pdf = await generateDocument(PdfPageFormat.a4); | 12 | + final pdf.Document document = await generateDocument(PdfPageFormat.a4); |
12 | final File file = File('document.pdf'); | 13 | final File file = File('document.pdf'); |
13 | - file.writeAsBytesSync(pdf.save()); | 14 | + file.writeAsBytesSync(document.save()); |
14 | }); | 15 | }); |
15 | } | 16 | } |
@@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to | @@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to | ||
4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing | 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing |
5 | repository: https://github.com/DavBfr/dart_pdf | 5 | repository: https://github.com/DavBfr/dart_pdf |
6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues | 6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues |
7 | -version: 2.0.1 | 7 | +version: 2.0.2 |
8 | 8 | ||
9 | environment: | 9 | environment: |
10 | sdk: ">=2.1.0 <3.0.0" | 10 | sdk: ">=2.1.0 <3.0.0" |
-
Please register or login to post a comment