fpdf2 icon indicating copy to clipboard operation
fpdf2 copied to clipboard

Feature suggestion: Include the option for cross-reference stream

Open andersonhc opened this issue 2 years ago • 3 comments

Since PDF 1.5, cross-reference streams can be used instead of cross-reference tables. Since streams can be compressed it helps reducing the PDF file size.

XRef streams will also allow to use features like object streams in the future

andersonhc avatar Jun 05 '23 18:06 andersonhc

Interesting suggestion.

Where in fpdf2-produced PDF documents do you think that cross-reference streams could/should be used?

Lucas-C avatar Jun 05 '23 19:06 Lucas-C

Interesting suggestion.

Where in fpdf2-produced PDF documents do you think that cross-reference streams could/should be used?

Cross-reference streams replace the normal cross-reference.

The normal cross-refence table looks like this:

xref
0 21
0000000000 65535 f 
0000000009 00000 n 
0000000096 00000 n 
0000000199 00000 n 
0000000280 00000 n 
0000000446 00000 n 
0000000584 00000 n 
0000000808 00000 n 
0000001406 00000 n 
0000001475 00000 n 
0000001687 00000 n 
0000001950 00000 n 
0000004839 00000 n 
0000004988 00000 n 
0000005275 00000 n 
0000006056 00000 n 
0000006126 00000 n 
0000006347 00000 n 
0000006624 00000 n 
0000012282 00000 n 
0000012381 00000 n 

While cross-reference streams looks like this:

121 0 obj <</Type/XRef/Size 122/Root 2 0 R/Index [0 122]/Filter/FlateDecode/Length 342/W[1 2 1]>>
stream
xœÐOHpÆñç±Ürs[+m9HF‰fbávè „È:HŒðÏR6XÑÀ×!"Rè”Þ„´¼DÝDé«£¥‹Š}wø~ï?ž÷‘$+.Nå·u5©$ŸbM
bVnÝ—#i9>†¹mrâNää>ÉW~ȝQ9µŠ¿òµN<’¯ïÊ]-r÷ŽœÊ=
¹7Œa¹ÿ	>Ê·¾âH¾½„=ùnÈ÷Êø"ý–3WåìgÊÃ5lË92æ6äû70%¼ÇOùá:È>Ú‡i9Ï;Ï{<†œ\`^`>ñKžLÊE2ÿÈÏãƒ\JaìËì+䨐ãùMåÜ;ǽUþ©òÏü±\£³ÚþÉ/ñ]^¼ƒŠ\§‡×ôð&‹Wô=ÐèÛhœE3âZB­ˆ ŠÎ#ޏˆ6´ã¸ìwyy¹¤ÿ¾ã\êendstream
endobject

When you use cross-reference streams you can also use object streams. I used it in the past to get all my bookmarks (outlines) objects and put them all inside a compressed stream. It was an extreme case but for very large PDF files it helps you produce smaller files.

andersonhc avatar Jun 05 '23 19:06 andersonhc

When you use cross-reference streams you can also use object streams. I used it in the past to get all my bookmarks (outlines) objects and put them all inside a compressed stream. It was an extreme case but for very large PDF files it helps you produce smaller files.

OK

They yeah, fpdf2 would welcome such feature if someone is willing to implement it!

Lucas-C avatar Aug 02 '23 10:08 Lucas-C