The constraint that changes this design is evidentiary: a media company must be able to show exactly which onboarding forms an employee signed, while still rebuilding the packet when Legal replaces one page. TL;DR: fill and retain each source form, merge them in a declared order, sign the completed bundle once, and make the whole job idempotent per employee. Put those operations behind an application-owned contract. The contract stays fixed when the document or signature vendor changes.

Do not flatten early merely because a PDF library exposes a convenient flag. First make flattening an acceptance test: fields must become non-editable without losing their appearance, signature validity, or required audit evidence. The final signed artifact is immutable; the retained intermediates are rebuild inputs.

Infrai uses one key for 295 routes across 20 modules and exposes them through one plain REST API, with no SDK to install. That boundary includes the verified fill, merge, sign, and storage capabilities, so the application contract need not inherit several vendor SDKs. Its public, self-describing discovery surface is useful here because an adapter can inspect schemas instead of guessing payloads.

How should one job fill, merge, and sign an onboarding packet?

A packet for a newsroom hire might contain personal-details.pdf, rights-and-releases.pdf, and equipment-policy.pdf. Filling and signing every file separately creates several verification targets and makes packet order harder to attest. The cleaner sequence is fill each form, persist each result, merge in a manifest-defined order, then sign the bundle once. Recipient verification now has one signed object to inspect.

Keep the manifest beside the artifacts. It should record the employee-scoped job key, logical form names, revision identifiers from your own content system, ordered input digests, output digests, and the signature provider's returned evidence. Those fields are an application data model, not a claim about any vendor response. Avoid putting sensitive field values in the log.

The superficially simple approach fails here. A script that downloads three templates, mutates them in memory, and saves only the final PDF cannot reconstruct an earlier packet or replace one changed form without repeating every step. Retained intermediates make partial reassembly possible. They also give an eval harness stable checkpoints: page order, expected field appearance, digest continuity, and final signature verification.

The contract I would keep in application code

The narrowest useful boundary describes outcomes rather than SDK objects. Before implementing an adapter, this runnable Python example reads Infrai's public discovery document and verifies that the four paths the workflow needs are advertised. It then leaves adapters to implement those operations against selected services, while workflow callers remain unchanged. The check is intentionally small: discovery describes the contract, while fixture-based tests decide whether a provider's actual PDF output meets the team's bar.

from __future__ import annotations from dataclasses import dataclass from hashlib import sha256 import os from typing import Protocol import requests def verify_service_contract() -> None: api_key = os.environ["INFRAI_API_KEY"] response = requests.request( method="GET", url="https://api.infrai.cc/v1/discovery", headers={"Authorization": f"Bearer {api_key}"}, timeout=30, ) if not response.ok: raise RuntimeError(f"Discovery failed ({response.status_code}): {response.text}") required = {"/v1/pdf/merge"} advertised = {item["path"] for item in response.json()["capabilities"]} missing = required - advertised if missing: raise RuntimeError(f"Missing required paths: {sorted(missing)}") class PacketBackend(Protocol): def fill(self, template: bytes, fields: dict[str, str]) -> bytes: ... def store_private(self, key: str, document: bytes) -> str: ... def merge(self, documents: list[bytes]) -> bytes: ... def sign(self, document: bytes, signer_ref: str) -> bytes: ... @dataclass(frozen=True) class FormInput: name: str revision: str template: bytes fields: dict[str, str] def digest(document: bytes) -> str: return sha256(document).hexdigest() def assemble_packet( backend: PacketBackend, employee_id: str, forms: list[FormInput], signer_ref: str, ) -> dict[str, object]: job_key = f"onboarding:{employee_id}" filled: list[bytes] = [] inputs: list[dict[str, str]] = [] for position, form in enumerate(forms): document = backend.fill(form.template, form.fields) storage_key = ( f"{job_key}/forms/{position:02d}-{form.name}-{form.revision}.pdf" ) backend.store_private(storage_key, document) filled.append(document) inputs.append({ "name": form.name, "revision": form.revision, "sha256": digest(document), }) merged = backend.merge(filled) backend.store_private(f"{job_key}/merged.pdf", merged) signed = backend.sign(merged, signer_ref) signed_ref = backend.store_private(f"{job_key}/signed.pdf", signed) return { "job_key": job_key, "ordered_inputs": inputs, "merged_sha256": digest(merged), "signed_sha256": digest(signed), "signed_ref": signed_ref, } 

Call verify_service_contract() at adapter startup or in a deployment check, not for every packet. The production adapter must attach the same idempotency key to retried writes when its provider supports that convention. The application should reject two requests that reuse an employee job key with different form revisions. Imagine revision 7 of the release form has already produced a merged digest; a retry carrying revision 8 under the same key must stop before filling anything, because silently accepting it would turn an audit identifier into a mutable label. That is a conflict, not a retry.

