Skip to main content
CodingMarble

Web development

How Browser-Based PDF Tools Work and Keep Files Private

A browser-based PDF tool reads your file with JavaScript and WebAssembly running on your own device, so the document never has to travel to a server. You can verify this yourself by watching the Network tab in your browser's developer tools while you use the tool.

By CodingMarble · Published · 5 min read

Watercolour wireframe sketches of website layouts
Photo: Hal Gatewood on Unsplash

Two ways a PDF tool can work

Online PDF tools fall into two architectures. In the server model, your browser uploads the file, a program on the provider's machine does the work, and you download the result. In the client-side model, the web page itself contains the code that processes the document, so the file stays in your browser's memory and the output is created locally.

The difference matters for privacy. In the server model, a copy of your document exists on someone else's machine, even if briefly, and you rely on their retention and deletion practices. Contracts, identity documents, bank statements and medical forms are the kind of files where that is worth thinking about. In the client-side model there is nothing to retain, because nothing was sent. The trade-off is that the work is limited by what your own device can do.

The building blocks inside the browser

Everything starts with the File API. When you choose or drag a file into the page, the browser hands JavaScript a File object that can be read without any network request. The content is read into an ArrayBuffer, a block of raw bytes, which is exactly what a PDF library needs, since a PDF is a structured binary format made of objects, cross-reference tables and compressed streams.

A JavaScript library can then parse that structure, copy pages between documents, and write out a new file. The result is wrapped in a Blob and offered through a temporary object URL, which is what makes the download link work without any server involved. Heavier jobs use WebAssembly, a compact binary format that lets code written in languages such as C or Rust run in the browser at speeds closer to native programs. Many mature image and document libraries have been compiled this way.

Rendering uses canvas. To show a page preview or turn a page into an image, a renderer draws the page onto a canvas element, from which you can export pixels. Finally, Web Workers run the slow parts on a background thread so the page does not freeze while a large file is processed; the main thread keeps updating the progress bar.

JavaScript· Merging two PDFs locally with a library such as pdf-lib, with no upload.
import { PDFDocument } from "pdf-lib";

async function mergePdfs(fileA, fileB) {
  const out = await PDFDocument.create();

  for (const file of [fileA, fileB]) {
    const bytes = await file.arrayBuffer();      // File API -> raw bytes
    const src = await PDFDocument.load(bytes);
    const pages = await out.copyPages(src, src.getPageIndices());
    pages.forEach((p) => out.addPage(p));
  }

  const merged = await out.save();               // Uint8Array
  const blob = new Blob([merged], { type: "application/pdf" });
  return URL.createObjectURL(blob);              // use as a download link
}

Why merging is easy and compression and OCR are not

Merging, splitting, reordering and rotating are mostly structural. The tool rearranges objects that already exist and writes a new index; it does not need to understand what a page looks like. That is cheap in memory and time, and well-supported by JavaScript libraries.

Compression is harder because making a PDF smaller usually means recompressing the images inside it, or downsampling them, and that involves decoding each image, redrawing it at a lower quality or size, and re-encoding it. Doing that for dozens of high-resolution scans is processor- and memory-heavy, and the quality loss is a judgment the user must be able to control. Fonts and duplicated resources can also be optimised, but gains depend on how the file was produced; a PDF that is already efficient may barely shrink.

OCR, or optical character recognition, is harder still. The tool must render each page to an image, run a recognition model that reads the letters, and then place an invisible text layer back over the page. Recognition models and language data can be large downloads, and recognition is slow on a phone. Accuracy depends on scan quality, language and layout, so results always deserve a manual check. Conversion to formats such as Word is difficult for a related reason: a PDF describes where glyphs sit on a page, not paragraphs or tables, so rebuilding structure is an educated guess.

Memory limits and phones

Client-side processing uses your device's memory. A large PDF may be read into memory as bytes, parsed into objects, and then copied again while the output is built, so peak usage can be several times the file size. Desktop browsers usually cope, but a phone with limited memory may slow down, reload the tab, or fail on a very large scan. Rendering many pages to canvases at high resolution multiplies the cost.

Good tools reduce this by processing page by page, releasing memory as they go, working in a Web Worker and showing progress. If a tool fails on a big file, try closing other tabs, splitting the file first, or using a desktop browser. This is a real limitation of the local approach, and a fair reason why some providers choose to use servers for heavy conversions.

How to check that a tool keeps your file local

You do not have to take a privacy claim on trust. Open the tool in a desktop browser, press F12 to open developer tools, and select the Network tab. Clear the list, then add a file and run the operation. Watch the requests that appear after you select the file.

  1. Look for requests of type POST or PUT, or ones with a large size under the transferred column, right after you pick the file. An upload usually shows as a large request carrying data.
  2. Click a suspicious request and open the Payload or Request tab to see what was sent.
  3. Repeat the test with the network turned off: in the Network tab choose the offline throttling option, or disconnect Wi-Fi after the page has loaded. A genuinely local tool will still complete the job.
  4. Note requests that only fetch scripts, fonts or analytics. Those are normal; the key question is whether your document's bytes leave the page.

Small requests such as page-view analytics are not uploads, but be aware that they exist. Remember also that a tool can behave differently for different features, so test the specific operation you need, particularly OCR and conversions, which some tools do send to a server.

Choosing a PDF tool safely

  • Prefer tools that say clearly whether processing is local or on a server, and then check that statement with the Network tab.
  • Read the privacy policy for retention periods if files are uploaded, and avoid uploading sensitive documents to any service you have not vetted.
  • Be wary of tools that demand sign-up for basic tasks, add watermarks, or push you to install unknown software or extensions.
  • Check the result: page count, order, readable text and form fields after every operation, before you send the file onward.
  • Keep the original until you have confirmed the output, and remove personal data from files you must share.

If you would like to try a browser-based tool and run the Network tab test yourself, LovePDF at lovepdf.codingmarble.com offers 35 free PDF tools (merge, split, compress, convert, edit, sign, OCR) that process files in the browser with no sign-up and no watermark. Whichever tool you use, the same check applies: watch what leaves your device.

Need this built properly for your business?

CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.