Showing
3 changed files
with
16 additions
and
3 deletions
@@ -28,6 +28,7 @@ class PdfPreview extends StatefulWidget { | @@ -28,6 +28,7 @@ class PdfPreview extends StatefulWidget { | ||
28 | this.onShared, | 28 | this.onShared, |
29 | this.scrollViewDecoration, | 29 | this.scrollViewDecoration, |
30 | this.pdfPreviewPageDecoration, | 30 | this.pdfPreviewPageDecoration, |
31 | + this.pdfFileName, | ||
31 | }) : super(key: key); | 32 | }) : super(key: key); |
32 | 33 | ||
33 | /// Called when a pdf document is needed | 34 | /// Called when a pdf document is needed |
@@ -69,6 +70,9 @@ class PdfPreview extends StatefulWidget { | @@ -69,6 +70,9 @@ class PdfPreview extends StatefulWidget { | ||
69 | /// Decoration of _PdfPreviewPage | 70 | /// Decoration of _PdfPreviewPage |
70 | final Decoration pdfPreviewPageDecoration; | 71 | final Decoration pdfPreviewPageDecoration; |
71 | 72 | ||
73 | + /// Name of the PDF when sharing. It must include the extension. | ||
74 | + final String pdfFileName; | ||
75 | + | ||
72 | @override | 76 | @override |
73 | _PdfPreviewState createState() => _PdfPreviewState(); | 77 | _PdfPreviewState createState() => _PdfPreviewState(); |
74 | } | 78 | } |
@@ -365,7 +369,11 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -365,7 +369,11 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
365 | } | 369 | } |
366 | 370 | ||
367 | Future<void> _print() async { | 371 | Future<void> _print() async { |
368 | - final result = await Printing.layoutPdf(onLayout: widget.build); | 372 | + final result = await Printing.layoutPdf( |
373 | + onLayout: widget.build, | ||
374 | + name: widget.pdfFileName, | ||
375 | + format: pageFormat, | ||
376 | + ); | ||
369 | 377 | ||
370 | if (result && widget.onPrinted != null) { | 378 | if (result && widget.onPrinted != null) { |
371 | widget.onPrinted(context); | 379 | widget.onPrinted(context); |
@@ -383,7 +391,8 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -383,7 +391,8 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
383 | final bounds = Rect.fromPoints(topLeft, bottomRight); | 391 | final bounds = Rect.fromPoints(topLeft, bottomRight); |
384 | 392 | ||
385 | final bytes = await widget.build(pageFormat); | 393 | final bytes = await widget.build(pageFormat); |
386 | - final result = await Printing.sharePdf(bytes: bytes, bounds: bounds); | 394 | + final result = await Printing.sharePdf( |
395 | + bytes: bytes, bounds: bounds, filename: widget.pdfFileName); | ||
387 | 396 | ||
388 | if (result && widget.onShared != null) { | 397 | if (result && widget.onShared != null) { |
389 | widget.onShared(context); | 398 | widget.onShared(context); |
@@ -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: 3.5.0 | 7 | +version: 3.6.0 |
8 | 8 | ||
9 | environment: | 9 | environment: |
10 | sdk: ">=2.3.0 <3.0.0" | 10 | sdk: ">=2.3.0 <3.0.0" |
-
Please register or login to post a comment