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-18 17:46:03 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
79fe64faa33699e80d75ed66b3497de9b57d86d8
79fe64fa
1 parent
f6e646a2
Fix Checkbox Widget
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
36 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/annotation.dart
pdf/lib/src/widgets/annotations.dart
pdf/lib/src/widgets/forms.dart
pdf/pubspec.yaml
pdf/test/widget_form_test.dart
test/golden/widgets-form.pdf
pdf/CHANGELOG.md
View file @
79fe64f
# Changelog
## 3.0.0-nullsafety.2
-
Fix Checkbox Widget
## 3.0.0-nullsafety.1
-
Fix Table border
...
...
pdf/lib/src/pdf/annotation.dart
View file @
79fe64f
...
...
@@ -82,7 +82,7 @@ enum PdfAnnotFlags {
lockedContent
,
}
enum
PdfAnnotApp
are
nce
{
enum
PdfAnnotApp
eara
nce
{
normal
,
rollover
,
down
,
...
...
@@ -125,6 +125,8 @@ abstract class PdfAnnotBase {
final
Map
<
String
?,
PdfDataType
>
_appearances
=
<
String
?,
PdfDataType
>{};
PdfName
?
_as
;
int
get
flagValue
{
if
(
flags
==
null
||
flags
!.
isEmpty
)
{
return
0
;
...
...
@@ -137,21 +139,22 @@ abstract class PdfAnnotBase {
PdfGraphics
appearance
(
PdfDocument
pdfDocument
,
PdfAnnotApp
are
nce
type
,
{
PdfAnnotApp
eara
nce
type
,
{
String
?
name
,
Matrix4
?
matrix
,
PdfRect
?
boundingBox
,
bool
selected
=
false
,
})
{
final
s
=
PdfGraphicXObject
(
pdfDocument
,
'/Form'
);
String
?
n
;
switch
(
type
)
{
case
PdfAnnotApp
are
nce
.
normal
:
case
PdfAnnotApp
eara
nce
.
normal
:
n
=
'/N'
;
break
;
case
PdfAnnotApp
are
nce
.
rollover
:
case
PdfAnnotApp
eara
nce
.
rollover
:
n
=
'/R'
;
break
;
case
PdfAnnotApp
are
nce
.
down
:
case
PdfAnnotApp
eara
nce
.
down
:
n
=
'/D'
;
break
;
}
...
...
@@ -182,6 +185,10 @@ abstract class PdfAnnotBase {
s
.
params
[
'/BBox'
]
=
PdfArray
.
fromNum
(<
double
?>[
bbox
.
x
,
bbox
.
y
,
bbox
.
width
,
bbox
.
height
]);
final
g
=
PdfGraphics
(
s
,
s
.
buf
);
if
(
selected
&&
name
!=
null
)
{
_as
=
PdfName
(
name
);
}
return
g
;
}
...
...
@@ -223,11 +230,8 @@ abstract class PdfAnnotBase {
if
(
_appearances
.
isNotEmpty
)
{
params
[
'/AP'
]
=
PdfDict
(
_appearances
);
if
(
_appearances
[
'/N'
]
is
PdfDict
)
{
final
n
=
_appearances
[
'/N'
];
if
(
n
is
PdfDict
)
{
params
[
'/AS'
]
=
PdfName
(
n
.
values
.
keys
.
first
!);
}
if
(
_as
!=
null
)
{
params
[
'/AS'
]
=
_as
;
}
}
}
...
...
@@ -656,7 +660,7 @@ class PdfTextField extends PdfFormField {
class
PdfButtonField
extends
PdfFormField
{
PdfButtonField
({
required
PdfRect
rect
,
String
?
fieldName
,
required
String
fieldName
,
String
?
alternateName
,
String
?
mappingName
,
PdfBorder
?
border
,
...
...
@@ -683,20 +687,20 @@ class PdfButtonField extends PdfFormField {
fieldFlags:
fieldFlags
,
);
final
bool
?
value
;
final
String
?
value
;
final
bool
?
defaultValue
;
final
String
?
defaultValue
;
@override
void
build
(
PdfPage
page
,
PdfObject
object
,
PdfDict
params
)
{
super
.
build
(
page
,
object
,
params
);
if
(
value
!=
null
)
{
params
[
'/V'
]
=
value
!
?
const
PdfName
(
'/Yes'
)
:
const
PdfName
(
'/Off'
);
params
[
'/V'
]
=
PdfName
(
value
!
);
}
if
(
defaultValue
!=
null
)
{
params
[
'/DV'
]
=
defaultValue
!
?
const
PdfName
(
'/Yes'
)
:
const
PdfName
(
'/Off'
);
params
[
'/DV'
]
=
PdfName
(
defaultValue
!);
}
}
}
...
...
pdf/lib/src/widgets/annotations.dart
View file @
79fe64f
...
...
@@ -290,7 +290,7 @@ class TextField extends Annotation {
Widget
?
child
,
double
width
=
120
,
double
height
=
13
,
String
?
name
,
required
String
name
,
PdfBorder
?
border
,
Set
<
PdfAnnotFlags
>?
flags
,
DateTime
?
date
,
...
...
pdf/lib/src/widgets/forms.dart
View file @
79fe64f
...
...
@@ -29,7 +29,6 @@ import 'widget.dart';
class
Checkbox
extends
SingleChildWidget
{
Checkbox
({
required
this
.
value
,
this
.
defaultValue
,
this
.
tristate
=
false
,
this
.
activeColor
=
PdfColors
.
blue
,
this
.
checkColor
=
PdfColors
.
white
,
...
...
@@ -51,8 +50,6 @@ class Checkbox extends SingleChildWidget {
final
bool
value
;
final
bool
?
defaultValue
;
final
bool
tristate
;
final
PdfColor
activeColor
;
...
...
@@ -69,13 +66,13 @@ class Checkbox extends SingleChildWidget {
final
bf
=
PdfButtonField
(
rect:
context
.
localToGlobal
(
box
!),
fieldName:
name
,
value:
value
,
defaultValue:
value
,
value:
value
?
'/Yes'
:
null
,
defaultValue:
value
?
'/Yes'
:
null
,
flags:
<
PdfAnnotFlags
>{
PdfAnnotFlags
.
print
},
);
final
g
=
bf
.
appearance
(
context
.
document
,
PdfAnnotApparence
.
normal
,
name:
'/Yes'
);
final
g
=
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
name:
'/Yes'
,
selected:
value
);
g
.
drawRect
(
0
,
0
,
bf
.
rect
.
width
,
bf
.
rect
.
height
);
g
.
setFillColor
(
activeColor
);
g
.
fillPath
();
...
...
@@ -86,7 +83,8 @@ class Checkbox extends SingleChildWidget {
g
.
setLineWidth
(
2
);
g
.
strokePath
();
bf
.
appearance
(
context
.
document
,
PdfAnnotApparence
.
normal
,
name:
'/Off'
);
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
name:
'/Off'
,
selected:
!
value
);
PdfAnnot
(
context
.
page
,
bf
);
}
...
...
@@ -144,12 +142,6 @@ class FlatButton extends SingleChildWidget {
),
);
// final PdfColor textColor;
// final PdfColor color;
// final EdgeInsets padding;
final
String
name
;
final
Widget
_childDown
;
...
...
@@ -177,21 +169,21 @@ class FlatButton extends SingleChildWidget {
..
translate
(
box
!.
x
,
box
!.
y
);
final
cn
=
context
.
copyWith
(
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotApp
are
nce
.
normal
,
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotApp
eara
nce
.
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
,
PdfAnnotApp
are
nce
.
down
,
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotApp
eara
nce
.
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
,
PdfAnnotApp
are
nce
.
rollover
,
canvas:
bf
.
appearance
(
context
.
document
,
PdfAnnotApp
eara
nce
.
rollover
,
matrix:
mat
,
boundingBox:
box
));
_childRollover
.
layout
(
cr
,
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
));
...
...
pdf/pubspec.yaml
View file @
79fe64f
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
3.0.0-nullsafety.
1
version
:
3.0.0-nullsafety.
2
environment
:
sdk
:
"
>=2.12.0-0
<3.0.0"
...
...
pdf/test/widget_form_test.dart
View file @
79fe64f
...
...
@@ -118,7 +118,14 @@ void main() {
Checkbox
(
name:
'Checkbox'
,
value:
true
,
defaultValue:
true
,
),
//
SizedBox
(
width:
20
,
height:
10
),
//
Label
(
label:
'unchecked:'
,
width:
100
),
Checkbox
(
name:
'Unchecked'
,
value:
false
,
),
//
SizedBox
(
width:
double
.
infinity
,
height:
10
),
...
...
test/golden/widgets-form.pdf
View file @
79fe64f
No preview for this file type
Please
register
or
login
to post a comment