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
2023-05-01 13:45:59 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b0b5c97901d41dfed9d4739c73a778f0ab4d2fe9
b0b5c979
1 parent
13b792cf
Allow saving an unmodified document
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/document.dart
pdf/lib/src/pdf/format/xref.dart
pdf/CHANGELOG.md
View file @
b0b5c97
...
...
@@ -7,6 +7,7 @@
-
Improve PdfArray and PdfDict constructors
-
Fix underline on spans
[
RomanIvn
]
-
Improve verbose output
-
Allow saving an unmodified document
## 3.10.1
...
...
pdf/lib/src/pdf/document.dart
View file @
b0b5c97
...
...
@@ -219,7 +219,7 @@ class PdfDocument {
Future
<
void
>
_write
(
PdfStream
os
)
async
{
PdfSignature
?
signature
;
final
xref
=
PdfXrefTable
();
final
xref
=
PdfXrefTable
(
lastObjectId:
_objser
);
for
(
final
ob
in
objects
.
where
((
e
)
=>
e
.
inUse
))
{
ob
.
prepare
();
...
...
pdf/lib/src/pdf/format/xref.dart
View file @
b0b5c97
...
...
@@ -91,7 +91,7 @@ class PdfXref extends PdfIndirect {
}
class
PdfXrefTable
extends
PdfDataType
with
PdfDiagnostic
{
PdfXrefTable
();
PdfXrefTable
(
{
this
.
lastObjectId
=
0
}
);
/// Document root point
final
params
=
PdfDict
();
...
...
@@ -99,6 +99,8 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
/// List of objects to write
final
objects
=
<
PdfObjectBase
>{};
final
int
lastObjectId
;
/// Writes a block of references to the Pdf file
void
_writeBlock
(
PdfStream
s
,
int
firstId
,
List
<
PdfXref
>
block
)
{
s
.
putString
(
'
$firstId
${block.length}
\n
'
);
...
...
@@ -192,7 +194,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
int
_outputLegacy
(
PdfObjectBase
o
,
PdfStream
s
,
List
<
PdfXref
>
xrefList
)
{
// Now scan through the offsets list. They should be in sequence.
xrefList
.
sort
((
a
,
b
)
=>
a
.
ser
.
compareTo
(
b
.
ser
));
final
size
=
xrefList
.
last
.
ser
+
1
;
final
size
=
math
.
max
(
lastObjectId
,
xrefList
.
last
.
ser
+
1
)
;
var
firstId
=
0
;
// First id in block
var
lastId
=
0
;
// The last id used
...
...
@@ -249,7 +251,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
xrefList
.
sort
((
a
,
b
)
=>
a
.
ser
.
compareTo
(
b
.
ser
));
// Write this object too
final
id
=
xrefList
.
last
.
ser
+
1
;
final
id
=
math
.
max
(
lastObjectId
,
xrefList
.
last
.
ser
+
1
)
;
final
size
=
id
+
1
;
xrefList
.
add
(
PdfXref
(
id
,
offset
));
...
...
Please
register
or
login
to post a comment