• Stars
    star
    61
  • Rank 497,051 (Top 10 %)
  • Language
    Go
  • License
    GNU Affero Genera...
  • Created almost 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Merge Image and PDF files (optionally with selective pages) with lossless quality

merge2pdf - Merge Image and PDF files into PDF

Simplest command line tool for merging Images and PDFs. It will not convert PDF pages (with texts, images, forms) into flat image, everything will remain as is.

merge2pdf - simplest tool for merging image and PDF files

Highlights -

  • Very simple and easy to use
  • Lossless quality by default. Option to adjust JPEG quality.
  • Can be merged only selective pages of PDF
  • Supports wide range of image formats
  • Options to adjust size, margin and scaling of image
  • Supports directory as input (merges all Images/PDFs of directory)
  • Free and open source

Install

It's just a single binary file, no external dependencies. Just download the appropriate version of executable from latest release for your OS. Then rename and give it execute permission.

mv merge2pdf_linux-amd64 merge2pdf  
sudo chmod +x merge2pdf

If you want to install it globally (run from any directory of your system), put it in your systems $PATH directory.

sudo mv merge2pdf /usr/local/bin/merge2pdf

Done!

How to use

# Merge multiple PDFs
merge2pdf output.pdf input1.pdf input2.pdf path/to/other.pdf ...

# Merge 1st page of input1.pdf, full input2.pdf and 2nd, 3rd, 4th page of input3.pdf  
merge2pdf output.pdf input1.pdf~1 input2.pdf input3.pdf~2,3,4

# Merge multiple Images
merge2pdf output.pdf image1.jpg image2.jpg path/to/other.png ...

# Merge all Images/PDFs of one or multiple directory
merge2pdf output.pdf path/to/a/dir path/to/another ...

# Mixing up PDF, PDF Pages, Images and directories
merge2pdf output.pdf doc1.pdf~1,2 image1.jpg path/to/dir path/to/other.pdf ...

Fine tuning Image pages

When adding Images, by default the size for image containing pages will be same to image size with 1 inch margin on each side. But you may set custom margins and resize to standard Print size.

# Set image page size to A4. Other Options are A3, Legal and Letter
merge2pdf -s A4 output.pdf image1.jpg image2.jpg

# Set image page size and margin (left, right, top, bottom).
merge2pdf -s A3 -m .5,.5,1,1 output.pdf image1.jpg image2.jpg
# margin can be set without size

# Scale images to page width, with aspect ratio
# To scale to height, use --scale-height
merge2pdf -s A3 -m .5,.5,1,1 --scale-width output.pdf image1.jpg image2.jpg

# For JPEG, you can set optimized quality
merge2pdf -m 0,0,0,0 --jpeg-quality=80 output.pdf image1.jpg image2.jpg

Note: When adding images and PDFs together, these options will effect ONLY Image pages.

If your filename contains space or some special characters, then quote the filepaths along with page numbers. For safety, you can quote them always.

merge2pdf output.pdf "With Space.pdf" "without-space.pdf" "with space and pages.pdf~2,3,4"

To see details of options,

merge2pdf -h

Notes

  • --size, --margin, --scale-width, --scale-height will only effect images.
  • PDF pages will inherit size and margin of source PDF
  • Some .tiff files (e,g, compression level 4) may not work properly
  • Directory inputs will be searched for image/PDF files on first level only. Subdirectories will be skipped.

Roadmap

✅ Merge multiple PDFs without loosing quality
✅ Merge multiple PDFs with selective pages
✅ Adding Images
✅ Mixing up Images and PDFs
✅️ Merge all (Image and PDF) files from directory
✅ Option to Resize Images to reduce filesize
◻️ Option to Greyscale Images to reduce filesize
◻️ Option to set files and pages as JSON config to make usages from other app more convenient

Contribute

If you fix a bug or want to add/improve a feature, and it's alligned with the focus (merging with ease) of this tool, I will be glad to accept your PR. :)

Thanks

This tool was made using the beautiful Unidoc library. Thanks and ❤️ to Unidoc.


"This is the Book about which there is no doubt, a guidance for those conscious of Allah" - Al-Quran

More Repositories

1

geek-life

The Todo List / Task Manager for Geeks in command line
Go
447
star
2

markpdf

Watermark PDF files using image or text
Go
140
star
3

php-watermark

Add text or image Watermark on image and PDF files
PHP
123
star
4

marionette-boilerplate

Let's start the dance! This boilerplate is a ready setup for starting your next awesome javascript app in minutes. Backbone + Marionette + RequireJS + Twitter Bootstrap
JavaScript
61
star
5

Kohana-Log-Viewer

Shows log files of Kohana PHP Framework with a beautiful interface
PHP
52
star
6

short-code

ShortCode generator for PHP. Create short, reversible or random, hash like codes.
PHP
29
star
7

static-pdo

Simple PHP PDO Wrapper - light, static, easy
PHP
15
star
8

bootstrap-file-field

jQuery plugin to enhance html file input to look like bootstrap button, showing image thumb and apply useful restrictions (e.g. file types, size, number of files etc.)
HTML
12
star
9

shared-checklist

Shared Checklist - Firebase Realtime Database example
HTML
6
star
10

GulpBusterBundle

Symfony Bundle to integrate gulp-buster gulp plugin. It's a cache busting utility for gulp based asset management.
PHP
5
star
11

docker-compose-laravel

Ready made development environment for Laravel 6.x using docker-compose
Dockerfile
5
star
12

jruby-swing

A small JRuby desktop app that converts a number from decimal/hex/binary/octal to decimal/hex/binary/octal formats. It's just an example of how to make Desktop application with JRuby and Swing
Ruby
4
star
13

Kohana-Twitter-Bootstrap-boilarplate

Start a Kohana project with integrated Twitter Bootstrap in minutes.
PHP
3
star
14

sf28_lte2

Symfony 2.8 with Admin LTE 2 - A boilerplate to start new project instantly with pre-built common features!
PHP
3
star
15

four-in-a-row

A Basic Four-In-A-Row Game
Go
2
star
16

magic

Magic - PSR 11 compliant tiny Dependency Injection Container
PHP
2
star
17

session-timer

A Chrome Extension to rescue your time by notifying at a configured time limit while browsing time killing sites.
JavaScript
1
star
18

slim-magic

A tiny, sample blog with Slim Framework using magic Dependency Injection Container.
PHP
1
star
19

ajaxray.marionette-boilerplate.io

This boilerplate is a ready setup for starting your next awesome javascript app in minutes.
JavaScript
1
star
20

phonegap

1
star
21

docker-slate

A slim, docker-only setup for Slate API Docs generator based on pre-built docker images
SCSS
1
star
22

PHP-Universal-Feed-Generator

PHP Universal Feed Generator (supports RSS 1.0, RSS 2.0 and ATOM)
1
star