J-F-Liu / lopdf

A Rust library for PDF document manipulation.
MIT License
1.67k stars 176 forks source link

pdfutil: Add ability to merge pdfs #340

Closed einoj closed 1 month ago

einoj commented 1 month ago

The --merge flag takes an arbritary list of pdfs and merges them into one.

Example: pdfutil --merge A.pdf B.pdf --output C.pdf

Optionally it can be run without the --output flag, then it will save to merged.pdf.

If only 1 is given it will just create a copy of the original pdf.

The merge code is taken from examples/merge.rs. I use the layer variable to avoid the borrow checker from complaining when using .iter().enumerate().