Showing
1 changed file
with
58 additions
and
31 deletions
@@ -29,47 +29,70 @@ Future<Uint8List> generateDocument( | @@ -29,47 +29,70 @@ Future<Uint8List> generateDocument( | ||
29 | final font1 = await rootBundle.load('assets/open-sans.ttf'); | 29 | final font1 = await rootBundle.load('assets/open-sans.ttf'); |
30 | final font2 = await rootBundle.load('assets/open-sans-bold.ttf'); | 30 | final font2 = await rootBundle.load('assets/open-sans-bold.ttf'); |
31 | final shape = await rootBundle.loadString('assets/document.svg'); | 31 | final shape = await rootBundle.loadString('assets/document.svg'); |
32 | + final swirls = await rootBundle.loadString('assets/swirls2.svg'); | ||
32 | 33 | ||
33 | doc.addPage( | 34 | doc.addPage( |
34 | pw.Page( | 35 | pw.Page( |
35 | pageTheme: pw.PageTheme( | 36 | pageTheme: pw.PageTheme( |
36 | - pageFormat: format.copyWith(marginBottom: 1.5 * PdfPageFormat.cm), | ||
37 | - orientation: pw.PageOrientation.portrait, | ||
38 | - buildBackground: (context) => pw.FullPage( | ||
39 | - ignoreMargins: true, | ||
40 | - child: pw.SvgImage(svg: shape, fit: pw.BoxFit.fill), | 37 | + pageFormat: format.copyWith( |
38 | + marginBottom: 0, | ||
39 | + marginLeft: 0, | ||
40 | + marginRight: 0, | ||
41 | + marginTop: 0, | ||
41 | ), | 42 | ), |
43 | + orientation: pw.PageOrientation.portrait, | ||
44 | + buildBackground: (context) => | ||
45 | + pw.SvgImage(svg: shape, fit: pw.BoxFit.fill), | ||
42 | ), | 46 | ), |
43 | build: (context) { | 47 | build: (context) { |
44 | - return pw.Column( | ||
45 | - children: [ | ||
46 | - pw.Spacer(), | ||
47 | - pw.RichText( | ||
48 | - text: pw.TextSpan(children: [ | ||
49 | - pw.TextSpan( | ||
50 | - text: DateTime.now().year.toString() + '\n', | ||
51 | - style: pw.TextStyle( | ||
52 | - fontWeight: pw.FontWeight.bold, | ||
53 | - color: PdfColors.grey600, | ||
54 | - fontSize: 40, | 48 | + return pw.Padding( |
49 | + padding: pw.EdgeInsets.only( | ||
50 | + left: 60, | ||
51 | + right: 60, | ||
52 | + bottom: 30, | ||
53 | + ), | ||
54 | + child: pw.Column( | ||
55 | + children: [ | ||
56 | + pw.Spacer(), | ||
57 | + pw.RichText( | ||
58 | + text: pw.TextSpan(children: [ | ||
59 | + pw.TextSpan( | ||
60 | + text: DateTime.now().year.toString() + '\n', | ||
61 | + style: pw.TextStyle( | ||
62 | + fontWeight: pw.FontWeight.bold, | ||
63 | + color: PdfColors.grey600, | ||
64 | + fontSize: 40, | ||
65 | + ), | ||
66 | + ), | ||
67 | + pw.TextSpan( | ||
68 | + text: 'Portable Document Format', | ||
69 | + style: pw.TextStyle( | ||
70 | + fontWeight: pw.FontWeight.bold, | ||
71 | + fontSize: 40, | ||
72 | + ), | ||
55 | ), | 73 | ), |
74 | + ])), | ||
75 | + pw.Spacer(), | ||
76 | + pw.Container( | ||
77 | + alignment: pw.Alignment.topRight, | ||
78 | + height: 150, | ||
79 | + child: pw.PdfLogo(), | ||
56 | ), | 80 | ), |
57 | - pw.TextSpan( | ||
58 | - text: 'Portable Document Format', | ||
59 | - style: pw.TextStyle( | ||
60 | - fontWeight: pw.FontWeight.bold, | ||
61 | - fontSize: 40, | 81 | + pw.Spacer(flex: 2), |
82 | + pw.Align( | ||
83 | + alignment: pw.Alignment.topLeft, | ||
84 | + child: pw.UrlLink( | ||
85 | + destination: 'https://wikipedia.org/wiki/PDF', | ||
86 | + child: pw.Text( | ||
87 | + 'https://wikipedia.org/wiki/PDF', | ||
88 | + style: pw.TextStyle( | ||
89 | + color: PdfColors.pink100, | ||
90 | + ), | ||
91 | + ), | ||
62 | ), | 92 | ), |
63 | ), | 93 | ), |
64 | - ])), | ||
65 | - pw.Spacer(), | ||
66 | - pw.Container( | ||
67 | - alignment: pw.Alignment.topRight, | ||
68 | - height: 150, | ||
69 | - child: pw.PdfLogo(), | ||
70 | - ), | ||
71 | - pw.Spacer(flex: 2), | ||
72 | - ], | 94 | + ], |
95 | + ), | ||
73 | ); | 96 | ); |
74 | }, | 97 | }, |
75 | ), | 98 | ), |
@@ -81,7 +104,6 @@ Future<Uint8List> generateDocument( | @@ -81,7 +104,6 @@ Future<Uint8List> generateDocument( | ||
81 | orientation: pw.PageOrientation.portrait, | 104 | orientation: pw.PageOrientation.portrait, |
82 | build: (context) { | 105 | build: (context) { |
83 | return pw.Column( | 106 | return pw.Column( |
84 | - crossAxisAlignment: pw.CrossAxisAlignment.start, | ||
85 | children: [ | 107 | children: [ |
86 | pw.Center( | 108 | pw.Center( |
87 | child: pw.Text('Table of content', | 109 | child: pw.Text('Table of content', |
@@ -89,6 +111,11 @@ Future<Uint8List> generateDocument( | @@ -89,6 +111,11 @@ Future<Uint8List> generateDocument( | ||
89 | ), | 111 | ), |
90 | pw.SizedBox(height: 20), | 112 | pw.SizedBox(height: 20), |
91 | pw.TableOfContent(), | 113 | pw.TableOfContent(), |
114 | + pw.Spacer(), | ||
115 | + pw.Center( | ||
116 | + child: pw.SvgImage( | ||
117 | + svg: swirls, width: 100, colorFilter: PdfColors.grey)), | ||
118 | + pw.Spacer(), | ||
92 | ], | 119 | ], |
93 | ); | 120 | ); |
94 | }, | 121 | }, |
-
Please register or login to post a comment