How to use the command pdfjoin (with examples)

How to use the command pdfjoin (with examples)

PDFjoin is a PDF merging utility based on pdfjam. It allows users to merge multiple PDF files into one, rearrange pages, and save the output to a new file. The command provides a lot of flexibility for combining and manipulating PDF documents.

Use case 1: Merge two PDFs into one with the default suffix “joined”

Code:

pdfjoin path/to/file1.pdf path/to/file2.pdf

Motivation: This example is useful when you need to combine multiple PDF files into a single document.

Explanation: The path/to/file1.pdf and path/to/file2.pdf arguments represent the paths to the PDF files you want to merge. The command will merge these files together and create a new PDF with the default suffix “joined”.

Example Output: A new PDF file named output-joined.pdf will be created in the current directory, containing the combined contents of file1.pdf and file2.pdf.

Use case 2: Merge the first page of each given file together

Code:

pdfjoin path/to/file1.pdf path/to/file2.pdf ... 1 --outfile output_file

Motivation: This example is useful when you want to extract specific pages from multiple PDF files and merge them into a new document.

Explanation: The 1 argument indicates that only the first page of each file should be merged together. The --outfile flag is used to specify the name of the output file.

Example Output: A new PDF file named output_file will be created in the current directory, containing the first page from each specified PDF file.

Use case 3: Save pages 3 to 5 followed by page 1 to a new PDF with custom suffix

Code:

pdfjoin path/to/file.pdf 3-5,1 --suffix rearranged

Motivation: This example is useful when you need to rearrange the pages of a single PDF document and save them as a new file.

Explanation: The 3-5,1 argument specifies the page ranges to be included in the output file. In this case, it includes pages 3 to 5 followed by page 1. The --suffix flag is used to specify a custom suffix for the output file.

Example Output: A new PDF file named file-rearranged.pdf will be created in the current directory, containing pages 3 to 5 followed by page 1 from the original PDF.

Use case 4: Merge page subranges from two PDFs

Code:

pdfjoin /path/to/file1.pdf 2- /path/to/file2.pdf last-3 --outfile output_file

Motivation: This example is useful when you need to extract specific page ranges from two different PDF files and combine them into a new document.

Explanation: The /path/to/file1.pdf and /path/to/file2.pdf arguments represent the paths to the PDF files you want to merge. The 2- argument specifies that all pages starting from page 2 of file1.pdf should be included. The last-3 argument specifies that the last 3 pages of file2.pdf should be included. The --outfile flag is used to specify the name of the output file.

Example Output: A new PDF file named output_file will be created in the current directory, containing all pages starting from page 2 of file1.pdf followed by the last 3 pages of file2.pdf.

Related Posts

How to use the command 'linkchecker' (with examples)

How to use the command 'linkchecker' (with examples)

Linkchecker is a command-line client that allows you to check HTML documents and websites for broken links.

Read More
How to use the command 'mamba' (with examples)

How to use the command 'mamba' (with examples)

The ‘mamba’ command is a fast, cross-platform package manager that is designed to be a drop-in replacement for conda.

Read More
How to Use the Command "monodis" (with examples)

How to Use the Command "monodis" (with examples)

The “monodis” command is a Mono Common Intermediate Language (CIL) disassembler.

Read More