VERSION 6 — CLICK-TO-EDIT PDF TEXT
- Default editor tool is now "Click to add / edit text". Click blank space to type in an inline popup; click selectable source text to edit its current value. Set size/color, Apply (Ctrl+Enter) or cancel (Escape).
- Source text in the selected region is removed using MuPDF text redactions before replacement text is written; this is not just a white cover. Images/line art are retained by that operation. Always review the result: overlapping/complex text and font substitution can change layout.
- Scanned/image-only source text requires OCR and cannot be selected for replacement here. You can still add text and annotations to those pages.
- PDF text may be split into chunks; click the relevant chunk. Original font appearance is not guaranteed. Pending source redaction annotations must be resolved before replacement editing.
- Existing added-text editing/moving, drawing, images, Undo and page controls remain available.
- Saving still uses the existing success-only trial and paid-plan checks. All seven tabs remain included under the existing file-count rules. No DB reset, migration, secret/key change or price change is needed.
- English user manual updated. Redeploy this ZIP to the same Pages project.

VERSION 5 — ONLINE PDF EDIT + DOWNLOADABLE ENGLISH MANUAL
- 7th tab: Online PDF Edit. Upload one PDF, add/edit added English/Hindi text, highlight, pen/signature strokes, rectangles, visual cover boxes, PNG/JPG images; select/move/delete items; Undo last 30 edits; reorder/remove pages. Save a new edited PDF.
- Selectable source text can now be replaced through the inline editor. Cover boxes are NOT secure redaction. Original text may remain recoverable. Editing may invalidate digital signatures; keep original files.
- One free SUCCESSFUL editor save per account. Opening/editing, failures and cancelled saves do not consume the trial. After the free success, either paid plan includes the editor.
- BOTH paid plans now include ALL 7 TABS. Rs 199: single-file conversions/editor plus merges of exactly 2 input files. Rs 499: conversion batches and merges up to 20 inputs, editor one PDF at a time. Renewal is still manual, one payment = 30 days.
- The "Download User Manual (PDF)" button is public and downloads DB_Document_Tools_User_Manual.pdf. The 10-page English manual explains all seven tabs, plans, trial counting, login and common messages.
- No database reset or extra SQL is required if run_states is already present. Keep existing DB binding, LIVE Razorpay keys and webhook secret unchanged; redeploy this ZIP to the SAME Pages project.
- New installs: schema.sql. Older installs without run_states: UPDATE_SUCCESS_TRIALS.sql.
- Automated tests verify mixed English/Hindi saved text, image embedding, pen/highlight/rectangle/cover edits, rotation-aware overlay positions, original content, page reorder/removal and output validity. Plan/trial tests cover all tabs and new basic-plan 2-file merges.
- The manual was rendered and visually checked. Interactive browser QA and real payment processing were not exercised during this update. No live accounts/payments were changed.

SIX-TAB RESTORATION UPDATE
Restored from Office_Utility_Portal_SMART_EXCEL_MERGE.zip:
1. 26AS Converter (latest legacy core retained)
2. PDF to Excel (text/table layout, one sheet per page; no OCR)
3. PDF to Image (PNG/JPG, Standard/High/Very High resolution)
4. PDF Merge (original pages, selection order)
5. Smart Excel Merge (all worksheets, real header auto-detection, reordered columns, XLSX/XLS/XML-XLS/CSV/ODS and supported legacy formats)
6. Crack your PDF (the existing limited recovery tool)

All seven tabs share the existing login, success-only free trials, subscriptions and one-active-session rules. Single-file tools allow batch selections on the Rs 499 plan. PDF Merge and Smart Excel Merge allow 2 input files on Rs 199, or up to 20 on Rs 499, after their free successful use. Each single/batch tool mode has its own one-time successful trial.

Dependencies for these tools are bundled locally. No document is uploaded to a CDN or conversion server. Scanned PDF to Excel needs OCR and intentionally fails without charging the trial. Unsupported/corrupt/encrypted inputs can fail; failure/cancel does not consume a trial.

