SDK npm package is not published yet and API environments may be unavailable.View status
Guide · Ananke TCode

Stamp a PDF

Upload a PDF, configure barcode placement, apply an Ananke TCode stamp, and download the result. Covers quality constraints and testing guidance.

Use case

You have a finalized PDF (invoice, certificate, report) and you want to embed an Ananke TCode DataMatrix barcode into it. The barcode makes the document scannable for verification.

Prerequisites

  • An active Ananke Labs tenant with an API key
  • A finalized PDF file (no further edits after stamping)
  • The SDK installed or an HTTP client available

1. Prepare the PDF

Ensure the PDF is complete. Any modification after stamping will invalidate the content hash. If you need to make edits, do so before stamping.

  • Use high-resolution sources (300 DPI or higher recommended)
  • Leave space for the barcode — typically a corner or margin area
  • Avoid watermarking the PDF after stamping

2. Configure placement (optional)

Create a placement template if the default barcode position doesn't work for your document layout:

Create a placement template
const placement = await client.tcode.placementTemplates.create({
  name:      "Bottom-right corner",
  positionX: 450,
  positionY: 50,
  width:     100,
  height:    100,
  page:      "last",
});

// Use this placement template for all invoices
const placementId = placement.id;

3. Stamp the document

SDK — Stamp with placement template
import { readFileSync } from "node:fs";

const stamp = await client.tcode.documents.stamp({
  name:                 "Invoice #1234",
  documentTypeCode:     "INV",
  placementTemplateId:  placementId,  // optional
  pdf:                  readFileSync("./invoice.pdf"),
});

console.log(stamp.reference);  // "TCR-XXXX"

4. Download the result

Download the stamped PDF
import { writeFileSync } from "node:fs";

const stampedPdf = await client.tcode.documents.download(stamp.id);
writeFileSync("./invoice-stamped.pdf", stampedPdf);

Open the downloaded PDF and confirm the barcode is visible and correctly positioned.

5. Print and test

Before deploying to production:

  1. Print the stamped PDF at the intended output size.
  2. Scan the barcode with a mobile phone camera or dedicated barcode reader.
  3. Confirm the scan decodes correctly and the verification endpoint returns valid.
  4. Test with at least 2–3 different scanner apps / devices.
  5. Test photocopied versions — high-contrast barcodes survive copying better.

Quality constraints

ConstraintRecommendation
Minimum barcode size15mm × 15mm for reliable scanning
Quiet zoneAt least 2mm of white space around the barcode
Print resolution300 DPI or higher
ContrastBlack barcode on white background (avoid colour overlays)
PlacementAvoid folding zones, staple areas, or high-wear regions

Next steps