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
2019-12-01 16:55:41 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5e0162fa8e0145119e6adafaf68248bb5fae5db8
5e0162fa
1 parent
62671003
Use PageTheme in example
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
48 deletions
printing/CHANGELOG.md
printing/example/lib/document.dart
printing/example/lib/example_widgets.dart
printing/CHANGELOG.md
View file @
5e0162f
...
...
@@ -5,6 +5,7 @@
-
Simplify iOS code
-
Improve native code
-
Add Printing.info()
-
Use PageTheme in example
## 2.1.9
...
...
printing/example/lib/document.dart
View file @
5e0162f
...
...
@@ -18,12 +18,10 @@ Future<Document> generateDocument(PdfPageFormat format) async {
print
(
'Unable to download image'
);
});
pdf
.
addPage
(
MyPage
(
pageFormat:
format
.
applyMargin
(
left:
2.0
*
PdfPageFormat
.
cm
,
top:
4.0
*
PdfPageFormat
.
cm
,
right:
2.0
*
PdfPageFormat
.
cm
,
bottom:
2.0
*
PdfPageFormat
.
cm
),
final
PageTheme
pageTheme
=
myPageTheme
(
format
);
pdf
.
addPage
(
Page
(
pageTheme:
pageTheme
,
build:
(
Context
context
)
=>
Row
(
children:
<
Widget
>[
Expanded
(
child:
Column
(
...
...
printing/example/lib/example_widgets.dart
View file @
5e0162f
...
...
@@ -6,48 +6,54 @@ import 'package:qr/qr.dart';
const
PdfColor
green
=
PdfColor
.
fromInt
(
0xff9ce5d0
);
const
PdfColor
lightGreen
=
PdfColor
.
fromInt
(
0xffcdf1e7
);
class
MyPage
extends
Page
{
MyPage
(
{
PdfPageFormat
pageFormat
=
PdfPageFormat
.
a4
,
BuildCallback
build
,
EdgeInsets
margin
})
:
super
(
pageFormat:
pageFormat
,
margin:
margin
,
build:
build
);
@override
void
paint
(
Widget
child
,
Context
context
)
{
context
.
canvas
..
setColor
(
lightGreen
)
..
moveTo
(
0
,
pageFormat
.
height
)
..
lineTo
(
0
,
pageFormat
.
height
-
230
)
..
lineTo
(
60
,
pageFormat
.
height
)
..
fillPath
()
..
setColor
(
green
)
..
moveTo
(
0
,
pageFormat
.
height
)
..
lineTo
(
0
,
pageFormat
.
height
-
100
)
..
lineTo
(
100
,
pageFormat
.
height
)
..
fillPath
()
..
setColor
(
lightGreen
)
..
moveTo
(
30
,
pageFormat
.
height
)
..
lineTo
(
110
,
pageFormat
.
height
-
50
)
..
lineTo
(
150
,
pageFormat
.
height
)
..
fillPath
()
..
moveTo
(
pageFormat
.
width
,
0
)
..
lineTo
(
pageFormat
.
width
,
230
)
..
lineTo
(
pageFormat
.
width
-
60
,
0
)
..
fillPath
()
..
setColor
(
green
)
..
moveTo
(
pageFormat
.
width
,
0
)
..
lineTo
(
pageFormat
.
width
,
100
)
..
lineTo
(
pageFormat
.
width
-
100
,
0
)
..
fillPath
()
..
setColor
(
lightGreen
)
..
moveTo
(
pageFormat
.
width
-
30
,
0
)
..
lineTo
(
pageFormat
.
width
-
110
,
50
)
..
lineTo
(
pageFormat
.
width
-
150
,
0
)
..
fillPath
();
super
.
paint
(
child
,
context
);
}
PageTheme
myPageTheme
(
PdfPageFormat
format
)
{
return
PageTheme
(
pageFormat:
format
.
applyMargin
(
left:
2.0
*
PdfPageFormat
.
cm
,
top:
4.0
*
PdfPageFormat
.
cm
,
right:
2.0
*
PdfPageFormat
.
cm
,
bottom:
2.0
*
PdfPageFormat
.
cm
),
buildBackground:
(
Context
context
)
{
return
FullPage
(
ignoreMargins:
true
,
child:
CustomPaint
(
size:
PdfPoint
(
format
.
width
,
format
.
height
),
painter:
(
PdfGraphics
canvas
,
PdfPoint
size
)
{
context
.
canvas
..
setColor
(
lightGreen
)
..
moveTo
(
0
,
size
.
y
)
..
lineTo
(
0
,
size
.
y
-
230
)
..
lineTo
(
60
,
size
.
y
)
..
fillPath
()
..
setColor
(
green
)
..
moveTo
(
0
,
size
.
y
)
..
lineTo
(
0
,
size
.
y
-
100
)
..
lineTo
(
100
,
size
.
y
)
..
fillPath
()
..
setColor
(
lightGreen
)
..
moveTo
(
30
,
size
.
y
)
..
lineTo
(
110
,
size
.
y
-
50
)
..
lineTo
(
150
,
size
.
y
)
..
fillPath
()
..
moveTo
(
size
.
x
,
0
)
..
lineTo
(
size
.
x
,
230
)
..
lineTo
(
size
.
x
-
60
,
0
)
..
fillPath
()
..
setColor
(
green
)
..
moveTo
(
size
.
x
,
0
)
..
lineTo
(
size
.
x
,
100
)
..
lineTo
(
size
.
x
-
100
,
0
)
..
fillPath
()
..
setColor
(
lightGreen
)
..
moveTo
(
size
.
x
-
30
,
0
)
..
lineTo
(
size
.
x
-
110
,
50
)
..
lineTo
(
size
.
x
-
150
,
0
)
..
fillPath
();
},
),
);
},
);
}
class
Block
extends
StatelessWidget
{
...
...
Please
register
or
login
to post a comment