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-06-24 10:42:54 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d131cbf6b9f6d0b735d5b77a0e00912a4f171c3e
d131cbf6
1 parent
52a70d1a
Add Document ID
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
4 deletions
pdf/CHANGELOG.md
pdf/lib/pdf.dart
pdf/lib/src/document.dart
pdf/lib/src/output.dart
pdf/lib/src/stream.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
d131cbf
## 1.3.14
*
Add Document ID
## 1.3.13
*
Do not modify the TTF font streams
...
...
pdf/lib/pdf.dart
View file @
d131cbf
...
...
@@ -21,6 +21,7 @@ import 'dart:convert';
import
'dart:math'
as
math
;
import
'dart:typed_data'
;
import
'package:crypto/crypto.dart'
;
import
'package:meta/meta.dart'
;
import
'package:utf/utf.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
...
...
@@ -34,21 +35,21 @@ part 'src/color.dart';
part
'src/colors.dart'
;
part
'src/compatibility.dart'
;
part
'src/document.dart'
;
part
'src/font.dart'
;
part
'src/font_descriptor.dart'
;
part
'src/font_metrics.dart'
;
part
'src/font.dart'
;
part
'src/formxobject.dart'
;
part
'src/graphics.dart'
;
part
'src/image.dart'
;
part
'src/info.dart'
;
part
'src/names.dart'
;
part
'src/object.dart'
;
part
'src/object_stream.dart'
;
part
'src/object.dart'
;
part
'src/outline.dart'
;
part
'src/output.dart'
;
part
'src/page.dart'
;
part
'src/page_format.dart'
;
part
'src/page_list.dart'
;
part
'src/page.dart'
;
part
'src/point.dart'
;
part
'src/polygon.dart'
;
part
'src/rect.dart'
;
...
...
pdf/lib/src/document.dart
View file @
d131cbf
...
...
@@ -97,6 +97,20 @@ class PdfDocument {
/// This holds the current fonts
final
Set
<
PdfFont
>
fonts
=
Set
<
PdfFont
>();
/// Generates the document ID
List
<
int
>
_documentID
;
List
<
int
>
get
documentID
{
if
(
_documentID
==
null
)
{
final
math
.
Random
rnd
=
math
.
Random
();
_documentID
=
sha256
.
convert
(
DateTime
.
now
().
toIso8601String
().
codeUnits
+
List
<
int
>.
generate
(
32
,
(
_
)
=>
rnd
.
nextInt
(
256
)))
.
bytes
;
}
return
_documentID
;
}
/// Creates a new serial number
int
_genSerial
()
=>
_objser
++;
...
...
pdf/lib/src/output.dart
View file @
d131cbf
...
...
@@ -106,6 +106,8 @@ class PdfOutput {
// the /Root catalog indirect reference (REQUIRED)
if
(
rootID
!=
null
)
{
params
[
'/Root'
]
=
rootID
.
ref
();
final
PdfStream
id
=
PdfStream
.
binary
(
rootID
.
pdfDocument
.
documentID
);
params
[
'/ID'
]
=
PdfStream
.
array
(<
PdfStream
>[
id
,
id
]);
}
else
{
throw
Exception
(
'Root object is not present in document'
);
}
...
...
pdf/lib/src/stream.dart
View file @
d131cbf
...
...
@@ -122,6 +122,22 @@ class PdfStream {
putString
(
value
?
'true'
:
'false'
);
}
/// Returns the ASCII/Unicode code unit corresponding to the hexadecimal digit
/// [digit].
int
_codeUnitForDigit
(
int
digit
)
=>
digit
<
10
?
digit
+
0x30
:
digit
+
0x61
-
10
;
void
putBinary
(
List
<
int
>
s
)
{
_stream
.
add
(
0x3c
);
for
(
int
byte
in
s
)
{
_stream
.
add
(
_codeUnitForDigit
((
byte
&
0xF0
)
>>
4
));
_stream
.
add
(
_codeUnitForDigit
(
byte
&
0x0F
));
}
_stream
.
add
(
0x3e
);
}
static
PdfStream
binary
(
List
<
int
>
s
)
=>
PdfStream
()..
putBinary
(
s
);
void
putArray
(
List
<
PdfStream
>
values
)
{
putString
(
'['
);
for
(
PdfStream
val
in
values
)
{
...
...
pdf/pubspec.yaml
View file @
d131cbf
...
...
@@ -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
:
1.3.1
3
version
:
1.3.1
4
environment
:
sdk
:
"
>=2.1.0
<3.0.0"
...
...
@@ -13,6 +13,7 @@ dependencies:
meta
:
"
^1.1.5"
vector_math
:
"
^2.0.0"
utf
:
"
^0.9.0"
crypto
:
"
^2.0.6"
dev_dependencies
:
test
:
any
...
...
Please
register
or
login
to post a comment