Showing
3 changed files
with
120 additions
and
87 deletions
| @@ -545,7 +545,7 @@ String _formatCurrency(double amount) { | @@ -545,7 +545,7 @@ String _formatCurrency(double amount) { | ||
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | String _formatDate(DateTime date) { | 547 | String _formatDate(DateTime date) { |
| 548 | - final format = DateFormat.yMMMMd('en_US'); | 548 | + final format = DateFormat.yMMMd('en_US'); |
| 549 | return format.format(date); | 549 | return format.format(date); |
| 550 | } | 550 | } |
| 551 | 551 |
| @@ -223,7 +223,7 @@ Future<Uint8List> generateReport(PdfPageFormat pageFormat) async { | @@ -223,7 +223,7 @@ Future<Uint8List> generateReport(PdfPageFormat pageFormat) async { | ||
| 223 | ), | 223 | ), |
| 224 | ), | 224 | ), |
| 225 | pw.Text( | 225 | pw.Text( |
| 226 | - 'Budget was originally \$1915. A total of \$1990 was spent on the month os January which exceeded the overall budget by \$75', | 226 | + 'Budget was originally \$1915. A total of \$1990 was spent on the month of January which exceeded the overall budget by \$75', |
| 227 | textAlign: pw.TextAlign.justify, | 227 | textAlign: pw.TextAlign.justify, |
| 228 | ) | 228 | ) |
| 229 | ], | 229 | ], |
| @@ -26,6 +26,7 @@ import 'package:pdf/widgets.dart' as pw; | @@ -26,6 +26,7 @@ import 'package:pdf/widgets.dart' as pw; | ||
| 26 | 26 | ||
| 27 | const PdfColor green = PdfColor.fromInt(0xff9ce5d0); | 27 | const PdfColor green = PdfColor.fromInt(0xff9ce5d0); |
| 28 | const PdfColor lightGreen = PdfColor.fromInt(0xffcdf1e7); | 28 | const PdfColor lightGreen = PdfColor.fromInt(0xffcdf1e7); |
| 29 | +const sep = 120.0; | ||
| 29 | 30 | ||
| 30 | Future<Uint8List> generateResume(PdfPageFormat format) async { | 31 | Future<Uint8List> generateResume(PdfPageFormat format) async { |
| 31 | final pw.Document doc = | 32 | final pw.Document doc = |
| @@ -38,102 +39,127 @@ Future<Uint8List> generateResume(PdfPageFormat format) async { | @@ -38,102 +39,127 @@ Future<Uint8List> generateResume(PdfPageFormat format) async { | ||
| 38 | 39 | ||
| 39 | final pw.PageTheme pageTheme = await _myPageTheme(format); | 40 | final pw.PageTheme pageTheme = await _myPageTheme(format); |
| 40 | 41 | ||
| 41 | - doc.addPage(pw.Page( | ||
| 42 | - pageTheme: pageTheme, | ||
| 43 | - build: (pw.Context context) => pw.Row(children: <pw.Widget>[ | ||
| 44 | - pw.Expanded( | ||
| 45 | - child: pw.Column( | ||
| 46 | - crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 47 | - children: <pw.Widget>[ | ||
| 48 | - pw.Container( | ||
| 49 | - padding: const pw.EdgeInsets.only(left: 30, bottom: 20), | ||
| 50 | - child: pw.Column( | ||
| 51 | - crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 52 | - children: <pw.Widget>[ | ||
| 53 | - pw.Text('Parnella Charlesbois', | ||
| 54 | - textScaleFactor: 2, | ||
| 55 | - style: pw.Theme.of(context) | ||
| 56 | - .defaultTextStyle | ||
| 57 | - .copyWith(fontWeight: pw.FontWeight.bold)), | ||
| 58 | - pw.Padding(padding: const pw.EdgeInsets.only(top: 10)), | ||
| 59 | - pw.Text('Electrotyper', | ||
| 60 | - textScaleFactor: 1.2, | ||
| 61 | - style: pw.Theme.of(context).defaultTextStyle.copyWith( | ||
| 62 | - fontWeight: pw.FontWeight.bold, color: green)), | ||
| 63 | - pw.Padding(padding: const pw.EdgeInsets.only(top: 20)), | ||
| 64 | - pw.Row( | 42 | + doc.addPage( |
| 43 | + pw.MultiPage( | ||
| 44 | + pageTheme: pageTheme, | ||
| 45 | + build: (pw.Context context) => [ | ||
| 46 | + pw.Partitions( | ||
| 47 | + children: [ | ||
| 48 | + pw.Partition( | ||
| 49 | + child: pw.Column( | ||
| 50 | + crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 51 | + children: <pw.Widget>[ | ||
| 52 | + pw.Container( | ||
| 53 | + padding: const pw.EdgeInsets.only(left: 30, bottom: 20), | ||
| 54 | + child: pw.Column( | ||
| 55 | + crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 56 | + children: <pw.Widget>[ | ||
| 57 | + pw.Text('Parnella Charlesbois', | ||
| 58 | + textScaleFactor: 2, | ||
| 59 | + style: pw.Theme.of(context) | ||
| 60 | + .defaultTextStyle | ||
| 61 | + .copyWith(fontWeight: pw.FontWeight.bold)), | ||
| 62 | + pw.Padding(padding: const pw.EdgeInsets.only(top: 10)), | ||
| 63 | + pw.Text('Electrotyper', | ||
| 64 | + textScaleFactor: 1.2, | ||
| 65 | + style: pw.Theme.of(context) | ||
| 66 | + .defaultTextStyle | ||
| 67 | + .copyWith( | ||
| 68 | + fontWeight: pw.FontWeight.bold, | ||
| 69 | + color: green)), | ||
| 70 | + pw.Padding(padding: const pw.EdgeInsets.only(top: 20)), | ||
| 71 | + pw.Row( | ||
| 65 | crossAxisAlignment: pw.CrossAxisAlignment.start, | 72 | crossAxisAlignment: pw.CrossAxisAlignment.start, |
| 66 | mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, | 73 | mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, |
| 67 | children: <pw.Widget>[ | 74 | children: <pw.Widget>[ |
| 68 | pw.Column( | 75 | pw.Column( |
| 69 | - crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 70 | - children: <pw.Widget>[ | ||
| 71 | - pw.Text('568 Port Washington Road'), | ||
| 72 | - pw.Text('Nordegg, AB T0M 2H0'), | ||
| 73 | - pw.Text('Canada, ON'), | ||
| 74 | - ]), | 76 | + crossAxisAlignment: pw.CrossAxisAlignment.start, |
| 77 | + children: <pw.Widget>[ | ||
| 78 | + pw.Text('568 Port Washington Road'), | ||
| 79 | + pw.Text('Nordegg, AB T0M 2H0'), | ||
| 80 | + pw.Text('Canada, ON'), | ||
| 81 | + ], | ||
| 82 | + ), | ||
| 75 | pw.Column( | 83 | pw.Column( |
| 76 | - crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
| 77 | - children: <pw.Widget>[ | ||
| 78 | - pw.Text('+1 403-721-6898'), | ||
| 79 | - _UrlText('p.charlesbois@yahoo.com', | ||
| 80 | - 'mailto:p.charlesbois@yahoo.com'), | ||
| 81 | - _UrlText('wholeprices.ca', | ||
| 82 | - 'https://wholeprices.ca'), | ||
| 83 | - ]), | 84 | + crossAxisAlignment: pw.CrossAxisAlignment.start, |
| 85 | + children: <pw.Widget>[ | ||
| 86 | + pw.Text('+1 403-721-6898'), | ||
| 87 | + _UrlText('p.charlesbois@yahoo.com', | ||
| 88 | + 'mailto:p.charlesbois@yahoo.com'), | ||
| 89 | + _UrlText( | ||
| 90 | + 'wholeprices.ca', 'https://wholeprices.ca'), | ||
| 91 | + ], | ||
| 92 | + ), | ||
| 84 | pw.Padding(padding: pw.EdgeInsets.zero) | 93 | pw.Padding(padding: pw.EdgeInsets.zero) |
| 85 | - ]), | ||
| 86 | - ])), | ||
| 87 | - _Category(title: 'Work Experience'), | ||
| 88 | - _Block(title: 'Tour bus driver'), | ||
| 89 | - _Block(title: 'Logging equipment operator'), | ||
| 90 | - _Block(title: 'Foot doctor'), | ||
| 91 | - _Category(title: 'Education'), | ||
| 92 | - _Block(title: 'Bachelor Of Commerce'), | ||
| 93 | - _Block(title: 'Bachelor Interior Design'), | ||
| 94 | - ])), | ||
| 95 | - pw.Container( | ||
| 96 | - height: double.infinity, | ||
| 97 | - width: 2, | ||
| 98 | - margin: const pw.EdgeInsets.symmetric(horizontal: 5), | ||
| 99 | - color: green, | ||
| 100 | - ), | ||
| 101 | - pw.Column( | ||
| 102 | - crossAxisAlignment: pw.CrossAxisAlignment.center, | ||
| 103 | - mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, | ||
| 104 | - children: <pw.Widget>[ | ||
| 105 | - pw.ClipOval( | ||
| 106 | - child: pw.Container( | ||
| 107 | - width: 100, | ||
| 108 | - height: 100, | ||
| 109 | - color: lightGreen, | ||
| 110 | - child: pw.Image(profileImage), | 94 | + ], |
| 95 | + ), | ||
| 96 | + ], | ||
| 97 | + ), | ||
| 98 | + ), | ||
| 99 | + _Category(title: 'Work Experience'), | ||
| 100 | + _Block(title: 'Tour bus driver'), | ||
| 101 | + _Block(title: 'Logging equipment operator'), | ||
| 102 | + _Block(title: 'Foot doctor'), | ||
| 103 | + _Block(title: 'Unicorn trainer'), | ||
| 104 | + _Block(title: 'Chief chatter'), | ||
| 105 | + pw.SizedBox(height: 20), | ||
| 106 | + _Category(title: 'Education'), | ||
| 107 | + _Block(title: 'Bachelor Of Commerce'), | ||
| 108 | + _Block(title: 'Bachelor Interior Design'), | ||
| 109 | + ], | ||
| 110 | + ), | ||
| 111 | ), | 111 | ), |
| 112 | - ), | ||
| 113 | - pw.Column(children: <pw.Widget>[ | ||
| 114 | - _Percent(size: 60, value: .7, title: pw.Text('Word')), | ||
| 115 | - _Percent(size: 60, value: .4, title: pw.Text('Excel')), | ||
| 116 | - ]), | ||
| 117 | - pw.BarcodeWidget( | ||
| 118 | - data: 'Parnella Charlesbois', | ||
| 119 | - width: 60, | ||
| 120 | - height: 60, | ||
| 121 | - barcode: pw.Barcode.qrCode(), | ||
| 122 | - ), | ||
| 123 | - ], | ||
| 124 | - ) | ||
| 125 | - ]), | ||
| 126 | - )); | 112 | + pw.Partition( |
| 113 | + width: sep, | ||
| 114 | + child: pw.Column( | ||
| 115 | + children: [ | ||
| 116 | + pw.Container( | ||
| 117 | + height: pageTheme.pageFormat.availableHeight, | ||
| 118 | + child: pw.Column( | ||
| 119 | + crossAxisAlignment: pw.CrossAxisAlignment.center, | ||
| 120 | + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, | ||
| 121 | + children: <pw.Widget>[ | ||
| 122 | + pw.ClipOval( | ||
| 123 | + child: pw.Container( | ||
| 124 | + width: 100, | ||
| 125 | + height: 100, | ||
| 126 | + color: lightGreen, | ||
| 127 | + child: pw.Image(profileImage), | ||
| 128 | + ), | ||
| 129 | + ), | ||
| 130 | + pw.Column(children: <pw.Widget>[ | ||
| 131 | + _Percent(size: 60, value: .7, title: pw.Text('Word')), | ||
| 132 | + _Percent( | ||
| 133 | + size: 60, value: .4, title: pw.Text('Excel')), | ||
| 134 | + ]), | ||
| 135 | + pw.BarcodeWidget( | ||
| 136 | + data: 'Parnella Charlesbois', | ||
| 137 | + width: 60, | ||
| 138 | + height: 60, | ||
| 139 | + barcode: pw.Barcode.qrCode(), | ||
| 140 | + ), | ||
| 141 | + ], | ||
| 142 | + ), | ||
| 143 | + ), | ||
| 144 | + ], | ||
| 145 | + ), | ||
| 146 | + ) | ||
| 147 | + ], | ||
| 148 | + ), | ||
| 149 | + ], | ||
| 150 | + ), | ||
| 151 | + ); | ||
| 127 | return doc.save(); | 152 | return doc.save(); |
| 128 | } | 153 | } |
| 129 | 154 | ||
| 130 | Future<pw.PageTheme> _myPageTheme(PdfPageFormat format) async { | 155 | Future<pw.PageTheme> _myPageTheme(PdfPageFormat format) async { |
| 156 | + format = format.applyMargin( | ||
| 157 | + left: 2.0 * PdfPageFormat.cm, | ||
| 158 | + top: 4.0 * PdfPageFormat.cm, | ||
| 159 | + right: 2.0 * PdfPageFormat.cm, | ||
| 160 | + bottom: 2.0 * PdfPageFormat.cm); | ||
| 131 | return pw.PageTheme( | 161 | return pw.PageTheme( |
| 132 | - pageFormat: format.applyMargin( | ||
| 133 | - left: 2.0 * PdfPageFormat.cm, | ||
| 134 | - top: 4.0 * PdfPageFormat.cm, | ||
| 135 | - right: 2.0 * PdfPageFormat.cm, | ||
| 136 | - bottom: 2.0 * PdfPageFormat.cm), | 162 | + pageFormat: format, |
| 137 | theme: pw.ThemeData.withFont( | 163 | theme: pw.ThemeData.withFont( |
| 138 | base: pw.Font.ttf(await rootBundle.load('assets/open-sans.ttf')), | 164 | base: pw.Font.ttf(await rootBundle.load('assets/open-sans.ttf')), |
| 139 | bold: pw.Font.ttf(await rootBundle.load('assets/open-sans-bold.ttf')), | 165 | bold: pw.Font.ttf(await rootBundle.load('assets/open-sans-bold.ttf')), |
| @@ -173,7 +199,14 @@ Future<pw.PageTheme> _myPageTheme(PdfPageFormat format) async { | @@ -173,7 +199,14 @@ Future<pw.PageTheme> _myPageTheme(PdfPageFormat format) async { | ||
| 173 | ..moveTo(size.x - 30, 0) | 199 | ..moveTo(size.x - 30, 0) |
| 174 | ..lineTo(size.x - 110, 50) | 200 | ..lineTo(size.x - 110, 50) |
| 175 | ..lineTo(size.x - 150, 0) | 201 | ..lineTo(size.x - 150, 0) |
| 176 | - ..fillPath(); | 202 | + ..fillPath() |
| 203 | + ..setColor(green) | ||
| 204 | + ..setLineWidth(2) | ||
| 205 | + ..moveTo( | ||
| 206 | + size.x - sep - format.marginRight + 4, format.marginBottom) | ||
| 207 | + ..lineTo(size.x - sep - format.marginRight + 4, | ||
| 208 | + size.y - format.marginTop) | ||
| 209 | + ..strokePath(); | ||
| 177 | }, | 210 | }, |
| 178 | ), | 211 | ), |
| 179 | ); | 212 | ); |
-
Please register or login to post a comment