Pressjet
← All articles
Digital signatures

Sign the packet after the last merge

Assemble an invoice and its terms, apply a PAdES signature, and verify the file you deliver.

Imagine an accounts team sends an invoice on Monday and attaches the terms on Tuesday. Signing the invoice on Monday authenticates that version of the document. If the customer needs one signed packet, assemble both parts first so the signature covers the file the customer actually receives.

Make the final page order explicit

Generate the invoice, select the applicable version of the terms and inspect both PDFs. Put their bytes in the intended order for merge. Open the merged proof once and check the transition from invoice to terms. The signing operation runs on a self-hosted Pressjet service configured with a PKCS#12 certificate and key. Use a server-side credential with permission to merge and sign.

import { readFile, writeFile } from "node:fs/promises";
import { Pressjet } from "pressjet";

const client = new Pressjet({
  baseUrl: "http://localhost:8080",
  apiKey: process.env.PRESSJET_API_KEY
});
const parts = await Promise.all(
  ["invoice.pdf", "terms.pdf"].map(path => readFile(path))
);
const packet = await client.merge(parts);
const signed = await client.sign(packet, {
  name: "Accounts team",
  reason: "Invoice and applicable terms",
  signingTime: new Date()
});
await writeFile("customer-packet.pdf", signed);

Read two results from the verifier

Pressjet applies a PAdES B-B signature with RSA and SHA-256. Run pdfsig customer-packet.pdf on the bytes you intend to deliver. Inspect which certificate signed it and whether the signature covers the document. Then check certificate trust on the recipient’s system. The name supplied in the request is descriptive metadata. Trust depends on the actual signing certificate and its chain.

The sample linked below makes that distinction visible. It was signed with the project’s self-signed test certificate. The signature verified in the local test, while the certificate issuer was untrusted. For a production rollout, repeat this check with your organization’s certificate in the reader your customers use.

Keep the signed bytes as the delivered artifact. If a customer needs revised terms, assemble and sign the revised packet as a new version. That leaves both parties with a clear answer to a practical question: exactly which pages were signed?

Download the signed test invoice · Server signing configuration · Signing and merge endpoints

Read nextMove one invoice off GotenbergAll articles ↗