Conversation
|
While HTML output would be superior in terms of accesiblity, I cannot emphasize enough how much adoption Typst would gain in providing tagged pdf support. I would take a 3x performance hit for this feature. |
# Conflicts: # crates/typst-pdf/src/image.rs # crates/typst-pdf/src/lib.rs
|
I ran benchmarks with the following five Typst documents: masterproef-main (https://github.com/Dherse/masterproef) Results: I think there are two conclusions to draw from this:
|
|
@laurmaedje I think from my side I am mostly done now. There is one bug remaining that I found, when compiling the following document: trying to compile with the standard If you want to do some more testing yourself, that would be appreciated, too. But given the tests I've already run I think we can be pretty sure that no major regressions should be introduced, though there obviously is only one way to find out. 😬 |
Hyphens are created here, always with zero-sized ranges. They don't appear in the source |
|
Ah, that's unfortunate, because it means that a document with hyphenation cannot be exported to PDF/A2/A3-u... But I guess this can be figured out at a later point. |
|
Something about krilla's output is not reproducible. Just running the Typst test suite twice will generate differing PDFs. I'm not sure why. |
krilla
|
Let's merge this! 🎉 It's been quite the journey and I'm super grateful for all the work you've poured into this. This is easily the largest and most impressive community contribution to Typst so far. I believe it builds a really strong foundation for the future of Typst's PDF export. So, huge props and thanks! The road to merge was probably much longer than anticipated, so thanks for staying on it. :) |
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This is how it used to work but one place was missed in #5420. This PR factors the behaviour out into a function, such that it is not missed again. This is necessary because e.g. the position of backlinks to footnotes is always at the baseline and if you link directly to it, the text will not be visible since it is right above.

Note that this PR is not ready for review, and probably won't be for a long while. It's just for experimenting, for now.
Introduction
krilla is a Rust crate I have been working on in the past few months. It builds on top of the
pdf-writercrate and is a higher-level crate that allows for the creation of PDF files using high-level primitives. It therefore encompasses the featuressvg2pdfandtypst-pdfcurrently have (and a lot more), and abstracts away most complexities of PDF away behind a high-level interface.Why?
Using this crate would have multiple advantages:
svg2pdfandtypst-pdf, and thus allows us to prevent code duplication, making it easier to implement new features. It also reduces file sizes, since objects can now be cached globally.typst-pdfcode much shorter and simpler, reducing the chance of bugs (not meaning that we shouldn't implement PDF regression tests at some point). Most of the complexity of PDF creation is abstracted away.krillais tested relatively extensively, both using visual regression tests as well as snapshot-based tests, (hopefully) reducing the chance of accidentally introducing bugs in the future. It removes a lot of the burden from Typst to ensure that PDF output is spec-conforming.ActualTextattributes (fixing Different characters that use the same glyph result in the same character when copied from PDFs #526, perhaps also PDF text extraction can fail in complex shaping scenarios #4225)The main disadvantage is that it probably will lead to some performance penalty due to the extra layer of abstraction added, thought it remains to be determined how much. PDF 2.0 and its substandards are currently not supported either, unfortunately.
Notes
Note that it's not been decided whether we actually want to make that switch, and if it does happen it will still be multiple weeks in the future, as it would require extensive testing (both in terms of correctness as well as performance-wise), and there are still some things left to do in
krillaitself.TODO List
Next steps:
typst-pdfhave been ported.After the above is done and you think overall the shape of the code is good, extensive testing would be the next step and roughly like this:
verapdfand Adobe Acrobat to see whether validation passes.