=== TextToPdfNet – Text & Web to PDF Converter ===
Contributors: texttopdfnet
Tags: pdf, converter, text to pdf, post to pdf, export pdf
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Convert text PDF and single website content into clean PDF files effortlessly.

== Description ==

TextToPdfNet is a lightweight, secure plugin that lets your visitors generate clean PDF documents from raw text or directly from your website posts and pages. 

### Features:
1. **Frontend Text-to-PDF Converter**: Add a simple form anywhere on your site using the `[text_to_pdf_form]` shortcode. Users can paste text and instantly download it as a PDF.
2. **Post/Page-to-PDF Converter**: Automatically append a "Download PDF" button to your posts or pages, or place it using the `[text_to_pdf_button]` shortcode. The generated PDF ensures a clean reading experience, excluding theme sidebars, comment sections, and popups.
3. **Download Counts**: View how many times a post was downloaded directly from the WordPress admin list.
4. **Fully Customizable**: Configure page sizes (A4, Letter), custom headers/footers, margin sizes, and toggle whether to include the featured image, metadata, or post title in the PDF.

### Security First
This plugin prioritizes security. It relies entirely on a localized copy of Dompdf without calling any external SaaS APIs or transferring data off-site. It adheres to WordPress.org's rigorous security guidelines, features strict escaping, sanitization, and verification mechanisms.

== Installation ==

1. Upload the `texttopdfnet-text-web-to-pdf` folder to the `/wp-content/plugins/` directory, or install the ZIP directly via **Plugins > Add New > Upload Plugin** in your WordPress admin.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Navigate to **Settings > Text to PDF** to configure your preferences.

== Usage Guide ==

This plugin provides two shortcodes and an automatic button feature. Here is how to use each one:

= Shortcode: Text-to-PDF Form =

Use the shortcode below to add a text input form on any page or post. Visitors can type or paste any text, give it a title, and download it instantly as a PDF.

`[text_to_pdf_form]`

**How to add it:**

1. Edit any page or post in WordPress.
2. Add a **Shortcode** block (or paste directly into the Classic Editor).
3. Type `[text_to_pdf_form]` and publish/update the page.
4. Visitors will see a form with a title field, a text area, and a "Generate PDF" button.

= Shortcode: Download Button for Current Post =

Use this shortcode to manually place a "Download as PDF" button anywhere inside a post or page. When clicked, the current post/page content is converted to a clean PDF.

`[text_to_pdf_button]`

**How to add it:**

1. Edit the post or page where you want the button.
2. Add a **Shortcode** block.
3. Type `[text_to_pdf_button]` and publish/update.

= Automatic Download Button =

You can also have the plugin automatically add a "Download as PDF" button to all posts and/or pages without using a shortcode. Configure this in **Settings > Text to PDF**:

1. Go to **Settings > Text to PDF**.
2. Check **Enable on Posts** and/or **Enable on Pages**.
3. Choose the **Button Position**: Top of Content, Bottom of Content, Both, or Shortcode Only.
4. Customize the **Button Label** text (default: "Download as PDF").

== Settings Guide ==

Navigate to **Settings > Text to PDF** in your WordPress admin to configure the following:

= Display Options =
* **Enable on Posts** – Automatically show the download button on all posts.
* **Enable on Pages** – Automatically show the download button on all pages.
* **Button Label** – Customize the text shown on the button (e.g., "Download as PDF", "Save PDF", "Export").
* **Button Position** – Choose where the button appears: Top, Bottom, Both Top and Bottom, or Shortcode Only.

= PDF Content Options =
* **Content to Include** – Toggle which elements appear in the generated PDF: Post Title, Featured Image, Author Name, Publish Date.
* **File Name Pattern** – Customize the downloaded file name using `{title}` and `{date}` placeholders. Example: `{title}-{date}` produces `my-blog-post-2026-04-10.pdf`.
* **Global Header Text** – Add custom text to the top of every generated PDF.
* **Global Footer Text** – Add custom text to the bottom of every generated PDF.

= PDF Layout Options =
* **Document Page Size** – Choose between A4 or Letter size.
* **Font Size** – Select Small, Medium, or Large.
* **Margin Preset** – Choose Narrow, Normal, or Wide margins.

= Watermark / Branding Options =
* **Watermark Site Name** – Enter your site name to display as a text watermark on every PDF page.
* **Watermark Logo URL** – Upload or select a logo image from the WordPress Media Library by clicking "Upload / Select Image".
* **Watermark Logo Size (px)** – Set the width of the logo in pixels (default: 500).
* **Watermark Opacity (%)** – Control the transparency of the watermark from 1% (barely visible) to 100% (fully opaque). Default is 30%.
* **Watermark Position** – Choose where the watermark appears: Top Left Corner, Top Right Corner, Center, Bottom Left Corner, or Bottom Right Corner.

== Frequently Asked Questions ==

= How do I add a Text-to-PDF form to my site? =
Add the shortcode `[text_to_pdf_form]` to any page or post. A form will appear where visitors can type text and download it as a PDF.

= How do I add a download button to a specific post? =
Add the shortcode `[text_to_pdf_button]` inside that post or page. Alternatively, enable the automatic button in **Settings > Text to PDF** and it will appear on all posts/pages.

= Does it send data to an external API? =
No. The plugin generates PDFs entirely on your server using the Dompdf library. No data is sent externally.

= Can I add my site logo to the PDF? =
Yes. Go to **Settings > Text to PDF**, scroll to the Watermark section, and upload your logo. You can configure the size, position, and transparency.

= Can I use it on custom post types? =
Currently it officially supports standard Posts and Pages. The `[text_to_pdf_button]` shortcode may also work on other singular content types.

= How do I track PDF downloads? =
The plugin automatically tracks download counts per post. You can view them in the **PDF Downloads** column on the Posts and Pages admin list screens.

== Screenshots ==

1. The frontend Text to PDF converter form.
2. The Download PDF button appended to a post.
3. Admin settings page configuring PDF outputs.

== Changelog ==

= 1.0.0 =
* Initial release.
* Frontend text-to-PDF converter form via shortcode.
* Post/page content to PDF download button.
* Admin settings for PDF layout, content, headers, footers.
* Watermark support with configurable logo, text, position, size, and opacity.
* Per-post download tracking with admin column display.
