Showing
5 changed files
with
37 additions
and
6 deletions
@@ -3,3 +3,5 @@ | @@ -3,3 +3,5 @@ | ||
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> | ||
7 | +* flutter printing: <https://pub.dartlang.org/packages/printing> |
@@ -4,6 +4,9 @@ This is a low-level Pdf creation library. | @@ -4,6 +4,9 @@ This is a low-level Pdf creation library. | ||
4 | It can create a full multi-pages document with graphics, | 4 | It can create a full multi-pages document with graphics, |
5 | images and text using TrueType fonts. | 5 | images and text using TrueType fonts. |
6 | 6 | ||
7 | +> Use `printing` package <https://pub.dartlang.org/packages/printing> | ||
8 | +> for full flutter print and share operation. | ||
9 | + | ||
7 | The coordinate system is using the internal Pdf system: | 10 | The coordinate system is using the internal Pdf system: |
8 | * (0.0, 0.0) is bottom-left | 11 | * (0.0, 0.0) is bottom-left |
9 | * 1.0 is defined as 1 / 72.0 inch | 12 | * 1.0 is defined as 1 / 72.0 inch |
@@ -27,7 +30,7 @@ var file = new File('file.pdf'); | @@ -27,7 +30,7 @@ var file = new File('file.pdf'); | ||
27 | file.writeAsBytesSync(pdf.save()); | 30 | file.writeAsBytesSync(pdf.save()); |
28 | ``` | 31 | ``` |
29 | 32 | ||
30 | -To load an image it is possible to use the dart library `image` | 33 | +To load an image it is possible to use the dart library [image](https://pub.dartlang.org/packages/image): |
31 | 34 | ||
32 | ```dart | 35 | ```dart |
33 | Image image = decodeImage(new Io.File('test.webp').readAsBytesSync()); | 36 | Image image = decodeImage(new Io.File('test.webp').readAsBytesSync()); |
1 | # Printing | 1 | # Printing |
2 | 2 | ||
3 | -Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers | 3 | +Plugin that allows Flutter apps to generate and print |
4 | +documents to android or ios compatible printers | ||
4 | 5 | ||
5 | -## Getting Started | 6 | +See the example on how to use the plugin. |
6 | 7 | ||
7 | -For help getting started with Flutter, view our online | ||
8 | -[documentation](https://flutter.io/). | 8 | +> This plugin uses the `pdf` package <https://pub.dartlang.org/packages/pdf> |
9 | +> for pdf creation. Please refer to <https://pub.dartlang.org/documentation/pdf/latest/> | ||
10 | +> for documentation. | ||
9 | 11 | ||
10 | -For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package). | 12 | +To load an image it is possible to use |
13 | +[Image.toByteData](https://docs.flutter.io/flutter/dart-ui/Image/toByteData.html): | ||
14 | + | ||
15 | +```dart | ||
16 | +var Image im; | ||
17 | +var bytes = await im.toByteData(format: ui.ImageByteFormat.rawRgba); | ||
18 | + | ||
19 | +PDFImage image = PDFImage( | ||
20 | + pdf, | ||
21 | + image: bytes.buffer.asUint8List(), | ||
22 | + width: im.width, | ||
23 | + height: im.height); | ||
24 | +g.drawImage(image, 100.0, 100.0, 80.0); | ||
25 | +``` | ||
26 | + | ||
27 | +To use a TrueType font from a flutter bundle: | ||
28 | + | ||
29 | +```dart | ||
30 | +var font = await rootBundle.load("assets/open-sans.ttf"); | ||
31 | +PDFTTFFont ttf = new PDFTTFFont(pdf, font); | ||
32 | +g.setColor(new PDFColor(0.3, 0.3, 0.3)); | ||
33 | +g.drawString(ttf, 20.0, "Dart is awesome", 50.0, 30.0); | ||
34 | +``` |
-
Please register or login to post a comment