@@ -15,6 +15,8 @@ REBOL [
15
15
The loading is not optimal. It tries to load all objects even these not referenced in cross-reference table.
16
16
It can be changed in the future, but so far, purpose of the code is to learn some PDF implementation details.
17
17
It is not designed for real life processing of large PDF documents.
18
+
19
+ Useful link for manual tests: https://www.pdf-online.com/osa/validate.aspx
18
20
}
19
21
]
20
22
@@ -419,20 +421,25 @@ get-xref-count: function[xrefs n][
419
421
to integer! n
420
422
]
421
423
422
- emit-stream : func [ obj [object! ]] [
424
+ emit-stream : func [ obj [object! ] /local data ] [
423
425
unless find obj 'spec [
424
426
extend obj 'spec # (Length: 0 )
425
427
]
426
- unless any [
427
- obj/spec/Filter
428
- 300 > length? obj/data ; don't use compression on tiny strings
428
+ data: any [obj/data #{} ]
429
+ unless any [ ; don't use compression
430
+ obj/spec/Filter ; if there is already some filter
431
+ 300 > length? data ; if data are small enough
429
432
][
430
433
obj/spec/Filter: 'FlateDecode
431
- obj/data: compress /zlib obj/data
434
+ data: compress /zlib obj/data
435
+ ]
436
+ unless binary? data [
437
+ ; make sure that data are in binary, so the length is correct!
438
+ data: to binary! data
432
439
]
433
- obj/spec/Length: length? obj / data
440
+ obj/spec/Length: length? data
434
441
emit-obj obj/spec
435
- out: insert insert insert out "stream^M^/ " obj / data "^M^/ endstream"
442
+ out: insert insert insert out "stream^M^/ " data "^M^/ endstream"
436
443
]
437
444
438
445
rebol-version-str: rejoin ["Rebol/" system/product " Version " system/version ]
0 commit comments