Showing
5 changed files
with
127 additions
and
67 deletions
1 | # Pdf for Dart and Flutter | 1 | # Pdf for Dart and Flutter |
2 | 2 | ||
3 | -This set of plugin allows Flutter apps to generate and print pdf files to device printer. | 3 | +This set of plugin allows Flutter apps to generate and print pdf files to device printer. |
4 | This plugin works for iOS and Android. | 4 | This plugin works for iOS and Android. |
5 | 5 | ||
6 | * dart pdf: <https://pub.dartlang.org/packages/pdf> | 6 | * dart pdf: <https://pub.dartlang.org/packages/pdf> |
1 | -# 1.3.13 | 1 | +## 1.3.13 |
2 | + | ||
2 | * Do not modify the TTF font streams | 3 | * Do not modify the TTF font streams |
3 | 4 | ||
4 | -# 1.3.12 | 5 | +## 1.3.12 |
6 | + | ||
5 | * Fix TextStyle constructor | 7 | * Fix TextStyle constructor |
6 | 8 | ||
7 | -# 1.3.11 | 9 | +## 1.3.11 |
10 | + | ||
8 | * Update Readme | 11 | * Update Readme |
9 | 12 | ||
10 | -# 1.3.10 | 13 | +## 1.3.10 |
14 | + | ||
11 | * Deprecate the document argument in Printing.sharePdf() | 15 | * Deprecate the document argument in Printing.sharePdf() |
12 | * Add default value to alpha in PdfColor variants | 16 | * Add default value to alpha in PdfColor variants |
13 | * Fix Table Widget | 17 | * Fix Table Widget |
14 | * Add Flexible and Spacer Widgets | 18 | * Add Flexible and Spacer Widgets |
15 | 19 | ||
16 | -# 1.3.9 | 20 | +## 1.3.9 |
21 | + | ||
17 | * Fix Transform Widget alignment | 22 | * Fix Transform Widget alignment |
18 | * Fix CustomPaint Widget size | 23 | * Fix CustomPaint Widget size |
19 | * Add DecorationImage to BoxDecoration | 24 | * Add DecorationImage to BoxDecoration |
20 | * Add default values to ClipRRect | 25 | * Add default values to ClipRRect |
21 | 26 | ||
22 | -# 1.3.8 | 27 | +## 1.3.8 |
28 | + | ||
23 | * Add jpeg image loading function | 29 | * Add jpeg image loading function |
24 | * Add Theme::copyFrom() method | 30 | * Add Theme::copyFrom() method |
25 | * Allow Annotations in TextSpan | 31 | * Allow Annotations in TextSpan |
@@ -29,21 +35,25 @@ | @@ -29,21 +35,25 @@ | ||
29 | * Implement properly RichText.softWrap | 35 | * Implement properly RichText.softWrap |
30 | * Set a proper value to context.pagesCount | 36 | * Set a proper value to context.pagesCount |
31 | 37 | ||
32 | -# 1.3.7 | 38 | +## 1.3.7 |
39 | + | ||
33 | * Add Pdf Creation date | 40 | * Add Pdf Creation date |
34 | * Support 64k glyphs per TTF font | 41 | * Support 64k glyphs per TTF font |
35 | 42 | ||
36 | -# 1.3.6 | 43 | +## 1.3.6 |
44 | + | ||
37 | * Fix TTF Font SubSetting | 45 | * Fix TTF Font SubSetting |
38 | 46 | ||
39 | -# 1.3.5 | 47 | +## 1.3.5 |
48 | + | ||
40 | * Add some color functions | 49 | * Add some color functions |
41 | * Remove color constants from PdfColor, use PdfColors | 50 | * Remove color constants from PdfColor, use PdfColors |
42 | * Add TTF Font SubSetting | 51 | * Add TTF Font SubSetting |
43 | * Add Unicode support for TTF Fonts | 52 | * Add Unicode support for TTF Fonts |
44 | * Add Circular Progress Indicator | 53 | * Add Circular Progress Indicator |
45 | 54 | ||
46 | -# 1.3.4 | 55 | +## 1.3.4 |
56 | + | ||
47 | * Add available dimensions for PdfPageFormat | 57 | * Add available dimensions for PdfPageFormat |
48 | * Add Document properties | 58 | * Add Document properties |
49 | * Add Page.orientation to force landscape or portrait | 59 | * Add Page.orientation to force landscape or portrait |
@@ -52,12 +62,14 @@ | @@ -52,12 +62,14 @@ | ||
52 | * Add all Material Colors | 62 | * Add all Material Colors |
53 | * Add Hyperlink widgets | 63 | * Add Hyperlink widgets |
54 | 64 | ||
55 | -# 1.3.3 | 65 | +## 1.3.3 |
66 | + | ||
56 | * Fix a bug with the RichText Widget | 67 | * Fix a bug with the RichText Widget |
57 | * Update code to Dart 2.1.0 | 68 | * Update code to Dart 2.1.0 |
58 | * Add Document.save() method | 69 | * Add Document.save() method |
59 | 70 | ||
60 | -# 1.3.2 | 71 | +## 1.3.2 |
72 | + | ||
61 | * Fix dart lint warnings | 73 | * Fix dart lint warnings |
62 | * Improve font bounds calculation | 74 | * Improve font bounds calculation |
63 | * Add RichText Widget | 75 | * Add RichText Widget |
@@ -65,19 +77,23 @@ | @@ -65,19 +77,23 @@ | ||
65 | * Add Stack Widget | 77 | * Add Stack Widget |
66 | * Update Readme | 78 | * Update Readme |
67 | 79 | ||
68 | -# 1.3.1 | 80 | +## 1.3.1 |
81 | + | ||
69 | * Fix pana linting notices | 82 | * Fix pana linting notices |
70 | 83 | ||
71 | -# 1.3.0 | 84 | +## 1.3.0 |
85 | + | ||
72 | * Add a Flutter like widget system | 86 | * Add a Flutter like widget system |
73 | 87 | ||
74 | -# 1.2.0 | 88 | +## 1.2.0 |
89 | + | ||
75 | * Change license to Apache 2.0 | 90 | * Change license to Apache 2.0 |
76 | * Improve PdfRect | 91 | * Improve PdfRect |
77 | * Add support for CMYK, HSL anf HSV colors | 92 | * Add support for CMYK, HSL anf HSV colors |
78 | * Implement rounded rect | 93 | * Implement rounded rect |
79 | 94 | ||
80 | -# 1.1.1 | 95 | +## 1.1.1 |
96 | + | ||
81 | * Improve PdfPoint and PdfRect | 97 | * Improve PdfPoint and PdfRect |
82 | * Change PdfColor.fromInt to const constructor | 98 | * Change PdfColor.fromInt to const constructor |
83 | * Fix drawShape Bézier curves | 99 | * Fix drawShape Bézier curves |
@@ -85,7 +101,8 @@ | @@ -85,7 +101,8 @@ | ||
85 | * Add default page margins | 101 | * Add default page margins |
86 | * Change license to Apache 2.0 | 102 | * Change license to Apache 2.0 |
87 | 103 | ||
88 | -# 1.1.0 | 104 | +## 1.1.0 |
105 | + | ||
89 | * Rename classes to satisfy Dart conventions | 106 | * Rename classes to satisfy Dart conventions |
90 | * Remove useless new and const keywords | 107 | * Remove useless new and const keywords |
91 | * Mark some internal functions as protected | 108 | * Mark some internal functions as protected |
@@ -98,32 +115,44 @@ | @@ -98,32 +115,44 @@ | ||
98 | * Add unicode support for annotations and info block | 115 | * Add unicode support for annotations and info block |
99 | * Add Flutter example | 116 | * Add Flutter example |
100 | 117 | ||
101 | -# 1.0.8 | 118 | +## 1.0.8 |
119 | + | ||
102 | * Fix monospace TTF font loading | 120 | * Fix monospace TTF font loading |
103 | * Add PDFPageFormat::toString | 121 | * Add PDFPageFormat::toString |
104 | 122 | ||
105 | -# 1.0.7 | 123 | +## 1.0.7 |
124 | + | ||
106 | * Use lowercase page dimension constants | 125 | * Use lowercase page dimension constants |
107 | 126 | ||
108 | -# 1.0.6 | 127 | +## 1.0.6 |
128 | + | ||
109 | * Fix TTF font name lookup | 129 | * Fix TTF font name lookup |
110 | 130 | ||
111 | -# 1.0.5 | 131 | +## 1.0.5 |
132 | + | ||
112 | * Remove dependency to dart:io | 133 | * Remove dependency to dart:io |
113 | * Add Contributing | 134 | * Add Contributing |
114 | 135 | ||
115 | -# 1.0.4 | 136 | +## 1.0.4 |
137 | + | ||
116 | * Updated homepage | 138 | * Updated homepage |
117 | * Update source formatting | 139 | * Update source formatting |
118 | * Update README | 140 | * Update README |
119 | 141 | ||
120 | -# 1.0.3 | 142 | +## 1.0.3 |
143 | + | ||
121 | * Remove dependency to ttf_parser | 144 | * Remove dependency to ttf_parser |
122 | 145 | ||
123 | -# 1.0.2 | 146 | +## 1.0.2 |
147 | + | ||
124 | * Update sdk support for 2.0.0 | 148 | * Update sdk support for 2.0.0 |
125 | 149 | ||
126 | -# 1.0.1 | 150 | +## 1.0.1 |
151 | + | ||
127 | * Add example | 152 | * Add example |
128 | * Lower vector_math dependency version | 153 | * Lower vector_math dependency version |
129 | * Uses better page format object | 154 | * Uses better page format object |
155 | + | ||
156 | +## 1.0.0 | ||
157 | + | ||
158 | +* Initial version |
@@ -14,10 +14,12 @@ Use the `printing` package <https://pub.dartlang.org/packages/printing> | @@ -14,10 +14,12 @@ Use the `printing` package <https://pub.dartlang.org/packages/printing> | ||
14 | for full flutter print and share operation. | 14 | for full flutter print and share operation. |
15 | 15 | ||
16 | The coordinate system is using the internal Pdf unit: | 16 | The coordinate system is using the internal Pdf unit: |
17 | - * 1.0 is defined as 1 / 72.0 inch | ||
18 | - * you can use the constants for centimeters, milimeters and inch defined in PdfPageFormat | 17 | + |
18 | +* 1.0 is defined as 1 / 72.0 inch | ||
19 | +* you can use the constants for centimeters, millimeters and inch defined in PdfPageFormat | ||
19 | 20 | ||
20 | Example: | 21 | Example: |
22 | + | ||
21 | ```dart | 23 | ```dart |
22 | final pdf = Document(); | 24 | final pdf = Document(); |
23 | 25 | ||
@@ -36,9 +38,9 @@ To load an image it is possible to use the dart library [image](https://pub.dart | @@ -36,9 +38,9 @@ To load an image it is possible to use the dart library [image](https://pub.dart | ||
36 | final img = decodeImage(File('test.webp').readAsBytesSync()); | 38 | final img = decodeImage(File('test.webp').readAsBytesSync()); |
37 | final image = PdfImage( | 39 | final image = PdfImage( |
38 | pdf.document, | 40 | pdf.document, |
39 | - image: img.data.buffer.asUint8List(), | ||
40 | - width: img.width, | ||
41 | - height: img.height, | 41 | + image: img.data.buffer.asUint8List(), |
42 | + width: img.width, | ||
43 | + height: img.height, | ||
42 | ); | 44 | ); |
43 | 45 | ||
44 | pdf.addPage(Page( | 46 | pdf.addPage(Page( |
1 | -# 2.0.4 | 1 | +## 2.0.4 |
2 | + | ||
2 | * Update Readme | 3 | * Update Readme |
3 | 4 | ||
4 | -# 2.0.3 | 5 | +## 2.0.3 |
6 | + | ||
5 | * Add file save and view to example application | 7 | * Add file save and view to example application |
6 | * Convert print screen example to Widgets | 8 | * Convert print screen example to Widgets |
7 | * Deprecate the document argument in Printing.sharePdf() | 9 | * Deprecate the document argument in Printing.sharePdf() |
8 | 10 | ||
9 | -# 2.0.2 | 11 | +## 2.0.2 |
12 | + | ||
10 | * Fix example application | 13 | * Fix example application |
11 | 14 | ||
12 | -# 2.0.1 | 15 | +## 2.0.1 |
16 | + | ||
13 | * Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0 | 17 | * Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0 |
14 | 18 | ||
15 | -# 2.0.0 | 19 | +## 2.0.0 |
20 | + | ||
16 | * Breaking change: Switch libraries to AndroidX | 21 | * Breaking change: Switch libraries to AndroidX |
17 | * Add Page information to PdfDoc object | 22 | * Add Page information to PdfDoc object |
18 | 23 | ||
19 | -# 1.3.5 | 24 | +## 1.3.5 |
25 | + | ||
20 | * Restore compatibility with Flutter 1.0.0 | 26 | * Restore compatibility with Flutter 1.0.0 |
21 | * Update code to Dart 2.1.0 | 27 | * Update code to Dart 2.1.0 |
22 | * Depends on pdf 1.3.3 | 28 | * Depends on pdf 1.3.3 |
23 | 29 | ||
24 | -# 1.3.4 | 30 | +## 1.3.4 |
31 | + | ||
25 | * Fix iOS build with Swift | 32 | * Fix iOS build with Swift |
26 | * Add installation instructions in the Readme | 33 | * Add installation instructions in the Readme |
27 | * Follow Flutter debug painting settings | 34 | * Follow Flutter debug painting settings |
28 | 35 | ||
29 | -# 1.3.3 | 36 | +## 1.3.3 |
37 | + | ||
30 | * Fix dart lint warnings | 38 | * Fix dart lint warnings |
31 | * Add documentation | 39 | * Add documentation |
32 | * Add a filename parameter for sharing | 40 | * Add a filename parameter for sharing |
33 | * Convert Objective-C code to Swift | 41 | * Convert Objective-C code to Swift |
34 | * Update Readme | 42 | * Update Readme |
35 | 43 | ||
36 | -# 1.3.2 | 44 | +## 1.3.2 |
45 | + | ||
37 | * Fix iOS printing issues | 46 | * Fix iOS printing issues |
38 | 47 | ||
39 | -# 1.3.1 | 48 | +## 1.3.1 |
49 | + | ||
40 | * Fix pana linting notices | 50 | * Fix pana linting notices |
41 | 51 | ||
42 | -# 1.3.0 | 52 | +## 1.3.0 |
53 | + | ||
43 | * Add a Flutter like widget system | 54 | * Add a Flutter like widget system |
44 | 55 | ||
45 | -# 1.2.0 | 56 | +## 1.2.0 |
57 | + | ||
46 | * Fix compileSdkVersion to match appcompat | 58 | * Fix compileSdkVersion to match appcompat |
47 | * Change license to Apache 2.0 | 59 | * Change license to Apache 2.0 |
48 | * Implement asynchronous printing driven by the OS | 60 | * Implement asynchronous printing driven by the OS |
49 | 61 | ||
50 | -# 1.1.0 | 62 | +## 1.1.0 |
63 | + | ||
51 | * Rename classes to satisfy Dart conventions | 64 | * Rename classes to satisfy Dart conventions |
52 | * Remove useless new and const keywords | 65 | * Remove useless new and const keywords |
53 | * Changed appcompat dependency to 26.1.0 | 66 | * Changed appcompat dependency to 26.1.0 |
54 | 67 | ||
55 | -# 1.0.6 | 68 | +## 1.0.6 |
69 | + | ||
56 | * Add screenshot example | 70 | * Add screenshot example |
57 | 71 | ||
58 | -# 1.0.5 | 72 | +## 1.0.5 |
73 | + | ||
59 | * Fix printing from pdf document | 74 | * Fix printing from pdf document |
60 | 75 | ||
61 | -# 1.0.4 | 76 | +## 1.0.4 |
77 | + | ||
62 | * Update example for pdf 1.0.5 | 78 | * Update example for pdf 1.0.5 |
63 | * Add Contributing | 79 | * Add Contributing |
64 | 80 | ||
65 | -# 1.0.3 | 81 | +## 1.0.3 |
82 | + | ||
66 | * Update source formatting | 83 | * Update source formatting |
67 | * Update README | 84 | * Update README |
68 | 85 | ||
69 | -# 1.0.2 | 86 | +## 1.0.2 |
87 | + | ||
70 | * Add License file | 88 | * Add License file |
71 | * Updated homepage | 89 | * Updated homepage |
72 | 90 | ||
73 | -# 1.0.1 | 91 | +## 1.0.1 |
92 | + | ||
74 | * Fixed sdk version | 93 | * Fixed sdk version |
75 | 94 | ||
76 | -# 1.0.0 | 95 | +## 1.0.0 |
96 | + | ||
77 | * Initial release. | 97 | * Initial release. |
1 | # Pdf Printing Example | 1 | # Pdf Printing Example |
2 | 2 | ||
3 | ```dart | 3 | ```dart |
4 | -import 'dart:async'; | ||
5 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
6 | 5 | ||
7 | import 'package:pdf/pdf.dart'; | 6 | import 'package:pdf/pdf.dart'; |
8 | -import 'package:pdf/widgets.dart' as Pdf; | 7 | +import 'package:pdf/widgets.dart' as pdf; |
9 | import 'package:printing/printing.dart'; | 8 | import 'package:printing/printing.dart'; |
10 | 9 | ||
11 | void main() => runApp(MyApp()); | 10 | void main() => runApp(MyApp()); |
@@ -22,28 +21,38 @@ class MyApp extends StatelessWidget { | @@ -22,28 +21,38 @@ class MyApp extends StatelessWidget { | ||
22 | child: const Icon(Icons.print), | 21 | child: const Icon(Icons.print), |
23 | tooltip: 'Print Document', | 22 | tooltip: 'Print Document', |
24 | onPressed: () { | 23 | onPressed: () { |
25 | - Printing.layoutPdf(onLayout: buildPdf); | 24 | + Printing.layoutPdf( |
25 | + onLayout: buildPdf, | ||
26 | + ); | ||
26 | }, | 27 | }, |
27 | ), | 28 | ), |
28 | - body: Center(child: const Text('Click on the print button below')), | 29 | + body: Center( |
30 | + child: const Text('Click on the print button below'), | ||
31 | + ), | ||
29 | ), | 32 | ), |
30 | ); | 33 | ); |
31 | } | 34 | } |
32 | 35 | ||
33 | List<int> buildPdf(PdfPageFormat format) { | 36 | List<int> buildPdf(PdfPageFormat format) { |
34 | - final PdfDoc pdf = PdfDoc() | ||
35 | - ..addPage(Pdf.Page( | ||
36 | - pageFormat: format, | ||
37 | - build: (Pdf.Context context) { | ||
38 | - return Pdf.ConstrainedBox( | ||
39 | - constraints: const Pdf.BoxConstraints.expand(), | ||
40 | - child: Pdf.FittedBox( | ||
41 | - child: Pdf.Text( | 37 | + final PdfDoc doc = PdfDoc(); |
38 | + | ||
39 | + doc.addPage( | ||
40 | + pdf.Page( | ||
41 | + pageFormat: format, | ||
42 | + build: (pdf.Context context) { | ||
43 | + return pdf.ConstrainedBox( | ||
44 | + constraints: const pdf.BoxConstraints.expand(), | ||
45 | + child: pdf.FittedBox( | ||
46 | + child: pdf.Text( | ||
42 | 'Hello World', | 47 | 'Hello World', |
43 | - )), | ||
44 | - ); | ||
45 | - })); | ||
46 | - return pdf.save(); | 48 | + ), |
49 | + ), | ||
50 | + ); | ||
51 | + }, | ||
52 | + ), | ||
53 | + ); | ||
54 | + | ||
55 | + return doc.save(); | ||
47 | } | 56 | } |
48 | } | 57 | } |
49 | ``` | 58 | ``` |
-
Please register or login to post a comment