Validated Clojure SWE-rebench V2 task.
harbor run -t withmartian/dotemacs___pdfboxing-67
harbor download withmartian/dotemacs___pdfboxing-67
Less strict merge-pdfs
merge-pdfs
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.
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?