Skip to content

feat: add multi-image to single PDF converter#411

Open
Suhaskumard wants to merge 2 commits into
Durgeshwar-AI:mainfrom
Suhaskumard:feature/multi-image-to-pdf-converter
Open

feat: add multi-image to single PDF converter#411
Suhaskumard wants to merge 2 commits into
Durgeshwar-AI:mainfrom
Suhaskumard:feature/multi-image-to-pdf-converter

Conversation

@Suhaskumard

Copy link
Copy Markdown
Contributor

Description

This PR implements the enhancements proposed in Issue #317 for the Multi-Image to Single PDF Converter tool.

The update focuses on improving PDF generation efficiency, reducing output file sizes, and providing users with greater control over document formatting. New capabilities include native image embedding, configurable page sizes and margins, image rotation controls, and memory usage optimizations, all while preserving the tool's fully client-side architecture.

Closes #317

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring

Checklist

  • Code follows project style guidelines
  • Tested locally
  • Updated documentation

Demo Video

Recording.2026-06-22.211140111.1.1.mp4

Changes Made

Native PDF Size Optimization

Implemented native image embedding to preserve original image compression and minimize PDF size inflation.

Enhancements include:

  • Direct JPEG embedding using pdfDoc.embedJpg()

  • Direct PNG embedding using pdfDoc.embedPng()

  • Format-specific handling to avoid unnecessary re-encoding

  • Automatic fallback conversion for unsupported formats:

    • WebP
    • GIF
    • BMP
  • High-quality JPEG conversion for unsupported formats

  • Automatic white background handling for transparent images converted to JPEG

Standard Page Sizes & Margin Controls

Added configurable document layout settings.

Supported page formats:

  • Original Image Size
  • A4
  • Letter

Supported margin presets:

  • None
  • Small
  • Medium
  • Large

Features include:

  • Automatic proportional image scaling
  • Centered image positioning
  • Consistent document formatting
  • Preservation of aspect ratio without stretching

Quick Image Rotation

Added image rotation controls directly within the upload workflow.

Capabilities include:

  • 90° clockwise rotation per click
  • Instant visual preview updates
  • Rotation angle indicators
  • Correct rotation application during PDF generation
  • Support for multiple sequential rotations

Memory Management Improvements

Optimized image processing to better support large image batches.

Enhancements include:

  • Immediate bitmap cleanup after processing
  • Reduced browser memory consumption
  • Prevention of GPU memory leaks
  • Improved stability during large batch conversions

Files Added

Frontend

  • No new files added.
  • All functionality implemented within existing components to minimize project footprint.

Documentation

  • Updated README.md

Files Updated

Frontend

  • frontend/src/pages/ImagePdf.jsx

Documentation

  • README.md

User Experience Improvements

Smaller PDF File Sizes

The generated PDF now more closely reflects the original size of uploaded images.

Benefits include:

  • Reduced storage usage
  • Faster downloads
  • Improved sharing efficiency
  • Better preservation of original image compression

Professional Document Formatting

Users can now generate standardized PDF documents regardless of image dimensions.

This provides:

  • Consistent A4 and Letter layouts
  • Proper image centering
  • Uniform page presentation
  • Improved print readiness

Faster Editing Workflow

Users can correct image orientation directly within the converter.

This eliminates:

  • External image editing steps
  • Additional upload cycles
  • Manual preprocessing before conversion

Improved Performance

Large image batches can be processed more reliably with reduced memory overhead and improved browser stability.


Testing

PDF Optimization Validation

Verified:

  • JPEG images preserve original compression.
  • PNG images are embedded natively.
  • Unsupported formats correctly trigger conversion workflows.
  • Transparent images are handled appropriately.
  • Generated PDFs avoid unnecessary size inflation.

Layout & Formatting Validation

Verified:

  • Images scale proportionally within A4 pages.
  • Images scale proportionally within Letter pages.
  • Margin presets apply correctly.
  • Images remain centered within printable areas.
  • Original mode preserves image dimensions.

Rotation Validation

Verified:

  • Rotation previews update immediately.
  • Rotation indicators display correctly.
  • Generated PDFs match previewed rotations.
  • Multiple consecutive rotations produce correct output.

Memory & Performance Validation

Verified:

  • Large image batches process successfully.
  • Bitmap resources are released correctly.
  • Browser memory usage remains stable.
  • No noticeable degradation during extended processing.

Edge Case Testing

Tested:

  • Extremely wide images.
  • Extremely tall images.
  • Images smaller than selected page dimensions.
  • Mixed image formats.
  • Mixed portrait and landscape batches.
  • Large batches containing 10+ images.

Documentation Validation

Updated documentation includes:

  • New PDF generation capabilities.
  • Page size configuration options.
  • Margin settings.
  • Rotation workflow.
  • File size optimization details.

Acceptance Criteria

  • Users can upload multiple images.
  • Images can be reordered before generation.
  • Standard page sizes (A4 and Letter) are supported.
  • Configurable page margins are available.
  • Individual images can be rotated.
  • JPEG and PNG compression is preserved when possible.
  • Large batches are processed efficiently.
  • All selected images are merged into a single PDF document.

Technical Notes

  • The implementation remains entirely client-side and does not require backend services.
  • Native image embedding is used whenever supported by pdf-lib to preserve compression and reduce output file size.
  • Canvas-based processing is only used when required for unsupported formats or user-requested image rotations.
  • Memory cleanup mechanisms ensure efficient processing of large image batches.
  • The implementation remains fully backward compatible, preserving existing behavior for users who do not use the new configuration options.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@Suhaskumard is attempting to deploy a commit to the Durgeshwar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Suhaskumard

Copy link
Copy Markdown
Contributor Author

Hi @Durgeshwar-AI,
I have solved the issue. If there are any changes, kindly let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Multi-Image to Single PDF Converter

1 participant