From 58bbe104a1fd31a4f349d6a68bb8f6f67cfe2dd2 Mon Sep 17 00:00:00 2001 From: Agando Date: Mon, 9 Nov 2026 15:02:12 +0100 Subject: feat(pdf2txt): canonical product tree with pdf.js vendored Source: spaces/chatstudio/pdf2txt.html (2026-10-19, unchanged, md5 fbe1df56). Packaged copy differs by exactly two lines (vendor/ paths). MIT, PDF.js Apache-2.0. --- CHANGELOG.md | 3 + LICENSE | 29 ++ README.md | 88 +++++ VERSION | 1 + docs/USAGE.md | 122 ++++++ src/index.html | 1192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1435 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 VERSION create mode 100644 docs/USAGE.md create mode 100644 src/index.html diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0684b9b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## [1.0.0] - 2026-11-09 + +First packaged release: single-file browser app plus local PDF.js vendor assets. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c2e674d --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +MIT License + +Copyright (c) 2026 Akan Goksu Valdes + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--------------------------------------------------------------------------- +THIRD-PARTY NOTICE + +The files in vendor/ (pdf.min.js, pdf.worker.min.js) are PDF.js and are +licensed under the Apache License, Version 2.0, not the MIT licence above. +See https://www.apache.org/licenses/LICENSE-2.0 for the full text. +The MIT licence above covers only the application file src/index.html. diff --git a/README.md b/README.md new file mode 100644 index 0000000..566b335 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +# PDF2TXT + Translator 1.0.0 + +A single-page, browser-only tool that pulls the text out of a PDF. The document is +opened and parsed **on your own machine** — nothing is uploaded anywhere. There is no +server, no account, no sign-up and no tracking code in the app. + +## What the tool actually does + +- **Load one file at a time** — drag & drop it onto the drop zone or click to choose it. + The picker accepts `.pdf`, `.txt`, `.md` and `.json`. +- **Extract text from a PDF** — every page is read with the bundled PDF.js and joined + into one plain-text document, with a progress bar (`Page i/total`). +- **Or paste text directly** into the paste box and press *Load Pasted Text*. +- **Edit the result** in a full-size editor (Select All / Deselect All / Fullscreen). +- **Download TXT** (`extracted.txt`) or **Copy All** to the clipboard. +- **Optional language-model steps** — Clean, Translate, Validate, or a combined + workflow: `Clean → Translate → Validate`, `Translate → Validate`, + `Clean → Validate`, `Translate Only`, `Clean Only`. +- **Translate into 16 target languages** offered in the page: English, Spanish, French, + German, Italian, Portuguese, Chinese, Japanese, Korean, Russian, Arabic, Hindi, + Turkish, Dutch, Polish, Swedish. Text is split into 1,500-character chunks and sent + one chunk at a time, with pause and stop buttons and a token counter. +- **Settings tab** — API source (Proxied `/ollama`, Local `localhost:11434`, or a Custom + URL), optional API key, *Refresh Models* (reads `/api/tags`), and chunk size. + +It does **not** do OCR, batch/multi-file processing, or translation presets. A scanned +PDF with no text layer will come out empty. + +## What you receive + +``` +pdf2txt/ +├── src/index.html the whole application (HTML + CSS + JS, no build step) +├── vendor/pdf.min.js PDF.js core library +├── vendor/pdf.worker.min.js PDF.js worker +├── docs/USAGE.md step-by-step guide for non-technical users +├── README.md this file +├── CHANGELOG.md +├── LICENSE +└── VERSION +``` + +## How to run it + +The page loads PDF.js as a Web Worker, and browsers refuse to start a worker from a +`file://` URL. So double-clicking `src/index.html` will load but extraction will fail. +Serve the folder over plain HTTP instead — no dependencies, Python 3 is enough: + +```bash +cd products/pdf2txt +python3 -m http.server 8000 +``` + +Then open . Any static web server works the same +way; upload the whole `pdf2txt` folder to any host and open `src/index.html`. + +## Optional translation + +Translation is **off by default in the sense that you must point it at a model**. The +page talks to an Ollama-compatible API using `POST /api/generate`. The model used for +offline translation is named in the page's Local model list as: + +``` +translategemma:latest +``` + +To use it entirely offline: + +1. Install [Ollama](https://ollama.com) and run `ollama pull translategemma:latest`. +2. In the app open the **Config** tab, set **API Source** to `Local (localhost:11434)`. +3. In the **Translate** section pick `translategemma:latest` as the Translation Model. +4. Choose a target language and press **Translate**. + +Two honest caveats about the shipped defaults: + +- The default **API Source** is `Proxied (/ollama)`, which expects a server-side proxy + at `/ollama`. On a plain static host use `Local` or a `Custom URL`. +- The default **Translation Model** is `glm-5.3-flash:cloud` — a cloud model. For a fully + local, offline run you must switch it to `translategemma:latest` (or another model you + have pulled, such as `llama3.2:latest` or `qwen2.5:7b-instruct`). + +Without a reachable model endpoint, PDF extraction, editing, copy and TXT download all +still work; only the Clean/Translate/Validate buttons fail. + +## Licence + +MIT © 2026 Akan Goksu Valdes — see [LICENSE](LICENSE). The files in `vendor/` are +PDF.js and remain under the Apache License 2.0. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/docs/USAGE.md b/docs/USAGE.md new file mode 100644 index 0000000..df194b6 --- /dev/null +++ b/docs/USAGE.md @@ -0,0 +1,122 @@ +# PDF2TXT + Translator — How to use it + +This guide assumes you have never run a web page from a folder before. It takes about +two minutes. + +## What this program is + +PDF2TXT reads the text inside a PDF and gives it to you as plain text you can copy or +save. Everything happens inside your own browser: the PDF is not uploaded to us or to +anyone else. There is no installation, no account and no internet connection needed for +the text extraction itself. + +--- + +## Step 1 — Start the app + +A browser will not load the PDF engine from a file you double-click, so start a tiny +local web server first. You only do this once per session. + +**On Linux / macOS** + +1. Open a Terminal. +2. Type these two lines, pressing Enter after each: + +```bash +cd path/to/pdf2txt +python3 -m http.server 8000 +``` + +3. Leave that window open. It must stay running while you use the app. + +**On Windows** + +1. Install Python 3 from python.org if you do not have it (tick "Add Python to PATH"). +2. Open the folder `pdf2txt` in File Explorer. +3. Click the address bar, type `cmd` and press Enter. +4. Type `python -m http.server 8000` and press Enter. + +**Then**, in any browser, open: + +``` +http://localhost:8000/src/index.html +``` + +You will see a dark page titled **PDF2TXT + Translator** with a **Main** and a +**Config** tab. If the page is blank or text extraction fails, you opened +`src/index.html` by double-clicking instead of through `http://localhost:8000` — go back +to Step 1. + +## Step 2 — Load your PDF + +- Drag the PDF from your file manager and drop it on the big dashed box, **or** click + the box and pick the file. +- The app shows the file name, the number of pages and the file size. +- Click **Load File**. A progress bar counts the pages while the text is extracted. +- One file at a time. To start over, click **🗑️ New**. + +You can also skip the PDF entirely: paste text into **Or paste text directly** and click +**Load Pasted Text**. + +## Step 3 — Check and edit the text + +The extracted text appears in the editor under **2. Edit & Select Parts**. You can type +in it, fix line breaks, or delete pages you do not want. **Select All**, **Deselect All** +and **⛶ Fullscreen** help with long documents. + +## Step 4 — Take the text out + +- **Download TXT** saves a file called `extracted.txt`. +- **Copy All** copies everything to the clipboard so you can paste it into Word, Google + Docs, an email, and so on. + +Both buttons use whatever is currently in the editor — your edits included. + +## Step 5 (optional) — Translate + +Translation uses a language model that runs through **Ollama**, and it is entirely +optional. Extraction, editing, copy and download work without it. + +1. Install Ollama from ollama.com. +2. In a terminal run: `ollama pull translategemma:latest` +3. Back in the app, open the **Config** tab and set **API Source** to + `Local (localhost:11434)`. +4. Open the **Translate** section. Set **Translation Model** to + `translategemma:latest`. +5. Choose your **Target** language from the 16 offered and press **🔄 Translate**. + +Things worth knowing before you translate: + +- The package ships with **API Source** set to `Proxied (/ollama)` and **Translation + Model** set to `glm-5.3-flash:cloud`. Both are cloud settings. For an offline run you + must change them as in steps 3 and 4. +- Long documents are sent in 1,500-character pieces, one after another, so a big book + takes a while. Use the pause/stop buttons if needed. +- The **Clean** and **Validate** steps also use a model (`llama3.2:latest` by default). If + you only want a translation, choose the workflow `Translate Only`. +- Machine translation is a draft, not a certified translation. Check names, numbers and + legal wording yourself. + +## Limits you should know + +- **No OCR.** If the PDF is a scan (a photo of a page), there is no text inside it and + the result will be empty. This tool reads text layers only. +- **No batch mode.** One document per run. +- **No upload.** Because nothing leaves your computer, there is no cloud backup and no + sync between devices. +- **Memory-bound.** Very large PDFs are limited by your browser's memory, not by an + artificial page cap. +- **Layout is flattened.** Columns and tables come out as a stream of text and may need + tidying in the editor. + +## Your purchase and the download link + +The download link you received from the store is **permanent for that purchase**: you can +open it again later to re-download the same package, with no expiry and no subscription. +Keep the link (or the email containing it) somewhere safe, and keep your own copy of the +`pdf2txt` folder as a backup — it is a plain folder of files, so copying it is enough. + +## Licence + +MIT © 2026 Akan Goksu Valdes. The PDF engine in `vendor/` is PDF.js, licensed under +Apache-2.0. See `LICENSE` in the package folder. diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..ffb3dc8 --- /dev/null +++ b/src/index.html @@ -0,0 +1,1192 @@ + + + + + + PDF2TXT + Translator + + + + + +
+ +
+ + +
+ +
+

1. Select File

+
+ +
📂 Click to choose or drag & drop
PDF, TXT, MD, JSON
+
+ +
+ + +
+ +
+

Or paste text directly:

+ + +
+
+ + + + + +
+
+
+
+
0%
+
+
+
+ + + 📊 Tokens: 0 +
+
+ +
+ + +
+
+ +
+
+ 📋 Activity Log + ▼ +
+
+
Ready. Select a PDF to begin.
+
+
+
+ +
+
+

⚙️ Settings

+

+ Configure default values. Chunk size auto-adjusts based on model type (cloud vs local). +

+ +
+ + +
+ + + + + +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + (500-5000, auto-adjusts with cloud models) +
+ +
+ + +
+ +
+ + +
+
+
+
+ + + + + \ No newline at end of file -- cgit v1.2.3