Closed Akeboshiwind closed 1 year ago
I have a couple of input-streams containing PDFs that I want to merge into an output-stream.
input-streams
output-stream
The current merge-pdfs function requires that all inputs are files, but PDFBox supports adding InputStreams.
merge-pdfs
InputStreams
Same with the output, merge-pdfs requires that the output is a filename, but PDFBox supports both filenames and OutputStreams.
OutputStreams
To solve this in my codebase I've updated merge-pdfs to be less strict:
(defn merge-pdfs [& {:keys [input output]}] (let [merger (PDFMergerUtility.)] (doseq [source input] (.addSource merger source)) (cond (instance? java.io.OutputStream output) (.setDestinationStream merger output) :else (.setDestinationFileName merger output)) (.mergeDocuments merger)))
But I wanted your feedback before submitting a PR. Is this something you'd be interested in?
Hey @Akeboshiwind
If you can get this to work and also ensure that there are no broken tests, I'd be happy to merge this in.
Thank you
Expected Behavior
I have a couple of
input-streams
containing PDFs that I want to merge into anoutput-stream
.The current
merge-pdfs
function requires that all inputs are files, but PDFBox supports addingInputStreams
.Same with the output,
merge-pdfs
requires that the output is a filename, but PDFBox supports both filenames andOutputStreams
.Potential Solution
To solve this in my codebase I've updated
merge-pdfs
to be less strict:But I wanted your feedback before submitting a PR. Is this something you'd be interested in?