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:24 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
62671003a276dae59c1d02f162928394727e967f
62671003
1 parent
b57400a5
Add FullPage widget
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
10 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/basic.dart
pdf/lib/widgets/page.dart
pdf/test/widget_watermark_test.dart
test/golden/widgets-watermark.pdf
pdf/CHANGELOG.md
View file @
6267100
...
...
@@ -17,6 +17,7 @@
-
Implement Image orientation
-
Add Exif reader
-
Add support for GreyScale Jpeg
-
Add FullPage widget
## 1.3.23
...
...
pdf/lib/widgets/basic.dart
View file @
6267100
...
...
@@ -666,3 +666,74 @@ class Builder extends StatelessWidget {
@override
Widget
build
(
Context
context
)
=>
builder
(
context
);
}
class
FullPage
extends
SingleChildWidget
{
FullPage
({
@required
this
.
ignoreMargins
,
Widget
child
,
})
:
assert
(
ignoreMargins
!=
null
),
super
(
child:
child
);
final
bool
ignoreMargins
;
BoxConstraints
_getConstraints
(
Context
context
)
{
return
ignoreMargins
?
BoxConstraints
.
tightFor
(
width:
context
.
page
.
pageFormat
.
width
,
height:
context
.
page
.
pageFormat
.
height
,
)
:
BoxConstraints
.
tightFor
(
width:
context
.
page
.
pageFormat
.
availableWidth
,
height:
context
.
page
.
pageFormat
.
availableHeight
,
);
}
PdfRect
_getBox
(
Context
context
)
{
final
PdfRect
box
=
_getConstraints
(
context
).
constrainRect
();
if
(
ignoreMargins
)
{
return
box
;
}
return
PdfRect
.
fromPoints
(
PdfPoint
(
context
.
page
.
pageFormat
.
marginLeft
,
context
.
page
.
pageFormat
.
marginTop
,
),
box
.
size
);
}
@override
void
layout
(
Context
context
,
BoxConstraints
constraints
,
{
bool
parentUsesSize
=
false
})
{
final
BoxConstraints
constraints
=
_getConstraints
(
context
);
if
(
child
!=
null
)
{
child
.
layout
(
context
,
constraints
,
parentUsesSize:
false
);
assert
(
child
.
box
!=
null
);
}
box
=
_getBox
(
context
);
print
(
'layout box:
$box
'
);
}
@override
void
debugPaint
(
Context
context
)
{}
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
if
(
child
==
null
)
{
return
;
}
final
PdfRect
box
=
_getBox
(
context
);
final
Matrix4
mat
=
Matrix4
.
tryInvert
(
context
.
canvas
.
getTransform
());
mat
.
translate
(
box
.
x
,
box
.
y
);
context
.
canvas
..
saveContext
()
..
setTransform
(
mat
);
child
.
paint
(
context
);
context
.
canvas
.
restoreContext
();
}
}
...
...
pdf/lib/widgets/page.dart
View file @
6267100
...
...
@@ -104,6 +104,14 @@ class Page {
page:
_pdfPage
,
canvas:
canvas
,
).
inheritFrom
(
calculatedTheme
);
assert
(()
{
if
(
Document
.
debug
)
{
debugPaint
(
context
);
}
return
true
;
}());
if
(
pageTheme
.
buildBackground
!=
null
)
{
final
Widget
child
=
pageTheme
.
buildBackground
(
context
);
if
(
child
!=
null
)
{
...
...
@@ -111,6 +119,7 @@ class Page {
paint
(
child
,
context
);
}
}
if
(
_build
!=
null
)
{
final
Widget
child
=
_build
(
context
);
if
(
child
!=
null
)
{
...
...
@@ -118,6 +127,7 @@ class Page {
paint
(
child
,
context
);
}
}
if
(
pageTheme
.
buildForeground
!=
null
)
{
final
Widget
child
=
pageTheme
.
buildForeground
(
context
);
if
(
child
!=
null
)
{
...
...
@@ -144,13 +154,6 @@ class Page {
@protected
void
paint
(
Widget
child
,
Context
context
)
{
assert
(()
{
if
(
Document
.
debug
)
{
debugPaint
(
context
);
}
return
true
;
}());
if
(
child
==
null
)
{
return
;
}
...
...
pdf/test/widget_watermark_test.dart
View file @
6267100
...
...
@@ -25,7 +25,10 @@ void main() {
final
Document
pdf
=
Document
();
final
PageTheme
pageTheme
=
PageTheme
(
buildBackground:
(
Context
context
)
=>
Watermark
.
text
(
'DRAFT'
),
buildBackground:
(
Context
context
)
=>
FullPage
(
ignoreMargins:
true
,
child:
Watermark
.
text
(
'DRAFT'
),
),
buildForeground:
(
Context
context
)
=>
Align
(
alignment:
Alignment
.
bottomLeft
,
child:
SizedBox
(
...
...
test/golden/widgets-watermark.pdf
View file @
6267100
No preview for this file type
Please
register
or
login
to post a comment