How It Works
1.Upload a PDF → Plugin extracts first page as WebP preview via ImageMagick2.Insert embed → Gutenberg block or [pdf_viewer] shortcode3.Page loads → Preview image displays instantly (< 10KB JS)4.User activates → Full PDF.js viewer loads on demand5.Interactive viewing → Navigation, zoom, download, print, fullscreenServer-Side Preview Generation
When a PDF is uploaded to the Media Library:
1.ImageMagick reads the PDF's first page2.Renders it at the configured DPI (72/150/300)3.Converts to optimized WebP format4.Stores alongside the original PDF in the uploads directory5.Extracts page count and dimensions as metadataPreview generation runs automatically on upload. For existing PDFs, use Settings → PDF Viewer → Tools → Process Unprocessed PDFs.
Zero Layout Shift (CLS)
The viewer container uses CSS aspect-ratio calculated from the PDF's actual page dimensions. The browser reserves the exact space before any content renders — no reflow, no jump.
This is measured at the page level: your Lighthouse CLS score is unaffected by PDF embeds.
Three Load Behaviors
Click (Default)
Preview image shown with "View Document" activation button. Full viewer loads only when clicked. Best for:
Multiple PDF embeds on one pagePerformance-sensitive pagesPDFs that most visitors won't openVisible (IntersectionObserver)
Full viewer loads automatically when the embed scrolls into the viewport. Best for:
Single primary PDF on the pageBelow-the-fold embeds that should load before user reaches themImmediate
Full viewer loads on page load. Best for:
Pages where the PDF IS the content (document portals)Single-PDF pages where load time is acceptableGutenberg Block
The native block provides:
PDF selection from Media Library with live previewAll settings in the block sidebar panelWide and full alignment supportMargin spacing controlsAnchor and custom CSS class supportBlock name: maxtdesign/pdf-viewer
Shortcode
[pdf_viewer id="123" width="100%" load="click" toolbar="true"]
Works in classic editor, text widgets, and any page builder that processes shortcodes.
Toolbar
The interactive viewer toolbar includes:
Page navigation — Previous/next page, page number inputZoom — Zoom in/out, fit-to-width, fit-to-pageDownload — Download the original PDF file (toggleable)Print — Print the PDF (toggleable)Fullscreen — Enter fullscreen mode (toggleable)Each button can be toggled globally in settings or per-embed in block/shortcode attributes.
Accessibility
Full keyboard navigation (Tab, Enter, arrow keys, Escape)ARIA labels on all controlsScreen reader announcements for state changesRespects prefers-reduced-motion for animationsProper focus management when entering/exiting fullscreenBulk Processing
Go to Settings → PDF Viewer → Tools to:
Process Unprocessed PDFs — Generate previews for all PDFs in your media library that don't have previews yetClear Cache — Remove cached preview metadataREST API
The plugin registers endpoints under /wp-json/mdpv/v1/:
GET /pdf/{id} — Get PDF info (page count, dimensions, preview URL)POST /pdf/{id}/process — Trigger preview generation for a specific PDFBoth endpoints require upload_files capability.