-
Notifications
You must be signed in to change notification settings - Fork 38
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
Save document only once on set-fields #64
Save document only once on set-fields #64
Conversation
dbb119b
to
5930ee9
Compare
@@ -0,0 +1,47 @@ | |||
name: Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding this to run tests automatically using Github actions. seems useful, but I can remove it if you rather not add it. this will apply for next PRs after this one is merged.
(set-fields "test/pdfs/interactiveform.pdf" out {"first_name" "My first name" | ||
"last_name" "Last Name"}) | ||
(is (= (seq (Files/readAllBytes (.toPath (io/file "test/pdfs/test.pdf")))) | ||
(seq (.toByteArray out)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using set-fields
with either a file or a byte-array produces the same result
Thanks for the contribution @lucasdf! I like it. I'll merge it soon. Thanks again. |
@dotemacs any news on this? Do we need to do something else to get this merged? Also, it came to my attention that are still several open pull requests for a while, do you need any help evaluating them? :) |
Hey @lucasdf Thank you for doing this change. Also, thank you for the patience in waiting for me to merge it /cc @rafaeldelboni |
Description of your pull request
Change
set-fields
logic to save the document only once after all fields have been renamed. The current behavior calls.save
after filling each field.Why should it be considered?
The main motivation for this is to support using the function
set-fields
with aByteArrayOutputStream
.The current logic calls
.save
after renaming each field, which appends the whole content of the PDF to the output stream, producing a bloated and potentially invalid PDF.This is not a problem when passing a file since it just overwrites the file content each time, which works but seems inefficient.
Why am I asking this?
In order to support using this function to save the result to a ByteArray.
Pull request checklist
clj-kondo --lint src
).Thanks for maintaining this lib!