Marcos Rodriguez
Committed by David PHAM-VAN

Added pdfFileName prop

# Changelog
## 3.6.0
- Added pdfFileName prop to PdfPreview Widget [Marcos Rodriguez]
## 3.5.0
- Add decoration options to the PdfPreview Widget [Marcos Rodriguez]
... ...
... ... @@ -28,6 +28,7 @@ class PdfPreview extends StatefulWidget {
this.onShared,
this.scrollViewDecoration,
this.pdfPreviewPageDecoration,
this.pdfFileName,
}) : super(key: key);
/// Called when a pdf document is needed
... ... @@ -69,6 +70,9 @@ class PdfPreview extends StatefulWidget {
/// Decoration of _PdfPreviewPage
final Decoration pdfPreviewPageDecoration;
/// Name of the PDF when sharing. It must include the extension.
final String pdfFileName;
@override
_PdfPreviewState createState() => _PdfPreviewState();
}
... ... @@ -365,7 +369,11 @@ class _PdfPreviewState extends State<PdfPreview> {
}
Future<void> _print() async {
final result = await Printing.layoutPdf(onLayout: widget.build);
final result = await Printing.layoutPdf(
onLayout: widget.build,
name: widget.pdfFileName,
format: pageFormat,
);
if (result && widget.onPrinted != null) {
widget.onPrinted(context);
... ... @@ -383,7 +391,8 @@ class _PdfPreviewState extends State<PdfPreview> {
final bounds = Rect.fromPoints(topLeft, bottomRight);
final bytes = await widget.build(pageFormat);
final result = await Printing.sharePdf(bytes: bytes, bounds: bounds);
final result = await Printing.sharePdf(
bytes: bytes, bounds: bounds, filename: widget.pdfFileName);
if (result && widget.onShared != null) {
widget.onShared(context);
... ...
... ... @@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to
homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
repository: https://github.com/DavBfr/dart_pdf
issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 3.5.0
version: 3.6.0
environment:
sdk: ">=2.3.0 <3.0.0"
... ...