Repository navigation
Embed files associated with the document as a whole - #5221
Conversation
|
Reproduction#embed.decode("bill-reports.pdf", "test.txt")
#set page("a4")
= header
#pagebreak(weak: true)
#embed("bill-reports.typ")Hope that's the right place for this comment |
I can reproduce this. The current implementation implements I looked at ' Tag ' while looking for other elements that might be closer to embedded files. Would adding a new variant to the |
|
@sirchnik the implementation was changed with some pointers from Laurenz on Discord. The layouting issues should be fixed now. One thing I haven't managed so far, but I still plan to do, is to move the embed methods into a |
|
I would prefer to drop the |
It's only used for the name tree and does not seem to be used by external software. Acrobat doesn't display it and ZUGFeRD doesn't use it either.
|
@NiklasEi I refactored this quite a bit together with @reknih, in part to make things more idiomatic, but also fixing some issues. Since dealing with the PDF specs is always quite involved, directly making the changes was a bit less time-consuming for me than leaving comments and going back and forth over it. I tried to make all commits small and self-contained, so feel free to take a look at the changes and let me know if anything seems odd. I want to make one more pass over the code to check things, but other than that this should be pretty much ready to merge. |
NiklasEi
left a comment
There was a problem hiding this comment.
@laurmaedje Thank you for taking the time!
I like the changes but have a small question.
|
Thanks for your work on this! |
|
Is it possible to use a different filename without renaming the file? From the source code I found out that removing the file date works by E: I see, it is possible by using |
|
The whole file will be read into memory either way. |
|
In typst it seems reading contents fully into RAM is common. But we can think of a solution where it gets chunked in fixed size blocks if I call something like |
|
Yes, it's common because Typst abstracts over the file system in a relatively high-level way. Chunking it all the way from reading to embedding (and compressing!) in the PDF would hugely increase the implementation complexity and there are no plans to do that. |
|
I understand the design decision. Btw: is compression optional? Many file formats are already compressed, additional compression can result in higher filesize and longer compilation time. |
|
Currently, it will always compress. |
|
Ultimately did this version for 0.13 of PDF embed enable using the same name as the pdf for the attachment.typ? Important Document.pdf |
|
@mrfragger There is currently no way to get the input file name so you need to either spell it out in your source file or provide it via |
|
quite impressed one_qpdf_embed_typ.pdf 10MB Seems like compression efficiency improved a tad for final typst 0.13 compared to pre-release. so attachment size is 1.4MB for qpdf and 1.5MB for typst native pdf.embed. No longer need qpdf as a dependency for embedded source typst files in pdf. Thanks for the hard work put into this. |
Co-authored-by: Laurenz <[email protected]>
Resolves #4411
Part of #2499
This PR implements file embeddings associated with the document as a whole. The attachments do not have visible annotations. It also adds an option for PDF/A-3 to allow arbitrary file embeddings with PDF/A compliance. I will gladly move this to a second PR if preferred.
The embeddings are part of a new
pdfmodule: