Showing
3 changed files
with
45 additions
and
2 deletions
1 | +# Pdf creation library for dart / flutter | ||
2 | + | ||
3 | +Example: | ||
4 | +```dart | ||
5 | +final pdf = new PDFDocument(); | ||
6 | +final page = new PDFPage(pdf, pageFormat: new PDFPageFormat(PDFPageFormat.LETTER)); | ||
7 | +final g = page.getGraphics(); | ||
8 | +final font = new PDFFont(pdf); | ||
9 | + | ||
10 | +g.setColor(new PDFColor(0.0, 1.0, 1.0)); | ||
11 | +g.drawRect(50.0, 30.0, 100.0, 50.0); | ||
12 | +g.fillPath(); | ||
13 | + | ||
14 | +g.setColor(new PDFColor(0.3, 0.3, 0.3)); | ||
15 | +g.drawString(font, 12.0, "Hello World!", 50.0, 300.0); | ||
16 | + | ||
17 | +var file = new File('file.pdf'); | ||
18 | +file.writeAsBytesSync(pdf.save()); | ||
19 | +``` |
@@ -4,9 +4,13 @@ description: A pdf producer for Dart | @@ -4,9 +4,13 @@ description: A pdf producer for Dart | ||
4 | homepage: https://github.com/davbfr/dart_pdf | 4 | homepage: https://github.com/davbfr/dart_pdf |
5 | version: 1.0.0 | 5 | version: 1.0.0 |
6 | 6 | ||
7 | +environment: | ||
8 | + sdk: ">=1.8.0 <2.0.0" | ||
9 | + | ||
7 | dependencies: | 10 | dependencies: |
11 | + meta: "^1.1.5" | ||
8 | ttf_parser: "^1.0.0" | 12 | ttf_parser: "^1.0.0" |
9 | - vector_math: | 13 | + vector_math: "^2.0.7" |
10 | 14 | ||
11 | dev_dependencies: | 15 | dev_dependencies: |
12 | - test: "^0.12.32+1" | ||
16 | + test: any |
test/example.dart
0 → 100644
1 | +import 'dart:io'; | ||
2 | + | ||
3 | +import 'package:pdf/pdf.dart'; | ||
4 | + | ||
5 | +void main() { | ||
6 | + final pdf = new PDFDocument(); | ||
7 | + final page = new PDFPage(pdf, pageFormat: new PDFPageFormat(PDFPageFormat.LETTER)); | ||
8 | + final g = page.getGraphics(); | ||
9 | + final font = new PDFFont(pdf); | ||
10 | + | ||
11 | + g.setColor(new PDFColor(0.0, 1.0, 1.0)); | ||
12 | + g.drawRect(50.0, 30.0, 100.0, 50.0); | ||
13 | + g.fillPath(); | ||
14 | + | ||
15 | + g.setColor(new PDFColor(0.3, 0.3, 0.3)); | ||
16 | + g.drawString(font, 12.0, "Hello World!", 50.0, 300.0); | ||
17 | + | ||
18 | + var file = new File('file.pdf'); | ||
19 | + file.writeAsBytesSync(pdf.save()); | ||
20 | +} |
-
Please register or login to post a comment