interface.dart
3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/rendering.dart' show Rect;
import 'package:pdf/pdf.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'callback.dart';
import 'method_channel.dart';
import 'output_type.dart';
import 'printer.dart';
import 'printing_info.dart';
import 'raster.dart';
/// The interface that implementations of printing must implement.
abstract class PrintingPlatform extends PlatformInterface {
/// Constructs a PrintingPlatform.
PrintingPlatform() : super(token: _token);
static final Object _token = Object();
static PrintingPlatform _instance = MethodChannelPrinting();
/// The default instance of [PrintingPlatform] to use.
///
/// Defaults to [MethodChannelPrinting].
static PrintingPlatform get instance => _instance;
/// Platform-specific plugins should set this with their own platform-specific
/// class that extends [PrintingPlatform] when they register themselves.
static set instance(PrintingPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
/// Returns a [PrintingInfo] object representing the capabilities
/// supported for the current platform
Future<PrintingInfo> info();
/// Prints a Pdf document to a local printer using the platform UI
/// the Pdf document is re-built in a [LayoutCallback] each time the
/// user changes a setting like the page format or orientation.
///
/// returns a future with a `bool` set to true if the document is printed
/// and false if it is canceled.
/// throws an exception in case of error
Future<bool> layoutPdf(
Printer? printer,
LayoutCallback onLayout,
String name,
PdfPageFormat format,
bool dynamicLayout,
bool usePrinterSettings,
OutputType outputType,
bool forceCustomPrintPaper,
);
/// Enumerate the available printers on the system.
Future<List<Printer>> listPrinters();
/// Opens the native printer picker interface, and returns the URL of the selected printer.
Future<Printer?> pickPrinter(Rect bounds);
/// Displays a platform popup to share the Pdf document to another application.
///
/// [subject] will be the email subject if selected application is email.
///
/// [body] will be the extra text that can be shared along with the Pdf document.
/// For email application [body] will be the email body text.
///
/// [emails] will be the list of emails to which you want to share the Pdf document.
/// If the selected application is email application then the these [emails] will be
/// filled in the to address.
///
/// [subject] and [body] will only work for Android and iOS platforms.
/// [emails] will only work for Android Platform.
Future<bool> sharePdf(
Uint8List bytes,
String filename,
Rect bounds,
String? subject,
String? body,
List<String>? emails,
);
/// Convert an html document to a pdf data
Future<Uint8List> convertHtml(
String html,
String? baseUrl,
PdfPageFormat format,
);
/// Convert a Pdf document to bitmap images
Stream<PdfRaster> raster(
Uint8List document,
List<int>? pages,
double dpi,
);
}