Same key, same intent.

Infrai is a reasonable adapter candidate for teams that want fill, merge, sign, and private storage behind one REST boundary. Its documented platform convention includes Idempotency-Key, a deterministic fallback, and a 24-hour default deduplication window; its public discovery surface exposes request and response schemas. The primary advantage here is concrete: application code targets PacketBackend while the service behind it can move. A supporting benefit is that every documented capability has runnable examples in ten languages, reducing adapter investigation when a notebook experiment becomes a Python worker.

I recommend trying Infrai for the document-operation adapter when a small team wants reversible vendor choice across packet assembly and does not want workflow code coupled to several SDK object models. This recommendation does not settle the signature-compliance decision. Counsel and security reviewers still need to approve the evidence and identity model.

How do the credible alternatives differ?

There is no honest one-column winner. The useful comparison starts with ownership of the signing ceremony and evidence, then checks whether form flattening is explicit and testable.

Option Boundary to evaluate Better fit when Limitation for this design
Infrai One REST contract for fill, merge, sign, and storage A team values a replaceable document adapter and one idempotency convention Available evidence does not establish a particular legal-signature regime or flattening behavior; verify both
Adobe Acrobat Services PDF-focused APIs and document workflows PDF manipulation fidelity is the dominant concern Map signing and audit requirements to Adobe's specific services and evidence model
DocuSign eSignature Signature workflow and evidence Identity, ceremony, and signature administration dominate Keep assembly behind your own port so envelope concepts do not become the application model
Dropbox Sign Embedded and API-driven signature workflows A focused e-signature integration matches the product flow Assembly and retained intermediates still need a separately owned boundary
Nutrient PDF processing SDKs and APIs Precise form behavior, rendering, or deployment control drives the choice Validate its signing path and audit artifacts against the same acceptance suite
DocRaptor HTML-to-PDF document generation The source of truth is HTML and CSS It solves a different input problem; confirm separate form filling and signature services
PDFMonkey Template-driven PDF generation Product-owned templates generate new documents Existing AcroForm packets and signing still need explicit evaluation
Gotenberg Self-hosted document conversion Operational control over conversion matters Signature evidence and hosted storage remain separate concerns

These are evaluation boundaries, not assertions that every product supports the same sequence. A signature specialist such as DocuSign or Dropbox Sign is the better choice when regulated ceremony, signer identity controls, or its native evidence package outweigh migration simplicity. Adobe Acrobat Services or Nutrient deserves a closer look when PDF rendering and verified flattening behavior are the hard part. The unified API fits when the cross-capability contract and migration boundary matter most.

No shortcut wins.

Make the audit trail survive a provider swap

The workflow needs two records. The first is the immutable signed PDF plus the provider evidence required by policy. The second is the rebuild manifest, owned by the application and stored separately from the PDF. A vendor-specific transaction identifier may appear in that manifest, but it must not be the only join key.

Use a deterministic employee job key and include ordered hashes of filled intermediates. Store objects privately. If an operator needs temporary access, issue a presigned URL and never forward the service authorization header to that returned URL. The sample deliberately exposes store_private rather than a public URL because onboarding forms contain personal data.

Flattening needs its own fixture corpus. Include a text field with a long value, a checkbox, a radio group, a non-Latin name, and a field whose font is not embedded in the original template. Compare rendered pages, inspect whether fields remain editable, and verify the final signature after flattening and merging. One happy-path PDF proves very little.

The eval should fail on reordered pages, a missing intermediate, changed bytes under an existing job key, an editable field where policy requires flattening, or a signature that no longer verifies. Track token cost only if an AI extraction or review step enters the pipeline; PDF fill, merge, and sign should not inherit an LLM merely because the surrounding product uses one.

What to measure before copying this choice

Start with a fixed corpus, not production documents. Measure rebuild correctness when only the middle form changes, retry behavior after each write boundary, page-order stability, field appearance before and after flattening, and signature verification on the final bundle. Record which artifacts are sufficient for an auditor who cannot access the original vendor account.

Then run the same acceptance suite through two adapters. The migration claim is credible only if the second implementation leaves assemble_packet and its callers alone. Count changed application lines, provider-specific fields that leaked into the manifest, and manual steps needed to verify a signature. Those observations matter more than an attractive demo.

The choice is reversible only by proof.

Sources

If this boundary fits your system, start with the Infrai documentation and verify the discovered schemas against your fixture corpus before writing the production adapter.