This tool converts multiple JPEG images into a single PDF file using Go. You can provide images by specifying a folder or a comma-separated list of filenames.
- Converts JPEG images to a PDF document
- Supports specifying either a folder containing images or a comma-separated list of files
- Automatically sorts images alphabetically to maintain order in the final PDF
- Customizable output PDF filename
- Go 1.16+ installed on your machine
- JPEG images to be converted
Clone the repository, navigate to the project directory, and build the program:
git clone https://github.com/anoopsimon/image-to-pdf-go.git
cd pdf-tool
go mod tidy
go build -o jpeg-to-pdf
Run the program using command-line flags:
jpeg-pdf-tool -folder=<folder_path> -output=<output_pdf_filename>
or
jpeg-pdf-tool -files=<file1.jpg,file2.jpg,...> -output=<output_pdf_filename>
Flag | Description |
---|---|
-folder |
Path to the folder containing JPEG files (optional if -files is used). |
-files |
Comma-separated list of JPEG filenames (optional if -folder is used). |
-output |
Name of the output PDF file (default: images_output.pdf ). |
Note: Either -folder
or -files
must be provided. If both are provided, the -folder
option will be used.
-
Convert all JPEG images in a folder to a PDF
jpeg-pdf-tool -folder=imgs -output=output.pdf
-
Convert specified JPEG files to a PDF
jpeg-pdf-tool -files="imgs/image1.jpg,imgs/image2.jpg" -output=output.pdf
-
Convert with default output filename
jpeg-pdf-tool -folder=imgs
If any issues occur, such as missing files or unsupported image formats, an error message will display in the terminal.