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-02-19 17:29:23 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
24ec3e22865faba70e0b21900df1a678078732f5
24ec3e22
1 parent
374ac2ac
Fix TextField Widget
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
62 deletions
pdf/CHANGELOG.md
pdf/lib/src/widgets/annotations.dart
pdf/lib/src/widgets/forms.dart
pdf/test/widget_form_test.dart
test/golden/widgets-form.pdf
pdf/CHANGELOG.md
View file @
24ec3e2
...
...
@@ -4,6 +4,7 @@
-
Fix Checkbox Widget
-
Fix SVG colors with percent
-
Fix TextField Widget
## 3.0.0-nullsafety.1
...
...
pdf/lib/src/widgets/annotations.dart
View file @
24ec3e2
...
...
@@ -17,7 +17,6 @@
import
'package:pdf/pdf.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'basic.dart'
;
import
'geometry.dart'
;
import
'text_style.dart'
;
import
'theme.dart'
;
...
...
@@ -285,45 +284,6 @@ class Signature extends Annotation {
));
}
class
TextField
extends
Annotation
{
TextField
({
Widget
?
child
,
double
width
=
120
,
double
height
=
13
,
required
String
name
,
PdfBorder
?
border
,
Set
<
PdfAnnotFlags
>?
flags
,
DateTime
?
date
,
PdfColor
?
color
,
PdfColor
?
backgroundColor
,
PdfAnnotHighlighting
?
highlighting
,
int
?
maxLength
,
String
?
alternateName
,
String
?
mappingName
,
Set
<
PdfFieldFlags
>?
fieldFlags
,
String
?
value
,
String
?
defaultValue
,
TextStyle
?
textStyle
,
})
:
super
(
child:
child
??
SizedBox
(
width:
width
,
height:
height
),
builder:
AnnotationTextField
(
name:
name
,
border:
border
,
flags:
flags
,
date:
date
,
color:
color
,
backgroundColor:
backgroundColor
,
highlighting:
highlighting
,
maxLength:
maxLength
,
alternateName:
alternateName
,
mappingName:
mappingName
,
fieldFlags:
fieldFlags
,
value:
value
,
defaultValue:
defaultValue
,
textStyle:
textStyle
,
));
}
class
Outline
extends
Anchor
{
Outline
({
Widget
?
child
,
...
...
pdf/lib/src/widgets/forms.dart
View file @
24ec3e2
...
...
@@ -17,11 +17,13 @@
import
'package:pdf/pdf.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'basic.dart'
;
import
'border_radius.dart'
;
import
'box_border.dart'
;
import
'container.dart'
;
import
'decoration.dart'
;
import
'geometry.dart'
;
import
'text.dart'
;
import
'text_style.dart'
;
import
'theme.dart'
;
import
'widget.dart'
;
...
...
@@ -98,6 +100,7 @@ class FlatButton extends SingleChildWidget {
PdfColor
colorRollover
=
PdfColors
.
blueAccent
,
EdgeInsets
?
padding
,
BoxDecoration
?
decoration
,
this
.
flags
,
required
Widget
child
,
required
this
.
name
,
})
:
_childDown
=
Container
(
...
...
@@ -148,6 +151,8 @@ class FlatButton extends SingleChildWidget {
final
Widget
_childRollover
;
final
Set
<
PdfAnnotFlags
>?
flags
;
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
...
...
@@ -155,7 +160,7 @@ class FlatButton extends SingleChildWidget {
final
bf
=
PdfButtonField
(
rect:
context
.
localToGlobal
(
box
!),
fieldName:
name
,
flags:
<
PdfAnnotFlags
>{
PdfAnnotFlags
.
print
}
,
flags:
flags
,
fieldFlags:
<
PdfFieldFlags
>{
PdfFieldFlags
.
pushButton
},
);
...
...
@@ -168,27 +173,137 @@ class FlatButton extends SingleChildWidget {
..
leftTranslate
(-
translation
.
x
,
-
translation
.
y
)
..
translate
(
box
!.
x
,
box
!.
y
);
final
cn
=
context
.
copyWith
(
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
matrix:
mat
,
boundingBox:
box
));
child
!.
layout
(
cn
,
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
));
child
!.
paint
(
cn
);
final
cd
=
context
.
copyWith
(
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
down
,
matrix:
mat
,
boundingBox:
box
));
_childDown
.
layout
(
cd
,
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
));
_childDown
.
paint
(
cd
);
final
cr
=
context
.
copyWith
(
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
rollover
,
matrix:
mat
,
boundingBox:
box
));
_childRollover
.
layout
(
cr
,
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
));
_childRollover
.
paint
(
cr
);
var
canvas
=
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
matrix:
mat
,
boundingBox:
box
);
Widget
.
draw
(
child
!,
offset:
PdfPoint
.
zero
,
canvas:
canvas
,
page:
context
.
page
,
constraints:
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
),
);
canvas
=
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
down
,
matrix:
mat
,
boundingBox:
box
);
Widget
.
draw
(
_childDown
,
offset:
PdfPoint
.
zero
,
canvas:
canvas
,
page:
context
.
page
,
constraints:
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
),
);
canvas
=
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
rollover
,
matrix:
mat
,
boundingBox:
box
);
Widget
.
draw
(
_childRollover
,
offset:
PdfPoint
.
zero
,
canvas:
canvas
,
page:
context
.
page
,
constraints:
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
),
);
PdfAnnot
(
context
.
page
,
bf
);
}
}
class
TextField
extends
StatelessWidget
{
TextField
({
this
.
child
,
this
.
width
=
120
,
this
.
height
=
13
,
required
this
.
name
,
this
.
border
,
this
.
flags
,
this
.
date
,
this
.
color
,
this
.
backgroundColor
,
this
.
highlighting
,
this
.
maxLength
,
this
.
alternateName
,
this
.
mappingName
,
this
.
fieldFlags
,
this
.
value
,
this
.
defaultValue
,
this
.
textStyle
,
});
final
Widget
?
child
;
final
double
width
;
final
double
height
;
final
String
name
;
final
PdfBorder
?
border
;
final
Set
<
PdfAnnotFlags
>?
flags
;
final
DateTime
?
date
;
final
PdfColor
?
color
;
final
PdfColor
?
backgroundColor
;
final
PdfAnnotHighlighting
?
highlighting
;
final
int
?
maxLength
;
final
String
?
alternateName
;
final
String
?
mappingName
;
final
Set
<
PdfFieldFlags
>?
fieldFlags
;
final
String
?
value
;
final
String
?
defaultValue
;
final
TextStyle
?
textStyle
;
@override
Widget
build
(
Context
context
)
{
return
child
??
SizedBox
(
width:
width
,
height:
height
);
}
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
final
_textStyle
=
Theme
.
of
(
context
).
defaultTextStyle
.
merge
(
textStyle
);
final
tf
=
PdfTextField
(
rect:
context
.
localToGlobal
(
box
!),
fieldName:
name
,
border:
border
,
flags:
flags
??
const
{
PdfAnnotFlags
.
print
},
date:
date
,
color:
color
,
backgroundColor:
backgroundColor
,
highlighting:
highlighting
,
maxLength:
maxLength
,
alternateName:
alternateName
,
mappingName:
mappingName
,
fieldFlags:
fieldFlags
,
value:
value
,
defaultValue:
defaultValue
,
font:
_textStyle
.
font
!.
getFont
(
context
)!,
fontSize:
_textStyle
.
fontSize
!,
textColor:
_textStyle
.
color
!,
);
final
mat
=
context
.
canvas
.
getTransform
();
final
translation
=
Vector3
(
0
,
0
,
0
);
final
rotation
=
Quaternion
(
0
,
0
,
0
,
0
);
final
scale
=
Vector3
(
0
,
0
,
0
);
mat
..
decompose
(
translation
,
rotation
,
scale
)
..
leftTranslate
(-
translation
.
x
,
-
translation
.
y
)
..
translate
(
box
!.
x
,
box
!.
y
);
if
(
value
!=
null
)
{
final
canvas
=
tf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
matrix:
mat
,
boundingBox:
box
);
canvas
.
buf
.
putString
(
'/Tx BMC
\n
'
);
Widget
.
draw
(
Text
(
value
!,
style:
_textStyle
),
offset:
PdfPoint
.
zero
,
canvas:
canvas
,
page:
context
.
page
,
constraints:
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
),
);
canvas
.
buf
.
putString
(
'EMC
\n
'
);
}
PdfAnnot
(
context
.
page
,
tf
);
}
}
...
...
pdf/test/widget_form_test.dart
View file @
24ec3e2
...
...
@@ -81,13 +81,15 @@ void main() {
Decorated
(
child:
TextField
(
name:
'Given Name'
,
value:
'David'
,
textStyle:
const
TextStyle
(
color:
PdfColors
.
amber
),
)),
//
SizedBox
(
width:
double
.
infinity
,
height:
10
),
//
Label
(
label:
'Family Name:'
,
width:
100
),
Decorated
(
child:
TextField
(
name:
'Family Name'
)),
Decorated
(
child:
TextField
(
name:
'Family Name'
,
value:
'PHAM-VAN'
)),
//
SizedBox
(
width:
double
.
infinity
,
height:
10
),
//
...
...
test/golden/widgets-form.pdf
View file @
24ec3e2
No preview for this file type
Please
register
or
login
to post a comment