Showing
1 changed file
with
34 additions
and
7 deletions
@@ -29,19 +29,29 @@ Future<Uint8List> generateDocument( | @@ -29,19 +29,29 @@ 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( | 48 | + return pw.Padding( |
49 | + padding: pw.EdgeInsets.only( | ||
50 | + left: 60, | ||
51 | + right: 60, | ||
52 | + bottom: 30, | ||
53 | + ), | ||
54 | + child: pw.Column( | ||
45 | children: [ | 55 | children: [ |
46 | pw.Spacer(), | 56 | pw.Spacer(), |
47 | pw.RichText( | 57 | pw.RichText( |
@@ -69,7 +79,20 @@ Future<Uint8List> generateDocument( | @@ -69,7 +79,20 @@ Future<Uint8List> generateDocument( | ||
69 | child: pw.PdfLogo(), | 79 | child: pw.PdfLogo(), |
70 | ), | 80 | ), |
71 | pw.Spacer(flex: 2), | 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 | + ), | ||
92 | + ), | ||
93 | + ), | ||
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