Showing
7 changed files
with
62 additions
and
4 deletions
| @@ -46,6 +46,18 @@ android { | @@ -46,6 +46,18 @@ android { | ||
| 46 | // TODO: Add your own signing config for the release build. | 46 | // TODO: Add your own signing config for the release build. |
| 47 | // Signing with the debug keys for now, so `flutter run --release` works. | 47 | // Signing with the debug keys for now, so `flutter run --release` works. |
| 48 | signingConfig signingConfigs.debug | 48 | signingConfig signingConfigs.debug |
| 49 | + minifyEnabled true | ||
| 50 | + useProguard true | ||
| 51 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
| 52 | + | ||
| 53 | + ndk { | ||
| 54 | + abiFilters 'armeabi-v7a' | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + debug { | ||
| 59 | + minifyEnabled false | ||
| 60 | + useProguard false | ||
| 49 | } | 61 | } |
| 50 | } | 62 | } |
| 51 | } | 63 | } |
| @@ -249,6 +249,8 @@ | @@ -249,6 +249,8 @@ | ||
| 249 | inputPaths = ( | 249 | inputPaths = ( |
| 250 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", | 250 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", |
| 251 | "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", | 251 | "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", |
| 252 | + "${BUILT_PRODUCTS_DIR}/flutter_full_pdf_viewer/flutter_full_pdf_viewer.framework", | ||
| 253 | + "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", | ||
| 252 | "${BUILT_PRODUCTS_DIR}/printing/printing.framework", | 254 | "${BUILT_PRODUCTS_DIR}/printing/printing.framework", |
| 253 | ); | 255 | ); |
| 254 | name = "[CP] Embed Pods Frameworks"; | 256 | name = "[CP] Embed Pods Frameworks"; |
| @@ -256,6 +258,8 @@ | @@ -256,6 +258,8 @@ | ||
| 256 | ); | 258 | ); |
| 257 | outputPaths = ( | 259 | outputPaths = ( |
| 258 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", | 260 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", |
| 261 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_full_pdf_viewer.framework", | ||
| 262 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", | ||
| 259 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/printing.framework", | 263 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/printing.framework", |
| 260 | ); | 264 | ); |
| 261 | runOnlyForDeploymentPostprocessing = 0; | 265 | runOnlyForDeploymentPostprocessing = 0; |
| @@ -5,12 +5,14 @@ import 'dart:ui' as ui; | @@ -5,12 +5,14 @@ import 'dart:ui' as ui; | ||
| 5 | 5 | ||
| 6 | import 'package:flutter/material.dart'; | 6 | import 'package:flutter/material.dart'; |
| 7 | import 'package:flutter/rendering.dart'; | 7 | import 'package:flutter/rendering.dart'; |
| 8 | +import 'package:path_provider/path_provider.dart'; | ||
| 8 | 9 | ||
| 9 | import 'package:pdf/pdf.dart'; | 10 | import 'package:pdf/pdf.dart'; |
| 10 | import 'package:pdf/widgets.dart' as pdf; | 11 | import 'package:pdf/widgets.dart' as pdf; |
| 11 | import 'package:printing/printing.dart'; | 12 | import 'package:printing/printing.dart'; |
| 12 | 13 | ||
| 13 | -import 'package:printing_example/document.dart'; | 14 | +import 'document.dart'; |
| 15 | +import 'viewer.dart'; | ||
| 14 | 16 | ||
| 15 | void main() => runApp(MaterialApp(home: MyApp())); | 17 | void main() => runApp(MaterialApp(home: MyApp())); |
| 16 | 18 | ||
| @@ -32,6 +34,19 @@ class MyAppState extends State<MyApp> { | @@ -32,6 +34,19 @@ class MyAppState extends State<MyApp> { | ||
| 32 | (await generateDocument(format)).save()); | 34 | (await generateDocument(format)).save()); |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 37 | + Future<void> _saveAsFile() async { | ||
| 38 | + Directory appDocDir = await getApplicationDocumentsDirectory(); | ||
| 39 | + String appDocPath = appDocDir.path; | ||
| 40 | + File file = File(appDocPath + '/' + 'document.pdf'); | ||
| 41 | + print('Save as file ${file.path} ...'); | ||
| 42 | + await file.writeAsBytes((await generateDocument(PdfPageFormat.a4)).save()); | ||
| 43 | + Navigator.push<dynamic>( | ||
| 44 | + context, | ||
| 45 | + MaterialPageRoute<dynamic>( | ||
| 46 | + builder: (BuildContext context) => PdfViewer(file: file)), | ||
| 47 | + ); | ||
| 48 | + } | ||
| 49 | + | ||
| 35 | Future<void> _sharePdf() async { | 50 | Future<void> _sharePdf() async { |
| 36 | print('Share ...'); | 51 | print('Share ...'); |
| 37 | final pdf.Document document = await generateDocument(PdfPageFormat.a4); | 52 | final pdf.Document document = await generateDocument(PdfPageFormat.a4); |
| @@ -117,6 +132,8 @@ class MyAppState extends State<MyApp> { | @@ -117,6 +132,8 @@ class MyAppState extends State<MyApp> { | ||
| 117 | RaisedButton( | 132 | RaisedButton( |
| 118 | child: const Text('Print Screenshot'), | 133 | child: const Text('Print Screenshot'), |
| 119 | onPressed: _printScreen), | 134 | onPressed: _printScreen), |
| 135 | + RaisedButton( | ||
| 136 | + child: const Text('Save to file'), onPressed: _saveAsFile), | ||
| 120 | ], | 137 | ], |
| 121 | ), | 138 | ), |
| 122 | ), | 139 | ), |
printing/example/lib/viewer.dart
0 → 100644
| 1 | +import 'dart:io'; | ||
| 2 | + | ||
| 3 | +import 'package:flutter/material.dart'; | ||
| 4 | +import 'package:flutter_full_pdf_viewer/flutter_full_pdf_viewer.dart'; | ||
| 5 | +import 'package:flutter_full_pdf_viewer/full_pdf_viewer_plugin.dart'; | ||
| 6 | +import 'package:flutter_full_pdf_viewer/full_pdf_viewer_scaffold.dart'; | ||
| 7 | + | ||
| 8 | +class PdfViewer extends StatelessWidget { | ||
| 9 | + const PdfViewer({this.file}); | ||
| 10 | + | ||
| 11 | + final File file; | ||
| 12 | + | ||
| 13 | + @override | ||
| 14 | + Widget build(BuildContext context) { | ||
| 15 | + return PDFViewerScaffold( | ||
| 16 | + appBar: AppBar( | ||
| 17 | + title: const Text('Document'), | ||
| 18 | + ), | ||
| 19 | + path: file.path); | ||
| 20 | + } | ||
| 21 | +} |
| @@ -10,8 +10,9 @@ dependencies: | @@ -10,8 +10,9 @@ dependencies: | ||
| 10 | flutter: | 10 | flutter: |
| 11 | sdk: flutter | 11 | sdk: flutter |
| 12 | printing: | 12 | printing: |
| 13 | - | ||
| 14 | - cupertino_icons: ^0.1.2 | 13 | + path_provider: |
| 14 | + flutter_full_pdf_viewer: | ||
| 15 | + cupertino_icons: | ||
| 15 | 16 | ||
| 16 | dev_dependencies: | 17 | dev_dependencies: |
| 17 | flutter_test: | 18 | flutter_test: |
| @@ -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: 2.0.2 | 7 | +version: 2.0.3 |
| 8 | 8 | ||
| 9 | environment: | 9 | environment: |
| 10 | sdk: ">=2.1.0 <3.0.0" | 10 | sdk: ">=2.1.0 <3.0.0" |
-
Please register or login to post a comment