# PDF Gallery Viewer

**Contributors:** panezio923  
**Tags:** pdf, gallery, responsive, modal, javascript
**Requires at least:** 6.6  
**Tested up to:** 6.7  
**Stable tag:** 1.2.0  
**Requires PHP:** 7.0  
**License:** GPLv2 or later  
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html  

A simple plugin that creates a responsive PDF gallery with live thumbnail previews and modal PDF viewer.

## Description

PDF Gallery Viewer is a WordPress plugin that allows you to create a beautiful and responsive PDF gallery on your website. It generates a live preview of the **first page of each PDF** directly in the browser using **PDF.js**, without relying on server-side libraries like Imagick. Each document includes a customizable title and a "View" link that opens the full PDF in a **modal lightbox viewer**.

The gallery layout is fully responsive, adapting from a grid view on larger screens to a single-column layout on mobile devices. Perfect for showcasing catalogs, portfolios, reports, and other downloadable documents in a clean and professional layout.

### Gutenberg Block Support

PDF Gallery Viewer includes a native Gutenberg block to easily add multiple PDFs to a single gallery without writing shortcodes.

**Block Features:**
- Add multiple PDFs in one block
- Inline title editing
- Drag-and-drop Media Library integration for PDF selection
- Clean, minimal interface with remove buttons
- Automatically generates the corresponding shortcodes:
  `[pdf_gallery_container]...[/pdf_gallery_container]`

This makes it even easier to manage galleries visually within the WordPress editor.

### Features

- ✅ Thumbnail preview of the first page of each PDF using JavaScript (no server dependencies).
- ✅ Fully responsive layout using Flexbox and CSS Grid.
- ✅ Clean and modern modal viewer with:
  - Navigation between PDF pages
  - Zoom in/out
  - Download button
  - Automatic memory of last page and zoom per PDF (per session)
- ✅ Simple shortcode system for inserting PDF galleries anywhere.
- ✅ Lightweight and easy to use.

### Usage

To add a PDF to your gallery:

```
[pdf_gallery url="PDF_URL" title="Document Title"]
```

Wrap multiple shortcodes inside a container (optional):

```
[pdf_gallery_container]
[pdf_gallery url="..." title="..."]
[pdf_gallery url="..." title="..."]
[/pdf_gallery_container]
```

Clicking "View" opens the PDF in a **modal viewer** with page navigation, zoom and download features.

### Requirements

- WordPress 6.6 or later
- JavaScript must be enabled
- PDFs must be publicly accessible

## Installation

1. Upload the plugin folder to `/wp-content/plugins/pdf-gallery-viewer/`
2. Activate the plugin via the WordPress admin panel
3. Use the `[pdf_gallery]` shortcode in posts or pages

## Frequently Asked Questions

### Does this plugin require Imagick?

No. All previews are generated directly in the browser using PDF.js.

### Will this work on mobile?

Yes, the gallery and modal viewer are fully responsive.

### Can I display multiple PDFs?

Yes! Use multiple `[pdf_gallery]` shortcodes inside a container.

## Screenshots

1. Responsive gallery grid on desktop
2. PDF modal viewer with controls
3. Zoom and download options in action

## Changelog

### v1.2.0
* Removed Imagick dependency
* Added real-time PDF thumbnail previews using PDF.js
* Introduced modal PDF viewer with:
  - Navigation between pages
  - Zoom in/out
  - Download PDF
  - Session-based memory for last page/zoom
* Added Gutenberg block:
  - Add/edit/remove multiple PDFs in a visual interface
  - Generates shortcodes automatically
  - Live preview and cleaner editing UI

### v1.0.0
* Initial release with responsive gallery layout and static thumbnail support

## Upgrade Notice

### 1.2.0
Major upgrade: thumbnails now rendered client-side using PDF.js. Modal viewer added with full controls. Imagick no longer required. Added Gutenberg block.
