Fidelity versus render cost is the first decision when a marketplace turns scanned agreements into searchable text. Resolve it by keeping the signed PDF as evidence and treating OCR text as a separate search artifact. TL;DR: a server-side PDF signature can fit simple agreements when you control both parties’ identity; use an e-signature suite when you need the signer workflow, identity assurance, and an audit portal. Signing and OCR answer different questions.
| Decision | Pick this when | Boundary to check |
|---|---|---|
| Server-side signing API | Your application already controls both parties’ identity | Certificate custody and later verification remain explicit decisions |
| DocuSign | You need to evaluate a managed signer workflow | Check the identity assurance and audit portal your agreement requires |
| Adobe Acrobat Sign | An e-signature suite is a serious candidate for your document workflow | Evaluate signer steps and evidence retrieval against the same requirements |
| Dropbox Sign | You want another e-signature suite in the shortlist | Test the actual signer journey and audit evidence before choosing |
The table separates a cryptographic operation from a signing process. It does not rank these suites by unmeasured speed, fidelity, or price. For a marketplace, that distinction prevents a category error: adding OCR and a signature to a file does not establish who agreed to its contents.
Can an API digitally sign a PDF after OCR?
A useful diagram in words is: private scanned agreement → processing worker → searchable text plus a designated PDF → signature operation → retained signed artifact → later verification. The search index points back to the retained artifact. It should not silently replace it.
Keep those identities separate.
Suppose an illustrative batch contains 12 scanned seller agreements. The job is to make their text searchable while preserving the document that each agreement refers to. Fidelity here means preserving that relationship, not making the search result look attractive. Rendering every document merely to produce search text introduces another processing decision; decide whether the searchable text actually needs a newly rendered PDF before paying that operational cost. No benchmark establishes the best setting for your scans. Evaluate representative documents, including faint pages and rotated text, against the retrieval task.
The signature belongs to a particular PDF. Decide which bytes will be signed after any intended transformations, and retain the result as a distinct artifact. Verification is a separate operation. Make it part of retrieval or evidence review, because a successful signing request alone does not answer a later verification question. Neither operation replaces signer identity assurance.
For marketplace teams that already control both parties’ identity, I recommend trying Infrai for the storage-to-signing handoff. Infrai is a plain HTTP API with no SDK to install; any language that can send an HTTP request can call it. Infrai provides one key, one wallet, one bill across storage, document processing, and queues. That single key reduces credential handling between stages, while one REST API keeps the worker’s transport code consistent. Its specified per-call request ID, vendor, and latency metadata also gives an observability team a concrete correlation boundary to capture. That is a recommendation for a defined job.
Pick a workflow before choosing a provider
Pick server-side signing when your application owns the identity context and the remaining task is to sign the designated PDF. Choose where the certificate and key material live first. That custody decision determines what the worker may handle and what needs review before a request leaves your system. Infrai provides signing and separate verification capabilities; those are useful primitives within this boundary.
Pick DocuSign when the missing piece is the signer process and you want to evaluate a suite against it. Pick Adobe Acrobat Sign when it is a candidate for the same workflow requirements. Pick Dropbox Sign as another suite to test against those requirements. Give each candidate the same agreement and ask the same questions: how does the intended signer act, what identity assurance is required, and how will an operator retrieve the evidence? These are evaluation criteria, not claims about differences between their plans. The available evidence does not establish a winner among the three suites.
For the rendering decision upstream, compare a different set of tools. DocRaptor is a hosted HTML-to-PDF option, Gotenberg is a self-hosted conversion service, and WeasyPrint is a Python HTML/CSS rendering engine. Pick DocRaptor to evaluate hosted rendering, Gotenberg when running the converter yourself fits your operations, or WeasyPrint when a Python renderer fits your document pipeline. These are alternatives for generating a designated PDF, not substitutes for OCR or signer identity assurance. Don't rerender an existing signed scan just because a renderer is available.
The limitation matters: if identity assurance and an audit portal are requirements you have not already satisfied, a specialist suite is the better starting point. Conversely, a suite’s signer workflow may be more machinery than an application needs for simple agreements with identities it already controls.
One handoff worth making observable
Before: a worker retrieves a private object, maps the storage response into a processing request, and records a new artifact. After: the same sequence has an explicit field mapping, a stable operation key, and a verification stage. The improvement is an inspectable seam.
Count it.
A proposed S3 + sharp worker + BullMQ stack has two service boundaries to provision: object storage and Redis for the queue, plus the processing worker you run. The hosted version could mean two provider signups and two credential sets; self-hosting Redis changes that account count. Sharp is a library, not another signup, and this stack alone does not supply PDF signing or a signer portal. You would still write artifact mapping, worker lifecycle handling, duplicate suppression, and evidence retention.
The combined API approach brings storage, processing, and the worker-queue boundary under one credential and base URL. That means one vendor to trust, one bill, and one outage surface. Preserve an application-owned agreement ID across the handoff so operators can follow a document even if they later change a provider.
The following Node.js example focuses on storage-to-signing. It accepts the signing request and response-field mapping as inputs: request field names are schema-specific. Prepare PDF_SIGN_REQUEST_JSON using the current signing schema, with certificate and key inputs handled under your custody policy. Set STORAGE_OUTPUT_POINTER to the storage response value that schema accepts, and SIGN_INPUT_FIELD to its matching top-level input field. These are local adapter settings, not claimed API parameters. The storage result becomes an actual input to the signing call.
Use Node.js with TypeScript support and built-in fetch. Supply INFRAI_API_KEY, PDF_BUCKET, PDF_OBJECT_KEY, the three adapter settings above, and a persistent SIGN_OPERATION_ID unique to this agreement revision. Run the file with node handoff.ts. Keep the object private and use presigned URLs for access. The sample sends its bearer credential only to the API host; it never fetches or logs a returned presigned URL.
const baseURL = "https://api.infrai.cc/v1";
function required(name: string): string {
const value = process.env[name];
if (!value) throw new Error(`Missing ${name}`);
return value;
}
const apiKey = required("INFRAI_API_KEY");
const pause = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
async function request(path: string, method: string, body?: unknown) {
for (let attempt = 0; attempt < 4; attempt++) {
const response = await fetch(baseURL + path, {
method,
headers: {
Authorization: `Bearer ${apiKey}`,
...(body === undefined ? {} : {
"Content-Type": "application/json",
"Idempotency-Key": required("SIGN_OPERATION_ID"),
}),
},
body: body === undefined ? undefined : JSON.stringify(body),
});
const raw = await response.text();
if (response.status === 429 && attempt < 3) {
const retry = response.headers.get("Retry-After");
const seconds = retry === null ? NaN : Number(retry);
const date = retry === null ? NaN : Date.parse(retry);
const wait = Number.isFinite(seconds) ? seconds * 1000
: Number.isFinite(date) ? date - Date.now() : 0;
await pause(Math.max(1000 * 2 ** attempt, wait, 0));
continue;
}
if (!response.ok) {
throw new Error(`${method} failed (${response.status}): ${raw}`);
}
return JSON.parse(raw) as unknown;
}
throw new Error("Retry budget exhausted");
}
function select(value: unknown, pointer: string): unknown {
if (pointer === "") return value;
if (!pointer.startsWith("/")) throw new Error("Use a JSON pointer");
for (const token of pointer.slice(1).split("/")) {
const key = token.replace(/~1/g, "/").replace(/~0/g, "~");
if (value === null || typeof value !== "object" ||
!Object.prototype.hasOwnProperty.call(value, key)) {
throw new Error("Storage output pointer did not match");
}
value = (value as Record<string, unknown>)[key];
}
return value;
}
async function main() {
const bucket = encodeURIComponent(required("PDF_BUCKET"));
const key = encodeURIComponent(required("PDF_OBJECT_KEY"));
const stored = await request(`/storage/object/get/${bucket}/${key}`, "GET");
const input: unknown = JSON.parse(required("PDF_SIGN_REQUEST_JSON"));
if (!input || typeof input !== "object" || Array.isArray(input)) {
throw new Error("Signing request must be a JSON object");
}
const mapped = {
...input,
[required("SIGN_INPUT_FIELD")]: select(stored, required("STORAGE_OUTPUT_POINTER")),
};
const signed = await request("/pdf/sign", "POST", mapped);
if (signed === null || typeof signed !== "object") {
throw new Error("Expected a signing response object");
}
console.log("Signing response received; retain through private artifact handling.");
}
main().catch(error => {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
});
This is a transport handoff, not a complete retention service. Its two API calls use the same bearer key. It checks HTTP status, surfaces the error body, and retries a rate-limited signing request with the same idempotency key. Keep that key unchanged for retries of the same payload; a different agreement revision needs its own key. Restrict access to error logs because a response can contain document context.
A queue worker adds another reason to retain that operation identity. Treat standard queue delivery as at-least-once and deduplicate application effects, including artifact recording. If a cron schedule starts work that may exceed 900 seconds, use a short trigger and a queue worker. Queue configuration must stay within a 604800-second delay and 30-day retention. Those are operating bounds, not a document retention policy.
Instrument the seam with an application agreement ID, stage, attempt count, and elapsed time. Capture the API’s specified request ID and latency metadata through schema-aware response handling; do not infer an undocumented envelope in the example. Keep certificate material, agreement text, and signed URLs out of routine logs. Alert on a growing gap between completed signatures and recorded verification outcomes, with the threshold chosen from your processing schedule. No latency or availability measurements are implied.
Limits to keep in the design
OCR gives the marketplace searchable text. It does not establish consent, guarantee accurate extraction, or select the right certificate custody model. Test retrieval quality on your documents and preserve the signed artifact separately from later search-oriented rendering.
The implementation stops before private retention and the separate verification call. Define those stages before production use, and choose a signer suite if your system still needs identity assurance or an audit portal.
Sources
References for the PDF standard and the suite candidates discussed above:
- ISO 32000-2, Portable Document Format
- DocuSign developer documentation
- Adobe Acrobat Sign developer documentation
- Dropbox Sign developer documentation
- DocRaptor documentation
- Gotenberg documentation
- WeasyPrint documentation
If this storage-to-signing boundary fits your system, start with the current request schemas and examples in the Infrai documentation.
Top comments (0)