A simple package to merge PDF (Portable Document Format) files on Linux, OS X and Windows. The following functions are exported:
merge_pdfs
append_pdf!
split_pdf
merge_pdfs(["file_1.pdf", "file_1.pdf", "file_2.pdf"], "merged.pdf")
Note, the same files can be merged multiple times.
Use the cleanup
option to delete the single files after merging:
merge_pdfs(["file_1.pdf", "file_1.pdf", "file_2.pdf"], "merged.pdf", cleanup=true)
Appending with append_pdf!
is particularly useful to create a single PDF
that contains multiple plots on separate pages:
using Plots
for i in 1:5
p = plot(rand(33), title="$i");
savefig(p, "temp.pdf")
append_pdf!("allplots.pdf", "temp.pdf", cleanup=true)
end
All five plots are contained in allplots.pdf
and the temporary file is deleted.
A PDF containing multiple pages can be split in single pages:
split_pdf("book.pdf")
If the argument cleanup = true
is given, the original document will
be deleted.
All the heavy lifting is done by
Poppler
. Thanks to the maintainers
of Poppler
and Poppler_jll.jl
!
Thanks to @zauster for implementing separate temp files for each worker.