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-28 10:51:44 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d355cbe5a9a9d868c7b97e860cbc99b48a6455c4
d355cbe5
1 parent
bf1d6657
Improve internal null-safety
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
35 additions
and
31 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/annotation.dart
pdf/lib/src/pdf/data_types.dart
pdf/lib/src/pdf/document.dart
pdf/lib/src/pdf/graphic_stream.dart
pdf/lib/src/pdf/names.dart
pdf/lib/src/pdf/page.dart
pdf/lib/src/widgets/annotations.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
d355cbe
# Changelog
## 3.0.1
-
Improve internal null-safety
## 3.0.0
-
Fix Checkbox Widget
...
...
pdf/lib/src/pdf/annotation.dart
View file @
d355cbe
...
...
@@ -123,7 +123,7 @@ abstract class PdfAnnotBase {
/// Color
final
PdfColor
?
color
;
final
Map
<
String
?,
PdfDataType
>
_appearances
=
<
String
?
,
PdfDataType
>{};
final
Map
<
String
,
PdfDataType
>
_appearances
=
<
String
,
PdfDataType
>{};
PdfName
?
_as
;
...
...
@@ -231,7 +231,7 @@ abstract class PdfAnnotBase {
if
(
_appearances
.
isNotEmpty
)
{
params
[
'/AP'
]
=
PdfDict
(
_appearances
);
if
(
_as
!=
null
)
{
params
[
'/AS'
]
=
_as
;
params
[
'/AS'
]
=
_as
!
;
}
}
}
...
...
pdf/lib/src/pdf/data_types.dart
View file @
d355cbe
...
...
@@ -158,7 +158,7 @@ class PdfString extends PdfDataType {
return
PdfString
(
_date
(
date
));
}
final
Uint8List
?
value
;
final
Uint8List
value
;
final
PdfStringFormat
format
;
...
...
@@ -269,11 +269,11 @@ class PdfString extends PdfDataType {
int
_codeUnitForDigit
(
int
digit
)
=>
digit
<
10
?
digit
+
0x30
:
digit
+
0x61
-
10
;
void
_output
(
PdfStream
s
,
Uint8List
?
value
)
{
void
_output
(
PdfStream
s
,
Uint8List
value
)
{
switch
(
format
)
{
case
PdfStringFormat
.
binary
:
s
.
putByte
(
0x3c
);
for
(
var
byte
in
value
!
)
{
for
(
var
byte
in
value
)
{
s
.
putByte
(
_codeUnitForDigit
((
byte
&
0xF0
)
>>
4
));
s
.
putByte
(
_codeUnitForDigit
(
byte
&
0x0F
));
}
...
...
@@ -281,7 +281,7 @@ class PdfString extends PdfDataType {
break
;
case
PdfStringFormat
.
litteral
:
s
.
putByte
(
40
);
_putTextBytes
(
s
,
value
!
);
_putTextBytes
(
s
,
value
);
s
.
putByte
(
41
);
break
;
}
...
...
@@ -350,7 +350,7 @@ class PdfSecString extends PdfString {
return
super
.
output
(
s
);
}
final
enc
=
object
.
pdfDocument
.
encryption
!.
encrypt
(
value
!
,
object
);
final
enc
=
object
.
pdfDocument
.
encryption
!.
encrypt
(
value
,
object
);
_output
(
s
,
enc
);
}
}
...
...
@@ -457,9 +457,9 @@ class PdfArray extends PdfDataType {
return
PdfArray
(
list
.
map
<
PdfNum
>((
num
?
e
)
=>
PdfNum
(
e
!)).
toList
());
}
final
List
<
PdfDataType
?>
values
=
<
PdfDataType
?
>[];
final
List
<
PdfDataType
>
values
=
<
PdfDataType
>[];
void
add
(
PdfDataType
?
v
)
{
void
add
(
PdfDataType
v
)
{
values
.
add
(
v
);
}
...
...
@@ -468,7 +468,7 @@ class PdfArray extends PdfDataType {
s
.
putString
(
'['
);
if
(
values
.
isNotEmpty
)
{
for
(
var
n
=
0
;
n
<
values
.
length
;
n
++)
{
final
val
=
values
[
n
]
!
;
final
val
=
values
[
n
];
if
(
n
>
0
&&
!(
val
is
PdfName
||
val
is
PdfString
||
...
...
@@ -489,7 +489,7 @@ class PdfArray extends PdfDataType {
}
// ignore: prefer_collection_literals
final
uniques
=
LinkedHashMap
<
PdfDataType
?
,
bool
>();
final
uniques
=
LinkedHashMap
<
PdfDataType
,
bool
>();
for
(
final
s
in
values
)
{
uniques
[
s
]
=
true
;
}
...
...
@@ -511,7 +511,7 @@ class PdfArray extends PdfDataType {
}
class
PdfDict
extends
PdfDataType
{
PdfDict
([
Map
<
String
?
,
PdfDataType
>?
values
])
{
PdfDict
([
Map
<
String
,
PdfDataType
>?
values
])
{
if
(
values
!=
null
)
{
this
.
values
.
addAll
(
values
);
}
...
...
@@ -526,27 +526,27 @@ class PdfDict extends PdfDataType {
);
}
final
Map
<
String
?,
PdfDataType
?>
values
=
<
String
?,
PdfDataType
?
>{};
final
Map
<
String
,
PdfDataType
>
values
=
<
String
,
PdfDataType
>{};
bool
get
isNotEmpty
=>
values
.
isNotEmpty
;
operator
[]=(
String
k
,
PdfDataType
?
v
)
{
operator
[]=(
String
k
,
PdfDataType
v
)
{
values
[
k
]
=
v
;
}
PdfDataType
?
operator
[](
String
?
k
)
{
PdfDataType
?
operator
[](
String
k
)
{
return
values
[
k
];
}
@override
void
output
(
PdfStream
s
)
{
s
.
putBytes
(
const
<
int
>[
0x3c
,
0x3c
]);
values
.
forEach
((
String
?
k
,
PdfDataType
?
v
)
{
values
.
forEach
((
String
k
,
PdfDataType
v
)
{
s
.
putString
(
k
);
if
(
v
is
PdfNum
||
v
is
PdfBool
||
v
is
PdfNull
||
v
is
PdfIndirect
)
{
s
.
putByte
(
0x20
);
}
v
!
.
output
(
s
);
v
.
output
(
s
);
});
s
.
putBytes
(
const
<
int
>[
0x3e
,
0x3e
]);
}
...
...
@@ -557,7 +557,7 @@ class PdfDict extends PdfDataType {
void
merge
(
PdfDict
other
)
{
for
(
final
key
in
other
.
values
.
keys
)
{
final
value
=
other
[
key
];
final
value
=
other
[
key
]
!
;
final
current
=
values
[
key
];
if
(
current
==
null
)
{
values
[
key
]
=
value
;
...
...
pdf/lib/src/pdf/document.dart
View file @
d355cbe
...
...
@@ -147,7 +147,7 @@ class PdfDocument {
Uint8List
?
_documentID
;
/// Generates the document ID
Uint8List
?
get
documentID
{
Uint8List
get
documentID
{
if
(
_documentID
==
null
)
{
final
rnd
=
math
.
Random
();
_documentID
=
Uint8List
.
fromList
(
sha256
...
...
@@ -156,7 +156,7 @@ class PdfDocument {
.
bytes
);
}
return
_documentID
;
return
_documentID
!
;
}
/// Creates a new serial number
...
...
@@ -169,18 +169,18 @@ class PdfDocument {
}
/// The root outline
PdfOutline
?
get
outline
{
PdfOutline
get
outline
{
if
(
_outline
==
null
)
{
_outline
=
PdfOutline
(
this
);
catalog
.
outlines
=
_outline
;
}
return
_outline
;
return
_outline
!
;
}
/// Graphic states for opacity and transfer modes
PdfGraphicStates
?
get
graphicStates
{
PdfGraphicStates
get
graphicStates
{
_graphicStates
??=
PdfGraphicStates
(
this
);
return
_graphicStates
;
return
_graphicStates
!
;
}
/// This document has at least one graphic state
...
...
pdf/lib/src/pdf/graphic_stream.dart
View file @
d355cbe
...
...
@@ -88,7 +88,7 @@ mixin PdfGraphicStream on PdfObject {
/// Generate a name for the graphic state object
String
stateName
(
PdfGraphicState
state
)
{
return
pdfDocument
.
graphicStates
!
.
stateName
(
state
);
return
pdfDocument
.
graphicStates
.
stateName
(
state
);
}
@override
...
...
@@ -135,7 +135,7 @@ mixin PdfGraphicStream on PdfObject {
'/K'
:
PdfBool
(
knockoutTransparency
),
});
resources
[
'/ExtGState'
]
=
pdfDocument
.
graphicStates
!
.
ref
();
resources
[
'/ExtGState'
]
=
pdfDocument
.
graphicStates
.
ref
();
}
if
(
params
.
containsKey
(
'/Resources'
))
{
...
...
pdf/lib/src/pdf/names.dart
View file @
d355cbe
...
...
@@ -57,7 +57,7 @@ class PdfNames extends PdfObject {
for
(
var
name
in
keys
)
{
dests
.
add
(
PdfSecString
.
fromString
(
this
,
name
));
dests
.
add
(
_dests
[
name
]);
dests
.
add
(
_dests
[
name
]
!
);
}
final
dict
=
PdfDict
();
...
...
pdf/lib/src/pdf/page.dart
View file @
d355cbe
...
...
@@ -80,7 +80,7 @@ class PdfPage extends PdfObject with PdfGraphicStream {
final
contentList
=
PdfArray
.
fromObjects
(
contents
);
if
(
params
.
containsKey
(
'/Contents'
))
{
final
prevContent
=
params
[
'/Contents'
];
final
prevContent
=
params
[
'/Contents'
]
!
;
if
(
prevContent
is
PdfArray
)
{
contentList
.
values
.
insertAll
(
0
,
prevContent
.
values
);
}
else
{
...
...
pdf/lib/src/widgets/annotations.dart
View file @
d355cbe
...
...
@@ -337,7 +337,7 @@ class Outline extends Anchor {
var
l
=
level
;
while
(
l
>
0
)
{
if
(
parent
!
.
effectiveLevel
==
l
)
{
if
(
parent
.
effectiveLevel
==
l
)
{
break
;
}
...
...
@@ -349,6 +349,6 @@ class Outline extends Anchor {
l
--;
}
parent
!
.
add
(
_outline
!);
parent
.
add
(
_outline
!);
}
}
...
...
pdf/pubspec.yaml
View file @
d355cbe
...
...
@@ -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
version
:
3.0.
1
environment
:
sdk
:
"
>=2.12.0-0
<3.0.0"
...
...
Please
register
or
login
to post a comment