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);
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: Uint8Array = await client.sign(packet, {
name: "Accounts team",
reason: "Invoice and applicable terms",
signingTime: new Date()
});
await writeFile("customer-packet.pdf", signed);
from datetime import datetime, timezone
from os import environ
from pathlib import Path
import pressjet
with pressjet.Client(api_key=environ["PRESSJET_API_KEY"], base_url="http://localhost:8080") as client:
parts = [Path(name).read_bytes() for name in ["invoice.pdf", "terms.pdf"]]
packet = client.merge(parts)
signed = client.sign(
packet,
name="Accounts team",
reason="Invoice and applicable terms",
signing_time=datetime.now(timezone.utc),
)
Path("customer-packet.pdf").write_bytes(signed)
package main
import (
"context"
"os"
"time"
pressjet "github.com/tonysantana1492/pressjet/sdks/go"
)
func must[T any](value T, err error) T {
if err != nil {
panic(err)
}
return value
}
func main() {
ctx := context.Background()
client := pressjet.NewClient()
invoice := must(os.ReadFile("invoice.pdf"))
terms := must(os.ReadFile("terms.pdf"))
packet := must(client.Merge(ctx, invoice, terms))
signed := must(client.Sign(ctx, packet, pressjet.SignatureDetails{
Name: "Accounts team",
Reason: "Invoice and applicable terms",
SigningTime: time.Now(),
}))
if err := os.WriteFile("customer-packet.pdf", signed, 0644); err != nil {
panic(err)
}
}
<?php
require __DIR__ . '/vendor/autoload.php';
use Pressjet\Client;
$client = new Client(
apiKey: getenv('PRESSJET_API_KEY'),
baseUrl: 'http://localhost:8080',
);
$invoice = file_get_contents('invoice.pdf');
$terms = file_get_contents('terms.pdf');
if ($invoice === false || $terms === false) {
throw new RuntimeException('Could not read the input PDFs');
}
$packet = $client->merge([$invoice, $terms]);
$signed = $client->sign(
$packet,
'Accounts team',
'Invoice and applicable terms',
new DateTimeImmutable(),
);
file_put_contents('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