Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: Include the option for cross-reference stream #804

Open
andersonhc opened this issue Jun 5, 2023 · 3 comments
Open

Comments

@andersonhc
Copy link
Collaborator

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

@Lucas-C
Copy link
Member

Lucas-C commented Jun 5, 2023

Interesting suggestion.

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

@andersonhc
Copy link
Collaborator Author

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œ�ÐOH�p�Æñç±Ürs[+m9HF�‰��fb��á��vè �„È:HŒðÏR6X�ÑÀ��×!"Rè”Þ„´¼DÝD�é��«£�¥‹Š}wø�~ï�?ž÷‘$+.�Nå·u5©$�ŸbM�
bVnÝ—#i9>†�¹m��râ�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��â�Z�B�­ˆ Š�Î#Ž�¸ˆ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.

@Lucas-C
Copy link
Member

Lucas-C commented Aug 2, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants