Showing
4 changed files
with
11 additions
and
0 deletions
| @@ -16,6 +16,8 @@ | @@ -16,6 +16,8 @@ | ||
| 16 | 16 | ||
| 17 | part of printing; | 17 | part of printing; |
| 18 | 18 | ||
| 19 | +/// Loads an image from a Flutter [ui.Image] | ||
| 20 | +/// into a [PdfImage] instance | ||
| 19 | Future<PdfImage> pdfImageFromImage( | 21 | Future<PdfImage> pdfImageFromImage( |
| 20 | {@required PdfDocument pdf, @required ui.Image image}) async { | 22 | {@required PdfDocument pdf, @required ui.Image image}) async { |
| 21 | final ByteData bytes = | 23 | final ByteData bytes = |
| @@ -27,6 +29,8 @@ Future<PdfImage> pdfImageFromImage( | @@ -27,6 +29,8 @@ Future<PdfImage> pdfImageFromImage( | ||
| 27 | height: image.height); | 29 | height: image.height); |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 32 | +/// Loads an image from a Flutter [ImageProvider] | ||
| 33 | +/// into a [PdfImage] instance | ||
| 30 | Future<PdfImage> pdfImageFromImageProvider( | 34 | Future<PdfImage> pdfImageFromImageProvider( |
| 31 | {@required PdfDocument pdf, | 35 | {@required PdfDocument pdf, |
| 32 | @required ImageProvider image, | 36 | @required ImageProvider image, |
| @@ -41,6 +41,9 @@ mixin Printing { | @@ -41,6 +41,9 @@ mixin Printing { | ||
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | + /// Prints a Pdf document to a local printer using the platform UI | ||
| 45 | + /// the Pdf document is re-built in a [LayoutCallback] each time the | ||
| 46 | + /// user changes a setting like the page format or orientation. | ||
| 44 | static Future<void> layoutPdf( | 47 | static Future<void> layoutPdf( |
| 45 | {@required LayoutCallback onLayout, String name = 'Document'}) async { | 48 | {@required LayoutCallback onLayout, String name = 'Document'}) async { |
| 46 | _onLayout = onLayout; | 49 | _onLayout = onLayout; |
| @@ -49,6 +52,7 @@ mixin Printing { | @@ -49,6 +52,7 @@ mixin Printing { | ||
| 49 | await _channel.invokeMethod<void>('printPdf', params); | 52 | await _channel.invokeMethod<void>('printPdf', params); |
| 50 | } | 53 | } |
| 51 | 54 | ||
| 55 | + /// Prints a [PdfDocument] or a pdf stream to a local printer using the platform UI | ||
| 52 | @deprecated | 56 | @deprecated |
| 53 | static Future<void> printPdf({PdfDocument document, List<int> bytes}) async { | 57 | static Future<void> printPdf({PdfDocument document, List<int> bytes}) async { |
| 54 | assert(document != null || bytes != null); | 58 | assert(document != null || bytes != null); |
| @@ -59,6 +63,7 @@ mixin Printing { | @@ -59,6 +63,7 @@ mixin Printing { | ||
| 59 | document != null ? document.save() : bytes); | 63 | document != null ? document.save() : bytes); |
| 60 | } | 64 | } |
| 61 | 65 | ||
| 66 | + /// Displays a platform popup to share the Pdf document to another application | ||
| 62 | static Future<void> sharePdf( | 67 | static Future<void> sharePdf( |
| 63 | {PdfDocument document, List<int> bytes, Rect bounds}) async { | 68 | {PdfDocument document, List<int> bytes, Rect bounds}) async { |
| 64 | assert(document != null || bytes != null); | 69 | assert(document != null || bytes != null); |
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | part of printing; | 17 | part of printing; |
| 18 | 18 | ||
| 19 | class PdfDoc extends Document { | 19 | class PdfDoc extends Document { |
| 20 | + /// Wrapper for a [Document] with zlib compression enabled by default | ||
| 20 | PdfDoc({bool compress = true}) | 21 | PdfDoc({bool compress = true}) |
| 21 | : super(deflate: compress ? zlib.encode : null); | 22 | : super(deflate: compress ? zlib.encode : null); |
| 22 | } | 23 | } |
-
Please register or login to post a comment