Serverless and edge
Where gopdfrab fits when there is no long-running process.
Where it fits
| Runtime | Fit | Why |
|---|---|---|
| Long-running service | Best | Validate in-process, with typed errors. |
| Container / batch job | Best | A static binary in a scratch image, 4.3 MB if it only validates. |
| Serverless function | Good | Nothing to warm up, so cold starts are the platform's, not the validator's. |
| Browser / WebAssembly | Situational | Nothing is uploaded, but first-time visitors download the bundle. |
| Edge worker (V8 isolate) | Constrained | Bundle and memory caps are too low for a full PDF engine. Use a function behind the edge. |
In the browser
Compiled with GOOS=js GOARCH=wasm, gopdfrab runs in a Web Worker and the document never leaves the browser. The converter loads a 5.9 MB verify-only build, and the 14.4 MB converter only when you fix a file.
Memory and time limits
With a memory cap and untrusted input, set the resource limits. A single stream decodes to at most 256 MB by default.
// A single stream decodes to at most 256 MB by default, guarding against
// decompression bombs. Raise it for legitimately large PDFs, or lower it to
// harden against hostile input.
gopdfrab.SetLimits(gopdfrab.Limits{
MaxDecodedStreamBytes: 512 << 20, // 512 MB
MaxResidentBytes: 32 << 20, // caches one open document keeps (default 64 MB)
})
gopdfrab.CurrentLimits() // the effective caps
gopdfrab.DefaultLimits() // the built-in capsPass a context with a deadline so a pathological file is abandoned before the platform kills the call. See options.
FAQ
Can I validate PDF/A in an AWS Lambda?
Yes. There is nothing to warm up before the first byte is read.
Can PDF/A validation run in the browser?
Yes. The converter on this site is gopdfrab compiled to WebAssembly, running in a Web Worker. The document never leaves the browser.
How big is the WebAssembly bundle?
About 5.9 MB for validation, cached after the first load. Conversion needs a 14.4 MB module, fetched only when you convert.
How much memory does validation need?
It depends on the document. Cap it with the resource limits.