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-02 08:42:02 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
286002c859847dfcecc3e1ef943c66a9b4038134
286002c8
1 parent
3bcb582f
Improve Signature fields
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
3 deletions
pdf/lib/src/pdf/catalog.dart
pdf/lib/src/pdf/page.dart
pdf/lib/src/pdf/signature.dart
pdf/lib/src/widgets/forms.dart
pdf/lib/src/pdf/catalog.dart
View file @
286002c
...
...
@@ -81,11 +81,28 @@ class PdfCatalog extends PdfObjectDict {
params
[
'/PageMode'
]
=
PdfName
(
_PdfPageModes
[
pageMode
.
index
]);
if
(
pdfDocument
.
sign
!=
null
)
{
if
(
pdfDocument
.
sign
!.
value
.
hasMDP
)
{
params
[
'/Perms'
]
=
PdfDict
({
'/DocMDP'
:
pdfDocument
.
sign
!.
ref
(),
});
}
final
dss
=
PdfDict
();
if
(
pdfDocument
.
sign
!.
crl
.
isNotEmpty
)
{
dss
[
'/CRLs'
]
=
PdfArray
.
fromObjects
(
pdfDocument
.
sign
!.
crl
);
}
if
(
pdfDocument
.
sign
!.
cert
.
isNotEmpty
)
{
dss
[
'/Certs'
]
=
PdfArray
.
fromObjects
(
pdfDocument
.
sign
!.
cert
);
}
if
(
pdfDocument
.
sign
!.
ocsp
.
isNotEmpty
)
{
dss
[
'/OCSPs'
]
=
PdfArray
.
fromObjects
(
pdfDocument
.
sign
!.
ocsp
);
}
if
(
dss
.
values
.
isNotEmpty
)
{
params
[
'/DSS'
]
=
dss
;
}
}
final
widgets
=
<
PdfAnnot
>[];
for
(
var
page
in
pdfDocument
.
pdfPageList
.
pages
)
{
for
(
var
annot
in
page
.
annotations
)
{
...
...
@@ -100,6 +117,13 @@ class PdfCatalog extends PdfObjectDict {
'/SigFlags'
:
PdfNum
(
pdfDocument
.
sign
?.
flagsValue
??
0
),
'/Fields'
:
PdfArray
.
fromObjects
(
widgets
),
});
// final acroForm = (params['/AcroForm'] ??= PdfDict()) as PdfDict;
// acroForm['/SigFlags'] = PdfNum(pdfDocument.sign?.flagsValue ?? 0);
// final fields = (acroForm['/Fields'] ??= PdfArray()) as PdfArray;
// for (final w in widgets) {
// fields.add(w.ref());
// }
}
}
}
...
...
pdf/lib/src/pdf/page.dart
View file @
286002c
...
...
@@ -47,7 +47,9 @@ class PdfPage extends PdfObjectDict with PdfGraphicStream {
this
.
pageFormat
=
PdfPageFormat
.
standard
,
this
.
rotate
=
PdfPageRotation
.
none
,
int
?
index
,
})
:
super
(
pdfDocument
,
type:
'/Page'
)
{
int
?
objser
,
int
objgen
=
0
,
})
:
super
(
pdfDocument
,
type:
'/Page'
,
objser:
objser
,
objgen:
objgen
)
{
if
(
index
!=
null
)
{
pdfDocument
.
pdfPageList
.
pages
.
insert
(
index
,
this
);
}
else
{
...
...
pdf/lib/src/pdf/signature.dart
View file @
286002c
...
...
@@ -14,20 +14,53 @@
* limitations under the License.
*/
import
'dart:typed_data'
;
import
'package:pdf/src/pdf/object_stream.dart'
;
import
'data_types.dart'
;
import
'document.dart'
;
import
'object.dart'
;
import
'object_dict.dart'
;
import
'stream.dart'
;
enum
PdfSigFlags
{
signaturesExist
,
appendOnly
}
/// Signature flags
enum
PdfSigFlags
{
/// The document contains at least one signature field.
signaturesExist
,
/// The document contains signatures that may be invalidated if the file is
/// saved (written) in a way that alters its previous contents, as opposed
/// to an incremental update.
appendOnly
,
}
class
PdfSignature
extends
PdfObjectDict
{
PdfSignature
(
PdfDocument
pdfDocument
,
{
required
this
.
value
,
required
this
.
flags
,
})
:
super
(
pdfDocument
,
type:
'/Sig'
);
List
<
Uint8List
>?
crl
,
List
<
Uint8List
>?
cert
,
List
<
Uint8List
>?
ocsp
,
})
:
super
(
pdfDocument
,
type:
'/Sig'
)
{
if
(
crl
!=
null
)
{
for
(
final
o
in
crl
)
{
this
.
crl
.
add
(
PdfObjectStream
(
pdfDocument
)..
buf
.
putBytes
(
o
));
}
}
if
(
cert
!=
null
)
{
for
(
final
o
in
cert
)
{
this
.
cert
.
add
(
PdfObjectStream
(
pdfDocument
)..
buf
.
putBytes
(
o
));
}
}
if
(
ocsp
!=
null
)
{
for
(
final
o
in
ocsp
)
{
this
.
ocsp
.
add
(
PdfObjectStream
(
pdfDocument
)..
buf
.
putBytes
(
o
));
}
}
}
final
Set
<
PdfSigFlags
>
flags
;
...
...
@@ -39,7 +72,14 @@ class PdfSignature extends PdfObjectDict {
.
map
<
int
>((
PdfSigFlags
e
)
=>
1
>>
e
.
index
)
.
reduce
((
int
a
,
int
b
)
=>
a
|
b
);
final
crl
=
<
PdfObjectStream
>[];
final
cert
=
<
PdfObjectStream
>[];
final
ocsp
=
<
PdfObjectStream
>[];
int
?
_offsetStart
;
int
?
_offsetEnd
;
@override
...
...
@@ -60,6 +100,9 @@ class PdfSignature extends PdfObjectDict {
}
abstract
class
PdfSignatureBase
{
/// Modification detection and prevention
bool
get
hasMDP
=>
false
;
void
preSign
(
PdfObject
object
,
PdfDict
params
);
Future
<
void
>
sign
(
PdfObject
object
,
PdfStream
os
,
PdfDict
params
,
...
...
pdf/lib/src/widgets/forms.dart
View file @
286002c
...
...
@@ -14,6 +14,8 @@
* limitations under the License.
*/
import
'dart:typed_data'
;
import
'package:pdf/pdf.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -320,6 +322,9 @@ class Signature extends SingleChildWidget {
this
.
date
,
this
.
color
,
this
.
highlighting
,
this
.
crl
,
this
.
cert
,
this
.
ocsp
,
})
:
value
=
value
??
crypto
,
super
(
child:
child
);
...
...
@@ -346,6 +351,15 @@ class Signature extends SingleChildWidget {
/// Field highlighting
final
PdfAnnotHighlighting
?
highlighting
;
/// Certificate revocation lists
final
List
<
Uint8List
>?
crl
;
/// Additional X509 certificates
final
List
<
Uint8List
>?
cert
;
/// Online Certificate Status Protocol
final
List
<
Uint8List
>?
ocsp
;
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
...
...
@@ -358,6 +372,9 @@ class Signature extends SingleChildWidget {
PdfSigFlags
.
signaturesExist
,
if
(
appendOnly
)
PdfSigFlags
.
appendOnly
,
},
crl:
crl
,
cert:
cert
,
ocsp:
ocsp
,
);
}
else
{
paintChild
(
context
);
...
...
Please
register
or
login
to post a comment