=== PDF Snapshot ===
Contributors: saumya010
Tags: pdf, print, download, export, snapshot
Requires at least: 6.3
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Turn any page or post into a polished, print-ready PDF — one click, with full control over which sections are included.

== Description ==

PDF Snapshot adds a "Download PDF" button to your posts and pages. When a visitor clicks it, the plugin captures the page, converts it to a PDF, and either shows a preview popup (with Print and Download buttons) or downloads it immediately — your choice.

**Key features**

* Two capture modes: the full themed page (with excluded sections removed), or just the title and post content.
* Choose exactly which sections to exclude: header, navigation, footer, sidebars, comments, and any CSS selector you specify (e.g. `.newsletter-signup` or `#related-posts`) to identify additional elements to remove from the PDF.
* Preview popup with Print and Download actions, or immediate download — configurable.
* Available as a shortcode (`[pdf_snapshot]`), a Gutenberg block, and optional automatic injection into all posts and/or pages.
* PDF-native running header (page title) and footer (page numbers), independent of the page's own HTML header/footer.
* Configurable paper size and orientation.
* Automatic image downscaling to keep generation fast.
* Built-in caching: a page's PDF is only regenerated when its content actually changes.
* Access control (public or logged-in users only) and a configurable rate limit to prevent abuse.

= How it works =

Version 1.0 generates PDFs entirely on your own server using the open-source Dompdf library — no external service, no added monthly cost, works on ordinary WordPress hosting. This means very JavaScript-heavy embeds (like some interactive maps or live widgets) may not appear in the PDF exactly as they do on screen; ordinary text, images, and layout convert reliably.

== Installation ==

1. Upload the `pdf-snapshot` folder to `/wp-content/plugins/`, or install it through the Plugins screen directly.
2. If installing from source (not a release zip), run `composer install` inside the plugin directory to fetch the Dompdf library.
3. Activate the plugin through the "Plugins" screen in WordPress.
4. Visit **Settings → PDF Snapshot** to configure capture, delivery, layout, and access settings.
5. Add the `[pdf_snapshot]` shortcode to a page, insert the "PDF Snapshot Button" block, or enable automatic injection in the settings.

== Frequently Asked Questions ==

= Does this work on shared hosting? =

Yes. Version 1.0 uses a pure-PHP PDF library (Dompdf) with no external dependencies beyond what Composer installs — no Node.js, no headless browser, no server configuration needed.

= Will embedded videos, maps, or interactive widgets show up in the PDF? =

Not reliably. The PDF engine does not execute JavaScript, so content that depends on it (some embeds, live widgets) may appear blank or be omitted. Ordinary content — text, images, tables, links — converts well.

= Can I control what's included in the PDF? =

Yes. Settings → PDF Snapshot lets you exclude the header, navigation, footer, sidebars, and comments, plus specify additional CSS selectors (e.g. `.newsletter-signup`) to identify any other elements that should be removed from the generated PDF. These selectors only pick which elements to strip — no CSS, JavaScript, or PHP code is ever saved or executed.

= Where are generated PDFs stored? =

In `wp-content/uploads/pdf-snapshot-cache/`, if caching is enabled. Cached PDFs are automatically cleared when the source post is updated.

== Third-Party Libraries ==

PDF Snapshot bundles [Dompdf](https://github.com/dompdf/dompdf) (LGPL-2.1) to generate PDFs entirely on your own server, along with its own dependencies (php-svg-lib, php-font-lib, php-css-parser, masterminds/html5, thecodingmachine/safe — all LGPL/MIT licensed). No external service or API call is used for PDF generation.

== Screenshots ==

1. Settings screen — Capture and section-exclusion options.
2. Settings screen — Delivery and layout options.
3. Front-end preview popup with Print/Download actions.

== Changelog ==

= 1.0.1 =
* Moved the settings screen's button-style toggle and color-picker initialization out of an inline `<script>` block into a properly registered/enqueued admin script, per WordPress.org plugin guidelines.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