If your database already has run_states from the previous success-trial update, no new SQL is needed. Keep the SAME DB binding, database and payment secrets. Redeploy this ZIP in the SAME Pages project. Do NOT reset/delete tables. For an older database, run UPDATE_SUCCESS_TRIALS.sql first. For a new database, run schema.sql.

Verified with generated fixtures: PDF→Excel rows, PNG rendering, PDF merge page count, multi-format spreadsheet merge/header alignment, image-only and empty file rejection. Automated plan/trial tests include all six tabs. Interactive browser and live payment checks remain outstanding.

UPDATE FOR EXISTING DEPLOYMENTS
Before uploading this version, run UPDATE_SUCCESS_TRIALS.sql in your existing D1 Console. It adds a table only and preserves users, payments, subscriptions and previous trial history. New installations can run schema.sql as normal.

DB DOCUMENT TOOLS — LOGIN, FREE TRIAL & MONTHLY PLANS
===================================================

KYA ADD HUA HAI
- Name/email/password registration and login; password change; logout.
- Every account gets ONE successful processing use for EACH tool/mode, across all seven tabs.
- Failed, cancelled and fully failed batch runs do not consume the free trial. A completed batch consumes one trial if at least one file succeeded and an output was prepared. The trial is committed immediately before offering the download. Trial records are stored in D1. A pending trial reservation prevents two parallel free runs; it is released on failure/cancel, on a new login, or within one hour for an abandoned browser. Previously recorded trial usage is preserved because older versions did not store success/failure outcomes.
- Rs 199 / 30 days: all 7 tabs: single-file conversions/editor; PDF/Excel merge with 2 input files.
- File limits: Excel 20 MB each / 50 MB total; PDF 50 MB each / 100 MB total. Device memory may impose a lower limit.
- Rs 499 / 30 days: all 7 tools, including PDF Merge, Smart Excel Merge and batches, up to 20 files per run. Batch output is a ZIP with a success/failure report.
- A subscribed single-file user can use an unused bulk trial once; later bulk runs require the Rs 499 plan.
- A new login invalidates the old login. Previous browser checks within 15 seconds, and every run is rechecked before a download. Multiple tabs in the SAME browser session are allowed. Previously downloaded documents cannot be revoked.
- One payment = 30 days. No recurring auto-debit is configured. Same-plan renewals extend expiry; an upgrade starts its own multi-file period immediately. No pro-rated refund. Buying single-file while multi-file is active is blocked.
- Razorpay checkout integration with SERVER signature check, captured-payment amount/currency/order checks, webhook support and duplicate-payment protection.
- Payment history and Check payment button for interrupted checkout/capture delays.
- Files remain on the user's device. Only accounts, sessions, trial usage, run metadata and payment metadata are stored.
- Strong/unknown PDF passwords are NOT guaranteed to recover; payment does not change that limitation.

IMPORTANT COMMERCIAL LIMIT
Access to THIS hosted app is gated by server login, trial records and payment records. The actual converters run in the browser and their open-source code can be copied or modified by a technically skilled user. This is not tamper-proof DRM and does not guarantee that a physical person cannot create more accounts. Accounts currently use email/password registration without email verification. For strong anti-copy enforcement, a future version needs server-side file processing and associated privacy, compute and cost changes. The PDF engine/app are AGPL; preserve notices and source availability.

CLOUDFLARE PAGES — DASHBOARD SE SETUP
1. Extract the downloaded ZIP. index.html, _worker.js, _routes.json, app.js, vendor folder etc. should be visible.
2. Cloudflare > Storage & Databases > D1 > Create database.
   Name: db-document-tools (or your own).
3. Open that D1 database > Console. Paste the COMPLETE contents of schema.sql and run it.
   This creates empty tables. No default user or admin password exists.
4. Workers & Pages > your Pages project > Settings > Bindings.
   Add D1 database binding. Variable name MUST be DB. Select the database from step 2.
   Configure PRODUCTION. Use a separate database if testing on preview.
