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-11-03 11:54:02 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d39897abc56f30c6c159b4fe3f439b24dc070716
d39897ab
1 parent
12f0fe3c
Add optional clipping on Page
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/page.dart
pdf/lib/widgets/page_theme.dart
pdf/CHANGELOG.md
View file @
d39897a
...
...
@@ -8,6 +8,7 @@
-
Fix warning in tests
-
Fix warning in example
-
Format Java code
-
Add optional clipping on Page
## 1.3.23
...
...
pdf/lib/widgets/page.dart
View file @
d39897a
...
...
@@ -28,13 +28,15 @@ class Page {
BuildCallback
build
,
Theme
theme
,
PageOrientation
orientation
,
EdgeInsets
margin
})
EdgeInsets
margin
,
bool
clip
=
false
})
:
assert
(
pageTheme
==
null
||
(
pageFormat
==
null
&&
theme
==
null
&&
orientation
==
null
&&
margin
==
null
),
margin
==
null
&&
clip
==
false
),
'Don
\'
t set both pageTheme and other settings'
),
pageTheme
=
pageTheme
??
PageTheme
(
...
...
@@ -42,6 +44,7 @@ class Page {
orientation:
orientation
,
margin:
margin
,
theme:
theme
,
clip:
clip
,
),
_build
=
build
;
...
...
@@ -152,6 +155,19 @@ class Page {
return
;
}
if
(
pageTheme
.
clip
)
{
final
EdgeInsets
_margin
=
margin
;
context
.
canvas
..
saveContext
()
..
drawRect
(
_margin
.
left
,
_margin
.
bottom
,
pageFormat
.
width
-
_margin
.
horizontal
,
pageFormat
.
height
-
_margin
.
vertical
,
)
..
clipPath
();
}
if
(
mustRotate
)
{
final
EdgeInsets
_margin
=
margin
;
final
Matrix4
mat
=
Matrix4
.
identity
();
...
...
@@ -167,5 +183,9 @@ class Page {
}
else
{
child
.
paint
(
context
);
}
if
(
pageTheme
.
clip
)
{
context
.
canvas
.
restoreContext
();
}
}
}
...
...
pdf/lib/widgets/page_theme.dart
View file @
d39897a
...
...
@@ -18,14 +18,15 @@ part of widget;
@immutable
class
PageTheme
{
const
PageTheme
(
{
PdfPageFormat
pageFormat
,
const
PageTheme
({
PdfPageFormat
pageFormat
,
this
.
buildBackground
,
this
.
buildForeground
,
this
.
theme
,
PageOrientation
orientation
,
EdgeInsets
margin
})
:
pageFormat
=
pageFormat
??
PdfPageFormat
.
standard
,
EdgeInsets
margin
,
this
.
clip
=
false
,
})
:
pageFormat
=
pageFormat
??
PdfPageFormat
.
standard
,
orientation
=
orientation
??
PageOrientation
.
natural
,
_margin
=
margin
;
...
...
@@ -41,6 +42,8 @@ class PageTheme {
final
Theme
theme
;
final
bool
clip
;
bool
get
mustRotate
=>
(
orientation
==
PageOrientation
.
landscape
&&
pageFormat
.
height
>
pageFormat
.
width
)
||
...
...
Please
register
or
login
to post a comment