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-04-11 09:18:49 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3bcb582f54fb46b27d4d75d1817271743663a07b
3bcb582f
1 parent
bce28073
Implement To be signed flieds
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
86 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/annotation.dart
pdf/lib/src/pdf/signature.dart
pdf/lib/src/widgets/annotations.dart
pdf/lib/src/widgets/forms.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
3bcb582
# Changelog
## 3.3.0
-
Implement To be signed flieds
## 3.2.0
-
Fix documentation
...
...
pdf/lib/src/pdf/annotation.dart
View file @
3bcb582
...
...
@@ -417,9 +417,10 @@ class PdfAnnotSign extends PdfAnnotWidget {
@override
void
build
(
PdfPage
page
,
PdfObject
object
,
PdfDict
params
)
{
super
.
build
(
page
,
object
,
params
);
assert
(
page
.
pdfDocument
.
sign
!=
null
);
if
(
page
.
pdfDocument
.
sign
!=
null
)
{
params
[
'/V'
]
=
page
.
pdfDocument
.
sign
!.
ref
();
}
}
}
enum
PdfFieldFlags
{
...
...
pdf/lib/src/pdf/signature.dart
View file @
3bcb582
...
...
@@ -25,16 +25,17 @@ enum PdfSigFlags { signaturesExist, appendOnly }
class
PdfSignature
extends
PdfObjectDict
{
PdfSignature
(
PdfDocument
pdfDocument
,
{
required
this
.
crypto
,
Set
<
PdfSigFlags
>?
flags
,
})
:
flags
=
flags
??
const
<
PdfSigFlags
>{
PdfSigFlags
.
signaturesExist
},
super
(
pdfDocument
,
type:
'/Sig'
);
required
this
.
value
,
required
this
.
flags
,
})
:
super
(
pdfDocument
,
type:
'/Sig'
);
final
Set
<
PdfSigFlags
>
flags
;
final
PdfSignatureBase
crypto
;
final
PdfSignatureBase
value
;
int
get
flagsValue
=>
flags
int
get
flagsValue
=>
flags
.
isEmpty
?
0
:
flags
.
map
<
int
>((
PdfSigFlags
e
)
=>
1
>>
e
.
index
)
.
reduce
((
int
a
,
int
b
)
=>
a
|
b
);
...
...
@@ -43,7 +44,7 @@ class PdfSignature extends PdfObjectDict {
@override
void
write
(
PdfStream
os
)
{
crypto
.
preSign
(
this
,
params
);
value
.
preSign
(
this
,
params
);
_offsetStart
=
os
.
offset
+
'
$objser
$objgen
obj
\n
'
.
length
;
super
.
write
(
os
);
...
...
@@ -54,7 +55,7 @@ class PdfSignature extends PdfObjectDict {
assert
(
_offsetStart
!=
null
&&
_offsetEnd
!=
null
,
'Must reserve the object space before signing the document'
);
await
crypto
.
sign
(
this
,
os
,
params
,
_offsetStart
,
_offsetEnd
);
await
value
.
sign
(
this
,
os
,
params
,
_offsetStart
,
_offsetEnd
);
}
}
...
...
pdf/lib/src/widgets/annotations.dart
View file @
3bcb582
...
...
@@ -100,57 +100,6 @@ class AnnotationUrl extends AnnotationBuilder {
}
}
class
AnnotationSignature
extends
AnnotationBuilder
{
AnnotationSignature
(
this
.
crypto
,
{
this
.
name
,
this
.
signFlags
,
this
.
border
,
this
.
flags
,
this
.
date
,
this
.
color
,
this
.
highlighting
,
});
final
Set
<
PdfSigFlags
>?
signFlags
;
final
PdfSignatureBase
crypto
;
final
String
?
name
;
final
PdfBorder
?
border
;
final
Set
<
PdfAnnotFlags
>?
flags
;
final
DateTime
?
date
;
final
PdfColor
?
color
;
final
PdfAnnotHighlighting
?
highlighting
;
@override
void
build
(
Context
context
,
PdfRect
?
box
)
{
context
.
document
.
sign
??=
PdfSignature
(
context
.
document
,
crypto:
crypto
,
flags:
signFlags
,
);
PdfAnnot
(
context
.
page
,
PdfAnnotSign
(
rect:
context
.
localToGlobal
(
box
!),
fieldName:
name
,
border:
border
,
flags:
flags
,
date:
date
,
color:
color
,
highlighting:
highlighting
,
),
);
}
}
class
AnnotationTextField
extends
AnnotationBuilder
{
AnnotationTextField
({
this
.
name
,
...
...
@@ -259,31 +208,6 @@ class UrlLink extends Annotation {
})
:
super
(
child:
child
,
builder:
AnnotationUrl
(
destination
));
}
class
Signature
extends
Annotation
{
Signature
({
required
Widget
child
,
required
PdfSignatureBase
crypto
,
required
String
name
,
Set
<
PdfSigFlags
>?
signFlags
,
PdfBorder
?
border
,
Set
<
PdfAnnotFlags
>?
flags
,
DateTime
?
date
,
PdfColor
?
color
,
PdfAnnotHighlighting
?
highlighting
,
})
:
super
(
child:
child
,
builder:
AnnotationSignature
(
crypto
,
signFlags:
signFlags
,
name:
name
,
border:
border
,
flags:
flags
,
date:
date
,
color:
color
,
highlighting:
highlighting
,
));
}
class
Outline
extends
Anchor
{
Outline
({
Widget
?
child
,
...
...
pdf/lib/src/widgets/forms.dart
View file @
3bcb582
...
...
@@ -307,3 +307,94 @@ class TextField extends StatelessWidget {
PdfAnnot
(
context
.
page
,
tf
);
}
}
class
Signature
extends
SingleChildWidget
{
Signature
({
Widget
?
child
,
@Deprecated
(
'Use value instead'
)
PdfSignatureBase
?
crypto
,
PdfSignatureBase
?
value
,
required
this
.
name
,
this
.
appendOnly
=
false
,
this
.
border
,
this
.
flags
,
this
.
date
,
this
.
color
,
this
.
highlighting
,
})
:
value
=
value
??
crypto
,
super
(
child:
child
);
/// Field name
final
String
name
;
/// Digital signature
final
PdfSignatureBase
?
value
;
/// Append
final
bool
appendOnly
;
final
PdfBorder
?
border
;
/// Flags for this field
final
Set
<
PdfAnnotFlags
>?
flags
;
/// Date metadata
final
DateTime
?
date
;
/// Field color
final
PdfColor
?
color
;
/// Field highlighting
final
PdfAnnotHighlighting
?
highlighting
;
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
if
(
value
!=
null
)
{
context
.
document
.
sign
??=
PdfSignature
(
context
.
document
,
value:
value
!,
flags:
{
PdfSigFlags
.
signaturesExist
,
if
(
appendOnly
)
PdfSigFlags
.
appendOnly
,
},
);
}
else
{
paintChild
(
context
);
}
final
bf
=
PdfAnnotSign
(
rect:
context
.
localToGlobal
(
box
!),
fieldName:
name
,
border:
border
,
flags:
flags
,
date:
date
,
color:
color
,
highlighting:
highlighting
,
);
if
(
child
!=
null
&&
value
!=
null
)
{
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
);
final
canvas
=
bf
.
appearance
(
context
.
document
,
PdfAnnotAppearance
.
normal
,
matrix:
mat
);
Widget
.
draw
(
child
!,
offset:
PdfPoint
.
zero
,
canvas:
canvas
,
page:
context
.
page
,
constraints:
BoxConstraints
.
tightFor
(
width:
box
!.
width
,
height:
box
!.
height
),
);
}
PdfAnnot
(
context
.
page
,
bf
);
}
}
...
...
pdf/pubspec.yaml
View file @
3bcb582
...
...
@@ -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.
2
.0
version
:
3.
3
.0
environment
:
sdk
:
"
>=2.12.0-0
<3.0.0"
...
...
Please
register
or
login
to post a comment