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:51:10 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
75519f502b5fd78c885d4a35976ed53bcefb5d0f
75519f50
1 parent
284ebaab
Reduce the size of floating numbers
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
pdf/lib/src/data_types.dart
pdf/test/data_types_test.dart
pdf/lib/src/data_types.dart
View file @
75519f5
...
...
@@ -72,7 +72,18 @@ class PdfNum extends PdfDataType {
if
(
value
is
int
)
{
s
.
putString
(
value
.
toInt
().
toString
());
}
else
{
s
.
putString
(
value
.
toStringAsFixed
(
precision
));
var
r
=
value
.
toStringAsFixed
(
precision
);
if
(
r
.
contains
(
'.'
))
{
var
n
=
r
.
length
-
1
;
while
(
r
[
n
]
==
'0'
)
{
n
--;
}
if
(
r
[
n
]
==
'.'
)
{
n
--;
}
r
=
r
.
substring
(
0
,
n
+
1
);
}
s
.
putString
(
r
);
}
}
}
...
...
pdf/test/data_types_test.dart
View file @
75519f5
...
...
@@ -27,9 +27,9 @@ void main() {
test
(
'PdfDataTypes Num'
,
()
{
expect
(
const
PdfNum
(
0
).
toString
(),
'0'
);
expect
(
const
PdfNum
(.
5
).
toString
(),
'0.5
0000
'
);
expect
(
const
PdfNum
(.
5
).
toString
(),
'0.5'
);
expect
(
const
PdfNum
(
50
).
toString
(),
'50'
);
expect
(
const
PdfNum
(
50.1
).
toString
(),
'50.1
0000
'
);
expect
(
const
PdfNum
(
50.1
).
toString
(),
'50.1'
);
});
test
(
'PdfDataTypes String'
,
()
{
...
...
@@ -84,7 +84,7 @@ void main() {
PdfArray
(),
PdfDict
(),
]).
toString
(),
'[/Name/Other false 2.5
0000
null(þÿ
\
x00h
\
x00e
\
x00l
\
x01B
\
x00o)[]<<>>]'
,
'[/Name/Other false 2.5 null(þÿ
\
x00h
\
x00e
\
x00l
\
x01B
\
x00o)[]<<>>]'
,
);
});
...
...
Please
register
or
login
to post a comment