A Java utility tool for merging images and PDF files into a single PDF document with quality options.
- Document quality (optimized for smaller file size)
- Image quality (optimized for better image quality)
input_folder_path: Path to the folder containing images and/or PDF files to processThe tool will generate output files in the input folder:
output_document.pdf: - If both PDFs and images are found: merged PDFs + images optimized for size
- If only PDFs are found: merged PDFs
- If only images are found: images converted to PDF, optimized for size
output_image.pdf: - Created only when images are processed
- Contains images optimized for quality
Compile the tool with all required libraries in the classpath:
javac -cp lib\*;. ImageAndPDFMerger.java
java -cp .;lib\* ImageAndPDFMerger c:\kentivy\pickup
This will process all PDF and image files in the merge_folder directory and create output PDFs in the same location.
The tool provides two quality settings for image processing:
1. DOCUMENT Quality: (output_document.pdf)
- Images are resized to 50% of original dimensions
- JPEG compression with quality factor of 0.5
- Optimized for smaller file size and document sharing
2. IMAGE Quality: (output_image.pdf)
- Original image dimensions preserved (scaled to fit A4)
- Lossless compression used
- Optimized for image quality and printing
1. The tool scans the input directory for PDF and image files
2. PDF files are merged using PDFBox's PDFMergerUtility
3. Images are processed to fit A4 page dimensions with margins
4. Output files are created in the input directory
The tool will: