Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2021-04-30 21:54:56 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a84e6c5b74acca934601569499dfe8702c82fbe8
a84e6c5b
1 parent
f53ed300
Improve demo document
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
demo/lib/examples/document.dart
demo/lib/examples/document.dart
View file @
a84e6c5
...
...
@@ -29,19 +29,29 @@ Future<Uint8List> generateDocument(
final
font1
=
await
rootBundle
.
load
(
'assets/open-sans.ttf'
);
final
font2
=
await
rootBundle
.
load
(
'assets/open-sans-bold.ttf'
);
final
shape
=
await
rootBundle
.
loadString
(
'assets/document.svg'
);
final
swirls
=
await
rootBundle
.
loadString
(
'assets/swirls2.svg'
);
doc
.
addPage
(
pw
.
Page
(
pageTheme:
pw
.
PageTheme
(
pageFormat:
format
.
copyWith
(
marginBottom:
1.5
*
PdfPageFormat
.
cm
),
orientation:
pw
.
PageOrientation
.
portrait
,
buildBackground:
(
context
)
=>
pw
.
FullPage
(
ignoreMargins:
true
,
child:
pw
.
SvgImage
(
svg:
shape
,
fit:
pw
.
BoxFit
.
fill
),
pageFormat:
format
.
copyWith
(
marginBottom:
0
,
marginLeft:
0
,
marginRight:
0
,
marginTop:
0
,
),
orientation:
pw
.
PageOrientation
.
portrait
,
buildBackground:
(
context
)
=>
pw
.
SvgImage
(
svg:
shape
,
fit:
pw
.
BoxFit
.
fill
),
),
build:
(
context
)
{
return
pw
.
Column
(
return
pw
.
Padding
(
padding:
pw
.
EdgeInsets
.
only
(
left:
60
,
right:
60
,
bottom:
30
,
),
child:
pw
.
Column
(
children:
[
pw
.
Spacer
(),
pw
.
RichText
(
...
...
@@ -69,7 +79,20 @@ Future<Uint8List> generateDocument(
child:
pw
.
PdfLogo
(),
),
pw
.
Spacer
(
flex:
2
),
pw
.
Align
(
alignment:
pw
.
Alignment
.
topLeft
,
child:
pw
.
UrlLink
(
destination:
'https://wikipedia.org/wiki/PDF'
,
child:
pw
.
Text
(
'https://wikipedia.org/wiki/PDF'
,
style:
pw
.
TextStyle
(
color:
PdfColors
.
pink100
,
),
),
),
),
],
),
);
},
),
...
...
@@ -81,7 +104,6 @@ Future<Uint8List> generateDocument(
orientation:
pw
.
PageOrientation
.
portrait
,
build:
(
context
)
{
return
pw
.
Column
(
crossAxisAlignment:
pw
.
CrossAxisAlignment
.
start
,
children:
[
pw
.
Center
(
child:
pw
.
Text
(
'Table of content'
,
...
...
@@ -89,6 +111,11 @@ Future<Uint8List> generateDocument(
),
pw
.
SizedBox
(
height:
20
),
pw
.
TableOfContent
(),
pw
.
Spacer
(),
pw
.
Center
(
child:
pw
.
SvgImage
(
svg:
swirls
,
width:
100
,
colorFilter:
PdfColors
.
grey
)),
pw
.
Spacer
(),
],
);
},
...
...
Please
register
or
login
to post a comment