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
2020-12-26 07:58:59 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cc971a2c8cae1f29d597aad51429ed3f63e4c215
cc971a2c
1 parent
b5b86c5c
Improve PdfName conformance
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
pdf/lib/src/data_types.dart
pdf/test/data_types_test.dart
pdf/lib/src/data_types.dart
View file @
cc971a2
...
...
@@ -315,7 +315,27 @@ class PdfName extends PdfDataType {
@override
void
output
(
PdfStream
s
)
{
assert
(
value
[
0
]
==
'/'
);
s
.
putString
(
value
);
final
bytes
=
<
int
>[];
for
(
final
c
in
value
.
codeUnits
)
{
assert
(
c
<
0xff
&&
c
>
0x00
);
if
(
c
<
0x21
||
c
>
0x7E
||
c
==
0x23
||
(
c
==
0x2f
&&
bytes
.
isNotEmpty
)
||
c
==
0x5b
||
c
==
0x5d
||
c
==
0x28
||
c
==
0x3c
||
c
==
0x3e
)
{
bytes
.
add
(
0x23
);
final
x
=
c
.
toRadixString
(
16
).
padLeft
(
2
,
'0'
);
bytes
.
addAll
(
x
.
codeUnits
);
}
else
{
bytes
.
add
(
c
);
}
}
s
.
putBytes
(
bytes
);
}
}
...
...
pdf/test/data_types_test.dart
View file @
cc971a2
...
...
@@ -25,6 +25,12 @@ void main() {
expect
(
const
PdfBool
(
false
).
toString
(),
'false'
);
});
test
(
'PdfDataTypes Name '
,
()
{
expect
(
const
PdfName
(
'/Test'
).
toString
(),
'/Test'
);
expect
(
const
PdfName
(
'/Type 1'
).
toString
(),
'/Type#201'
);
expect
(
const
PdfName
(
'/Num#1'
).
toString
(),
'/Num#231'
);
});
test
(
'PdfDataTypes Num'
,
()
{
expect
(
const
PdfNum
(
0
).
toString
(),
'0'
);
expect
(
const
PdfNum
(.
5
).
toString
(),
'0.5'
);
...
...
Please
register
or
login
to post a comment