document.dart
4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'dart:async';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/widgets.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';
import 'example_widgets.dart';
Future<pw.Document> generateDocument(PdfPageFormat format) async {
final pw.Document doc =
pw.Document(title: 'My Résumé', author: 'David PHAM-VAN');
final PdfImage profileImage = kIsWeb
? null
: await pdfImageFromImageProvider(
pdf: doc.document,
image: const NetworkImage(
'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&s=200'),
onError: (dynamic exception, StackTrace stackTrace) {
print('Unable to download image');
});
final pw.PageTheme pageTheme = myPageTheme(format);
doc.addPage(pw.Page(
pageTheme: pageTheme,
build: (pw.Context context) => pw.Row(children: <pw.Widget>[
pw.Expanded(
child: pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Container(
padding: const pw.EdgeInsets.only(left: 30, bottom: 20),
child: pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Text('Parnella Charlesbois',
textScaleFactor: 2,
style: pw.Theme.of(context)
.defaultTextStyle
.copyWith(fontWeight: pw.FontWeight.bold)),
pw.Padding(padding: const pw.EdgeInsets.only(top: 10)),
pw.Text('Electrotyper',
textScaleFactor: 1.2,
style: pw.Theme.of(context).defaultTextStyle.copyWith(
fontWeight: pw.FontWeight.bold, color: green)),
pw.Padding(padding: const pw.EdgeInsets.only(top: 20)),
pw.Row(
crossAxisAlignment: pw.CrossAxisAlignment.start,
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: <pw.Widget>[
pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Text('568 Port Washington Road'),
pw.Text('Nordegg, AB T0M 2H0'),
pw.Text('Canada, ON'),
]),
pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.start,
children: <pw.Widget>[
pw.Text('+1 403-721-6898'),
UrlText('p.charlesbois@yahoo.com',
'mailto:p.charlesbois@yahoo.com'),
UrlText('wholeprices.ca',
'https://wholeprices.ca'),
]),
pw.Padding(padding: pw.EdgeInsets.zero)
]),
])),
Category(title: 'Work Experience'),
Block(title: 'Tour bus driver'),
Block(title: 'Logging equipment operator'),
Block(title: 'Foot doctor'),
Category(title: 'Education'),
Block(title: 'Bachelor Of Commerce'),
Block(title: 'Bachelor Interior Design'),
])),
pw.Container(
height: double.infinity,
width: 2,
margin: const pw.EdgeInsets.symmetric(horizontal: 5),
color: green,
),
pw.Column(
crossAxisAlignment: pw.CrossAxisAlignment.center,
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: <pw.Widget>[
pw.ClipOval(
child: pw.Container(
width: 100,
height: 100,
color: lightGreen,
child: profileImage == null
? pw.Container()
: pw.Image(profileImage))),
pw.Column(children: <pw.Widget>[
Percent(size: 60, value: .7, title: pw.Text('Word')),
Percent(size: 60, value: .4, title: pw.Text('Excel')),
]),
pw.BarcodeWidget(
data: 'Parnella Charlesbois',
width: 60,
height: 60,
barcode: pw.Barcode.qrCode(),
),
],
)
]),
));
return doc;
}