5. Settings > Variables and Secrets: add the following as encrypted secrets:
   RAZORPAY_KEY_ID = your Razorpay key ID
   RAZORPAY_KEY_SECRET = your Razorpay key secret
   RAZORPAY_WEBHOOK_SECRET = a long random secret that YOU also set on Razorpay webhook
   Never put key secrets into index.html, app.js, GitHub, public files, or a chat message.
6. Create a new deployment and upload the complete ZIP (root index.html and _worker.js).
   _worker.js implements the backend in Pages advanced mode. _routes.json runs it for /api/* only.
   Redeploy AFTER adding the DB binding/secrets.
7. Register an account on the live URL. Verify the free trials.
   Without Razorpay secrets, login/trials work but checkout reports that payments are not configured.

RAZORPAY SETUP
1. Use your own business Razorpay account. Complete its live activation requirements.
2. Start with TEST mode keys in Cloudflare; do not collect real money until test checks pass.
3. Configure automatic capture in Razorpay's payment capture settings. Only CAPTURED payments activate access. Merely authorised/failed payments do not.
4. In Razorpay webhook settings add:
   https://YOUR-ACTUAL-WEBSITE-HOST/api/payments/webhook
   Event: payment.captured
   Secret: EXACTLY the same value as Cloudflare RAZORPAY_WEBHOOK_SECRET.
5. Test a Rs 199 plan, expiry rights, Rs 499 batch plan, payment failure, webhook retry and Check payment.
6. Replace test keys with LIVE keys only when ready. Add webhook in live mode as well.
7. App prices are TOTAL collected amounts: Rs 19900 paise / Rs 49900 paise respectively. No separate tax amount is added by this code. Gateway charges reduce your net receipt.
8. Set your actual business support/contact, billing/refund terms and privacy details before accepting public payments. No business address/email has been invented in this package.

ALTERNATIVE — WORKERS VIA CLI
The source.zip link contains full source including package.json, worker.js, wrangler.jsonc and schema.sql.
1. Extract source.zip into a separate folder.
2. npm ci
3. npx wrangler login
4. npx wrangler d1 create db-document-tools
5. Put returned database_id into wrangler.jsonc (replace placeholder).
6. npx wrangler d1 execute DB --remote --file=schema.sql
7. npx wrangler secret put RAZORPAY_KEY_ID
   npx wrangler secret put RAZORPAY_KEY_SECRET
   npx wrangler secret put RAZORPAY_WEBHOOK_SECRET
8. npx wrangler deploy
Workers uses public/ assets and worker.js. _worker.js is generated only for the Pages ZIP, not required in public/ for Workers.

ACCOUNT SUPPORT / FORGOTTEN PASSWORD
Signed-in users can change password with their current password. Automated email password-reset is not included. Do not launch without an account-support process. Never reset a password just because an unverified email request asks for it.

DATABASE HOUSEKEEPING
Workers CLI config includes a daily cleanup cron. Pages does not run this cron; optionally schedule cleanup externally or periodically run in D1 Console:
DELETE FROM rate_limits WHERE bucket < (strftime('%s','now') / 900)-4;
DELETE FROM runs WHERE expires_at < CAST(strftime('%s','now') AS INTEGER)*1000;
Do not delete users, trials, payments or plan_periods to reset quotas.

VERIFICATION
Automated route/database integration tests pass: register/login/logout, password change, old-session invalidation, success-only counting, failed/cancelled retries, idempotent completion, all tool/mode trial limits, concurrent trial reservation, single vs batch plan rights, expiry, amount tampering, forged signatures, idempotent payment verification/webhooks, and CSRF rejection. Provider responses were mocked; no real payment was made. Converter/PDF engine fixture checks also pass. Worker deployment dry-run performed. Interactive browser and real Cloudflare/Razorpay end-to-end verification have not been completed in this environment.

LICENSE
App and MuPDF.js are AGPL-3.0-or-later. fflate and pdf-lib are MIT. SheetJS CE and PDF.js are Apache-2.0. See bundled vendor license files; fonts/cmaps/wasm retain their respective notices. Source download remains available as required. Do not remove license/source notices.
