@@ -19,14 +19,20 @@ class PDFDoc {
1919 PDFDoc ._internal ();
2020
2121 /// Creates a [PDFDoc] object with a [File] instance.
22- /// Optionally, takes a password for encrypted PDF documents.
23- static Future <PDFDoc > fromFile (File file, {String password = "" }) async {
22+ /// Optionally, takes a [password] for encrypted PDF documents.
23+ /// If [fastInit] is true, the initialization of the document will
24+ /// be faster on Android. In that case, the text stripper engine
25+ /// will not be initialized with this call, but later when some text
26+ /// is read. This means that the first text read will take some time
27+ /// but the document data can be accessed immediately.
28+ static Future <PDFDoc > fromFile (File file,
29+ {String password = "" , bool fastInit = false }) async {
2430 var doc = PDFDoc ._internal ();
2531 doc._file = file;
2632 Map data;
2733 try {
28- data = await _CHANNEL
29- . invokeMethod ( 'initDoc' , {"path" : file.path, "password" : password});
34+ data = await _CHANNEL . invokeMethod ( 'initDoc' ,
35+ {"path" : file.path, "password" : password, "fastInit" : fastInit });
3036 } on Exception catch (e) {
3137 return Future .error (e);
3238 }
@@ -39,16 +45,28 @@ class PDFDoc {
3945 }
4046
4147 /// Creates a [PDFDoc] object with a file path.
42- /// Optionally, takes a password for encrypted PDF documents.
43- static Future <PDFDoc > fromPath (String path, {String password = "" }) async {
44- return await fromFile (File (path), password: password);
48+ /// Optionally, takes a [password] for encrypted PDF documents.
49+ /// If [fastInit] is true, the initialization of the document will
50+ /// be faster on Android. In that case, the text stripper engine
51+ /// will not be initialized with this call, but later when some text
52+ /// is read. This means that the first text read will take some time
53+ /// but the document data can be accessed immediately.
54+ static Future <PDFDoc > fromPath (String path,
55+ {String password = "" , bool fastInit = false }) async {
56+ return await fromFile (File (path), password: password, fastInit: fastInit);
4557 }
4658
4759 /// Creates a [PDFDoc] object with a URL.
48- /// Optionally, takes a password for encrypted PDF documents.
60+ /// Optionally, takes a [password] for encrypted PDF documents.
61+ /// If [fastInit] is true, the initialization of the document will
62+ /// be faster on Android. In that case, the text stripper engine
63+ /// will not be initialized with this call, but later when some text
64+ /// is read. This means that the first text read will take some time
65+ /// but the document data can be accessed immediately.
4966 /// It downloads the PDF file located in the given URL and saves it
5067 /// in the app's temporary directory.
51- static Future <PDFDoc > fromURL (String url, {String password = "" }) async {
68+ static Future <PDFDoc > fromURL (String url,
69+ {String password = "" , bool fastInit = false }) async {
5270 File file;
5371 try {
5472 String tempDirPath = (await getTemporaryDirectory ()).path;
@@ -62,7 +80,7 @@ class PDFDoc {
6280 } on Exception catch (e) {
6381 return Future .error (e);
6482 }
65- return await fromFile (file, password: password);
83+ return await fromFile (file, password: password, fastInit : fastInit );
6684 }
6785
6886 /// Gets the page of the document at the given page number.
0 commit comments