Showing
14 changed files
with
32 additions
and
9 deletions
@@ -4,7 +4,7 @@ import 'package:pdf/pdf.dart'; | @@ -4,7 +4,7 @@ import 'package:pdf/pdf.dart'; | ||
4 | import 'package:pdf/widgets.dart'; | 4 | import 'package:pdf/widgets.dart'; |
5 | 5 | ||
6 | void main() { | 6 | void main() { |
7 | - final Document pdf = Document(deflate: zlib.encode); | 7 | + final Document pdf = Document(); |
8 | 8 | ||
9 | pdf.addPage(MultiPage( | 9 | pdf.addPage(MultiPage( |
10 | pageFormat: | 10 | pageFormat: |
@@ -26,6 +26,8 @@ import 'package:meta/meta.dart'; | @@ -26,6 +26,8 @@ import 'package:meta/meta.dart'; | ||
26 | import 'package:utf/utf.dart'; | 26 | import 'package:utf/utf.dart'; |
27 | import 'package:vector_math/vector_math_64.dart'; | 27 | import 'package:vector_math/vector_math_64.dart'; |
28 | 28 | ||
29 | +import 'src/io.dart' if (dart.library.io) 'src/archive.dart'; | ||
30 | + | ||
29 | part 'src/annotation.dart'; | 31 | part 'src/annotation.dart'; |
30 | part 'src/array.dart'; | 32 | part 'src/array.dart'; |
31 | part 'src/ascii85.dart'; | 33 | part 'src/ascii85.dart'; |
pdf/lib/src/archive.dart
0 → 100644
@@ -46,7 +46,11 @@ class PdfDocument { | @@ -46,7 +46,11 @@ class PdfDocument { | ||
46 | /// This creates a Pdf document | 46 | /// This creates a Pdf document |
47 | /// @param pagemode an int, determines how the document will present itself to | 47 | /// @param pagemode an int, determines how the document will present itself to |
48 | /// the viewer when it first opens. | 48 | /// the viewer when it first opens. |
49 | - PdfDocument({PdfPageMode pageMode = PdfPageMode.none, this.deflate}) { | 49 | + PdfDocument({ |
50 | + PdfPageMode pageMode = PdfPageMode.none, | ||
51 | + DeflateCallback deflate, | ||
52 | + bool compress = true, | ||
53 | + }) : deflate = compress ? (deflate ?? defaultDeflate) : null { | ||
50 | _objser = 1; | 54 | _objser = 1; |
51 | 55 | ||
52 | // Now create some standard objects | 56 | // Now create some standard objects |
pdf/lib/src/io.dart
0 → 100644
@@ -20,6 +20,7 @@ class Document { | @@ -20,6 +20,7 @@ class Document { | ||
20 | Document( | 20 | Document( |
21 | {PdfPageMode pageMode = PdfPageMode.none, | 21 | {PdfPageMode pageMode = PdfPageMode.none, |
22 | DeflateCallback deflate, | 22 | DeflateCallback deflate, |
23 | + bool compress = true, | ||
23 | this.theme, | 24 | this.theme, |
24 | String title, | 25 | String title, |
25 | String author, | 26 | String author, |
@@ -27,7 +28,11 @@ class Document { | @@ -27,7 +28,11 @@ class Document { | ||
27 | String subject, | 28 | String subject, |
28 | String keywords, | 29 | String keywords, |
29 | String producer}) | 30 | String producer}) |
30 | - : document = PdfDocument(pageMode: pageMode, deflate: deflate) { | 31 | + : document = PdfDocument( |
32 | + pageMode: pageMode, | ||
33 | + deflate: deflate, | ||
34 | + compress: compress, | ||
35 | + ) { | ||
31 | if (title != null || | 36 | if (title != null || |
32 | author != null || | 37 | author != null || |
33 | creator != null || | 38 | creator != null || |
@@ -34,7 +34,7 @@ class MyApp extends StatelessWidget { | @@ -34,7 +34,7 @@ class MyApp extends StatelessWidget { | ||
34 | } | 34 | } |
35 | 35 | ||
36 | List<int> buildPdf(PdfPageFormat format) { | 36 | List<int> buildPdf(PdfPageFormat format) { |
37 | - final PdfDoc doc = PdfDoc(); | 37 | + final Document doc = Document(); |
38 | 38 | ||
39 | doc.addPage( | 39 | doc.addPage( |
40 | pdf.Page( | 40 | pdf.Page( |
@@ -107,7 +107,7 @@ class Category extends StatelessWidget { | @@ -107,7 +107,7 @@ class Category extends StatelessWidget { | ||
107 | } | 107 | } |
108 | 108 | ||
109 | Future<Document> generateDocument(PdfPageFormat format) async { | 109 | Future<Document> generateDocument(PdfPageFormat format) async { |
110 | - final PdfDoc pdf = PdfDoc(title: 'My Résumé', author: 'David PHAM-VAN'); | 110 | + final Document pdf = Document(title: 'My Résumé', author: 'David PHAM-VAN'); |
111 | 111 | ||
112 | final PdfImage profileImage = await pdfImageFromImageProvider( | 112 | final PdfImage profileImage = await pdfImageFromImageProvider( |
113 | pdf: pdf.document, | 113 | pdf: pdf.document, |
@@ -74,7 +74,7 @@ class MyAppState extends State<MyApp> { | @@ -74,7 +74,7 @@ class MyAppState extends State<MyApp> { | ||
74 | print('Print Screen ${im.width}x${im.height} ...'); | 74 | print('Print Screen ${im.width}x${im.height} ...'); |
75 | 75 | ||
76 | Printing.layoutPdf(onLayout: (PdfPageFormat format) { | 76 | Printing.layoutPdf(onLayout: (PdfPageFormat format) { |
77 | - final pdf.Document document = PdfDoc(); | 77 | + final pdf.Document document = pdf.Document(); |
78 | 78 | ||
79 | final PdfImage image = PdfImage(document.document, | 79 | final PdfImage image = PdfImage(document.document, |
80 | image: bytes.buffer.asUint8List(), | 80 | image: bytes.buffer.asUint8List(), |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | 16 | ||
17 | part of printing; | 17 | part of printing; |
18 | 18 | ||
19 | +@deprecated | ||
19 | class PdfDoc extends Document { | 20 | class PdfDoc extends Document { |
20 | /// Wrapper for a [Document] with zlib compression enabled by default | 21 | /// Wrapper for a [Document] with zlib compression enabled by default |
21 | PdfDoc( | 22 | PdfDoc( |
@@ -29,7 +30,7 @@ class PdfDoc extends Document { | @@ -29,7 +30,7 @@ class PdfDoc extends Document { | ||
29 | String keywords, | 30 | String keywords, |
30 | String producer}) | 31 | String producer}) |
31 | : super( | 32 | : super( |
32 | - deflate: compress ? zlib.encode : null, | 33 | + compress: compress, |
33 | pageMode: pageMode, | 34 | pageMode: pageMode, |
34 | theme: theme, | 35 | theme: theme, |
35 | title: title, | 36 | title: title, |
-
Please register or login to post a comment