Saral PDF Preview for WooCommerce

Plugin Banner

Saral PDF Preview for WooCommerce

by Akaal Creatives

Download
Description

Saral PDF Preview lets you attach a PDF file to any WooCommerce product. A configurable button appears on the product page and opens the PDF in a clean, distraction-free lightbox — no download, no print, just a smooth in-browser reading experience powered by PDF.js.

Features

  • Upload a PDF per product via a dedicated meta box in the product editor.
  • Configurable button text (default: “Preview Book”).
  • Choose from 7 hook locations on the product page — a live visual diagram shows exactly where the button will appear.
  • Protected mode (default): the real PDF URL is never exposed to visitors; the file is streamed through a signed REST endpoint.
  • Public mode: uses the standard WordPress attachment URL.
  • Zoom in / zoom out controls inside the lightbox.
  • Keyboard accessible — press Escape to close.
  • Responsive layout on mobile.
  • No tracking, no external requests, no upsells.
  1. Upload the saral-pdf-preview-for-woocommerce folder to /wp-content/plugins/.
  2. Activate the plugin through the Plugins menu in WordPress.
  3. Go to WooCommerce PDF Preview to configure the button text, position, and serving mode.
  4. Edit any product, find the PDF Preview meta box, and upload a PDF.
  1. Admin settings page — configure button text, hook position, and file serving mode.

    Admin settings page — configure button text, hook position, and file serving mode.

  2. The "Preview Book" button on a WooCommerce product page.

    The "Preview Book" button on a WooCommerce product page.

  3. The PDF lightbox open on a product page — zoom controls, keyboard accessible, no download option.

    The PDF lightbox open on a product page — zoom controls, keyboard accessible, no download option.

Does this work with any WooCommerce theme?

Yes. The button is injected via standard WooCommerce action hooks so it works with any theme that respects the WooCommerce template hierarchy.

Can customers download the PDF?

No. The lightbox intentionally has no download or print controls. In Protected mode the real file URL is never sent to the browser, so determined users cannot easily retrieve it either.

Is a login required to view the preview?

No. All visitors (logged-in or not) can open the lightbox.

How large can the PDF be?

There is no hard limit imposed by this plugin. Your server’s max_execution_time and memory_limit settings apply as usual. For very large PDFs, consider splitting them into a shorter sample.

Which PDF.js version is bundled?

PDF.js 5.7.284.

1.2.0

  • Upgraded PDF.js from 3.11.174 to 5.7.284.
  • PDF.js now loads lazily on first lightbox open via dynamic import — reduces initial page weight.
  • Hardened output escaping: button HTML is now passed through wp_kses() with an explicit allowlist; admin meta box attribute conditionals rewritten to eliminate unescaped echo calls.

1.1.0

  • Added data-pdf-preview-trigger attribute as the lightbox trigger — any custom element can now open the lightbox without relying on the plugin’s CSS class.
  • Added saral_pdf_preview_for_woocommerce_trigger_attr() helper function for use in theme templates and custom markup.
  • Added saral_pdf_preview_for_woocommerce_trigger_attr filter to override the trigger attribute string.
  • Settings page now documents the custom trigger element feature with usage examples.

1.0.6

  • Added shortcode [saral_pdf_preview_for_woocommerce] — place the preview button in any custom location on a product page without touching theme files. Accepts an optional id attribute to target a specific product from any page.
  • Added PHP template tag support: echo do_shortcode( ‘[saral_pdf_preview_for_woocommerce]’ ) for use directly in theme templates.
  • Settings page now includes a Manual Embedding section with copy-ready shortcode and PHP snippets.

1.0.5

  • Added “Data on Uninstall” setting — choose whether to keep or remove PDF assignments from products when the plugin is deleted. Defaults to keeping the data so assignments are restored on reinstall.

1.0.4

  • Security: protected endpoint now verifies the product exists and is published before streaming the PDF.
  • Security: Content-Disposition filename is now sanitised before being sent in the response header.
  • Fixed: REST endpoint returns a proper error response instead of calling wp_die().
  • Fixed: loading spinner now hides correctly if a network error occurs during PDF load.
  • Fixed: uploading a non-PDF attachment no longer leaves stale metadata on the product.
  • Fixed: preview button is now guarded against malformed button hook settings.
  • Fixed: PDF attachment MIME type is verified in public serving mode before use.
  • Improved: admin media frame strings (Select PDF, Use this PDF) are now translatable.
  • Improved: modal dialog now uses aria-labelledby for better screen reader support.

1.0.3

  • Added loading spinner shown while PDF is downloading and rendering.

1.0.2

  • Bumped asset version to bust browser cache after identifier rename.

1.0.1

  • Renamed all internal identifiers to match plugin slug.
  • Fixed 403 on protected PDF endpoint for logged-in users.

1.0.0

  • Initial release.
Back to top