Skip to content

Add a setting for writing PDF files in a more compact way#72

Merged
laurmaedje merged 37 commits intotypst:mainfrom
LaurenzV:compact
Nov 8, 2025
Merged

Add a setting for writing PDF files in a more compact way#72
laurmaedje merged 37 commits intotypst:mainfrom
LaurenzV:compact

Conversation

@LaurenzV
Copy link
Copy Markdown
Contributor

@LaurenzV LaurenzV commented Oct 13, 2025

No description provided.

@LaurenzV
Copy link
Copy Markdown
Contributor Author

I think this should be ready now. The only thing I'm unsure about is that you can't do with_capacity and new_with at the same time, so I added a reserve method for Chunk at least. Maybe I should also add that for Pdf? Other suggestions are welcome.

I've tested it by compiling my thesis with this. Size drops from 4.3MB to 4.1MB, and no viewers seems to have trouble reading the PDF. I've also verified that there are no regressions when pretty is true by running it against the krilla test suite.

Here's how it roughly looks:
image

@LaurenzV LaurenzV marked this pull request as ready for review October 13, 2025 18:40
@laurmaedje laurmaedje requested a review from saecki October 27, 2025 14:48
@saecki
Copy link
Copy Markdown
Member

saecki commented Oct 28, 2025

I think this should be ready now. The only thing I'm unsure about is that you can't do with_capacity and new_with at the same time, so I added a reserve method for Chunk at least. Maybe I should also add that for Pdf? Other suggestions are welcome.

Since Pdf implements DerefMut<Target = Chunk> it's already available.

Otherwise I don't have much to say, LGTM!

Comment thread src/chunk.rs Outdated
Comment thread src/chunk.rs Outdated
Comment thread src/chunk.rs Outdated
Comment thread src/content.rs Outdated
Comment thread src/object.rs Outdated
Comment thread src/chunk.rs
LaurenzV and others added 6 commits October 30, 2025 22:36
Also add `with_settings_and_capacity` after all. It does not hurt and the with_settings + reserve route can incur an extra allocation.
@laurmaedje laurmaedje changed the title Add a configuration to write PDF files in a more compact way Add a setting for writing PDF files in a more compact way Nov 8, 2025
@laurmaedje laurmaedje merged commit 08626d8 into typst:main Nov 8, 2025
2 checks passed
@laurmaedje
Copy link
Copy Markdown
Member

Thank you!

@LaurenzV LaurenzV deleted the compact branch November 8, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants