How We Built PDF Mind: Heavy PDF Work Without Heavy Servers
- Engineering
- Web
- Architecture
A free PDF tool site has to handle private documents, very heavy jobs and very light ones, on a budget. These are the decisions that made it work.

PDF Mind is our own product: 50+ online tools, PDF and more, on the web and in an iOS app. You can merge, split, compress, convert, OCR, sign, fill and edit PDFs, with no signup to start. We build it and we run it, which means every decision below is one we live with in production. This is how it fits together.
The constraints
Four things shaped the design from the start.
- The files are private. People upload contracts, ID scans and bank statements. We should hold them for as short a time as possible.
- It is free to start. Server cost has to stay low, so the free tier cannot be what decides the size of the server bill.
- The work is uneven. Merging two PDFs takes milliseconds. OCR on a 200-page scan takes minutes and a lot of memory.
- The input is hostile, usually by accident. Malformed files, password-protected files, files with a thousand pages. All of them arrive.
Decision 1: put each job where it is cheapest
There is no single "PDF server". Each kind of work runs in the place that suits it.
| Where | What runs there | Why |
|---|---|---|
| The browser | The editor: viewing, editing, annotating, and by default the export | No server load, and the download is instant |
| The API (Node) | Light tools: merge, split, organize, watermark, page numbers, sign | Fast enough to answer in the request itself |
| A worker, behind a queue | Heavy tools: OCR, Word, Excel and PowerPoint conversion, compression, PDF/A | Slow and memory-hungry, so they must never block the API |
The editor is built on pdf.js for rendering, Fabric.js for the editing layer, and pdf-lib to write the result. The heavy tools lean on well-tested open-source engines (LibreOffice, Ghostscript, Tesseract through ocrmypdf, PyMuPDF and pdf2docx) rather than anything we would have to maintain ourselves.
The heavy tools go through a BullMQ queue on Redis. By default the worker runs one job at a time. That sounds timid, but OCR is CPU and memory heavy, and two large OCR jobs at once on a small machine is how a server falls over. With a queue, a busy moment means a user sees "processing" for a little longer. Without one, it means everyone gets an error. Concurrency is a setting, so a bigger machine can take more.
The website and the iOS app use the same API. A fix to a conversion reaches both at once.
Decision 2: files that delete themselves
"We delete your files" is easy to write on a privacy page. We wanted it to be something the system does whether or not anyone remembers.
- Tool uploads are kept in their own folder per job. A sweep job deletes anything older than three hours, whether the user came back for the result or not.
- Documents opened in the editor by a guest are kept for 24 hours after their last change, then removed along with their files. The privacy policy states the same window.
- Download links from the email delivery path (below) expire on their own schedule, and a cleanup job removes the file with the link.
One detail we are glad we caught. When someone leaves their email in the editor, that lead used to live on the document row. Deleting documents after 24 hours would have quietly deleted leads too. Leads now have their own table, and the cleanup job checks that the table exists before it deletes anything. If it is missing, the job does nothing and logs why. A cleanup job that can destroy data you meant to keep should fail closed.
Decision 3: one export engine, in two places
The editor exports in the browser: the edited PDF is assembled on the user's machine and downloaded straight away. That is fast and costs nothing. But it has limits. A file born in the browser cannot be emailed as a link, cannot be re-downloaded on another device, and cannot be held behind a step such as "enter your email to download".
So the export also runs on the server. The important choice was not to write it twice. The function that assembles the PDF is pure: given the source PDF, a serialised description of the edits, and the font bytes, it returns the finished file. It touches no browser APIs, no DOM and no network. The browser calls it directly. The worker imports the same module and calls it with the same inputs.
The editor already serialised its whole canvas for undo and redo, so the description of the edits existed before we needed it. We checked the risky parts with small experiments first, including whether a page could be rebuilt on the server without any canvas library at all. It could, which kept the worker light.
The output tries to stay as close to a real PDF as it can:
- Replaced text is written as real, selectable text.
- Covers become vector shapes, and links, sticky notes and form fields become real PDF objects.
- Anything that cannot be expressed as vector falls back to a high-resolution image of the page, so nothing is lost.
- Rotated and cropped pages are handled, so an edit lands where the user put it and not sideways.
- Form values in Arabic, Cyrillic or CJK scripts use Unicode fonts instead of failing.
Which path is used is a switch in the admin dashboard, with no deploy. In browser mode, the download is instant. In email mode, the browser sends the edits to the server, the worker builds the file, and the download link goes only to the email address the user enters. Requests are rate limited, so the form cannot be used to flood someone's inbox.
We are clear with ourselves about what this is. It is a lead capture step, not copy protection. A browser editor has to load the document to show it, and what a browser can show, a determined person can copy. No browser-based editor gets around that.
What production taught us
"Works on my machine" includes the operating system
In October we ran every server-side tool on production with a small test file. Most passed. PowerPoint to PDF and Excel to PDF failed, while working perfectly on a development machine. The code was fine. The server had LibreOffice's word processor installed but not its spreadsheet or presentation parts, because the setup script only installed what the first tools needed.
Two lessons came out of it. First, test every tool on production, not just the ones you changed. Second, the provisioning script is part of the product: we updated it so the next server gets the full set. A third, smaller one: the process remembered a missing program for as long as it ran, so installing the package changed nothing until a restart.
A full audit, then a release of fixes
We audited every tool end to end and shipped the fixes in a single release. Some of what changed:
- Errors have stable codes. Every error now carries a code such as
PASSWORD_PROTECTEDorTOO_LONG, so the website shows a translated message and the iOS app can react properly. - No more silent failures. A password-protected PDF used to come back as a blank file marked "successful". It now fails with a clear message, and the user's daily allowance is refunded.
- The server stops talking about itself. Unexpected errors show "Something went wrong" to the user and go to the log in full, instead of exposing internal details.
- Honest limits. The editor used to say it accepted 50 MB, but saving failed above about 22 MB. It now says 20 MB and means it. Light tools cap PDFs at 1,000 pages, rather than letting a huge file tie up the server.
None of this is glamorous, and that is the point. Most of what makes a tool site trustworthy is the behaviour on the bad day: the odd file, the busy hour, the missing package.
Languages
OCR runs in 14 languages, including Bengali, Arabic, Hindi, Urdu, Chinese, Japanese and Korean, and the server only offers the languages it actually has installed. The site's tool pages are translated, Arabic included, with right-to-left layout.
What you can check yourself
PDF Mind is live, so you do not have to take our word for any of this. Open a PDF in the editor, change a word and download it. Run OCR on a scan. Merge two files. The behaviour described above is what you will see.
Why this matters if you are building something
Most businesses do not need a PDF tool site. Many do have document work that eats people's time: invoices, forms, reports, contracts that need the same five changes every week. The same approach applies. Decide what can run on the user's device, put the heavy work behind a queue, make retention a rule in code, and test the bad inputs first.
If you have document work like that, tell us about it. You can also read more about PDF Mind and our web app development work.