Back to blog
API GuideFebruary 01, 20256 min read

How to Detect Signatures in PDFs: The Developer's Guide to Automating Verification

Stop checking every page manually. Learn how to use Vision AI to automatically detect signatures, enforce compliance, and build audit-proof verification workflows.

Introduction

Verifying if a contract, application, or form has been signed is one of the most tedious tasks in document processing. For developers, it's also one of the hardest to automate.

Why? Because signatures aren't text. They are images—scribbles, curves, and stamps—that live on top of the document. This guide explores why traditional methods fail and how to implement a robust Vision AI solution that "sees" signatures just like a human reviewer does.

Why Text Search Fails at Signatures

If you've tried to automate this before, you've probably tried OCR (Optical Character Recognition) or keyword searching. You might look for the word "Signed" or "Signature".

Here is why that breaks:

  • The "Empty Line" Problem: Finding the text "Signature:" doesn't tell you if someone actually signed next to it.
  • False Positives: A blank form still contains the word "Signature". A text search says "Found!", but the document is unsigned.
  • Unpredictable Layouts: Signatures drift. They overlap text. They float in margins. Strict coordinate-based zoning breaks as soon as a scanner shifts the page by 5mm.

To solve this, you need to stop reading text and start detecting objects.

The Solution: Vision AI

Vision AI models (like the ones powering Ninjadoc's API) are trained on millions of document samples to recognize the visual characteristics of signatures. They don't just look for the word "Signature"—they look for the ink strokes, the cursive patterns, and the visual density that indicates a signature.

This allows you to answer the critical question: "Is there a signature on page 3?" with a confidence score and exact coordinates, regardless of where it is placed.

Step 1: Detect Signatures (The Request)

The API is simple: send a PDF, get back a JSON list of every signature found. Here is a standard Node.js implementation.

Detect Signatures Request

const formData = new FormData();
// In Node.js, assuming you have the file as a buffer or stream
formData.append('document_file', fileStream, 'contract.pdf');

const response = await fetch('https://ninjadoc.ai/api/signature-detection', {
  method: 'POST',
  headers: { 
    'X-API-Key': process.env.NINJADOC_API_KEY 
  },
  body: formData
});

const result = await response.json();

// Output:
// {
//   "signature_items": [
//     {
//       "bbox": [100, 200, 300, 200, 300, 250, 100, 250],
//       "page": 1,
//       "confidence": 0.98
//     }
//   ],
//   "page_metadata": { ... }
// }

Step 2: Verification Logic

Detection is only half the battle. You need business logic to decide if a document is "valid." Below is a robust verification function that filters low-confidence results and checks specific pages.

Verification Logic Function

async function verifyDocument(fileStream) {
  const formData = new FormData();
  formData.append('document_file', fileStream);

  // 1. Get detection results
  const response = await fetch('https://ninjadoc.ai/api/signature-detection', {
    method: 'POST',
    headers: { 'X-API-Key': process.env.NINJADOC_API_KEY },
    body: formData
  });
  
  const { signature_items } = await response.json();

  // 2. Define your acceptance criteria
  const MIN_CONFIDENCE = 0.85;
  const REQUIRED_PAGES = [3]; // e.g., signature required on last page

  // 3. Validate
  const validSignatures = (signature_items || [])
    .filter(sig => sig.confidence >= MIN_CONFIDENCE);

  const isSigned = validSignatures.length > 0;
  
  // Check if specific pages are signed
  const signedPages = new Set(validSignatures.map(s => s.page));
  const hasRequiredSignatures = REQUIRED_PAGES.every(p => signedPages.has(p));

  return {
    verified: isSigned && hasRequiredSignatures,
    signatureCount: validSignatures.length,
    details: validSignatures
  };
}

Pro Tip: Always use a confidence threshold (e.g., 0.85). Vision models are probabilistic; setting a threshold eliminates noise and ensures you only act on high-certainty detections.

Visual Proof & Auditing

One of the biggest advantages of this approach is Auditability. Because the API returns a bbox (Bounding Box), you can draw a rectangle on the UI to show your users exactly what the AI found.

This builds trust. Instead of a black-box "Verified" checkmark, you can show the document with a green box around the signature. If the AI makes a mistake, the user sees it immediately.

Why Coordinates Matter:

  • Human-in-the-loop: Speed up manual review by auto-scrolling to the signature location.
  • Multi-signature validation: checks if signatures exist in specific regions (e.g., distinct "Buyer" and "Seller" zones).
  • Redaction validation: Ensure signatures aren't accidentally covered up.

Vision AI vs. Standard OCR

Here is a quick breakdown of why developers switch from OCR to Vision AI for this specific task.

MethodHow it worksThe Failure Mode
Keyword Search (OCR)Finds text "Signed By:"Detects the label, not the signature. Can't verify if signed.
Zonal OCRLooks at fixed (x,y) coordinatesBreaks if scan is tilted, zoomed, or shifted.
Vision AIDetects visual ink patternsRobust to shifts, missing labels, and messy scans.

Pricing & Scalability

Enterprise document AI often comes with massive upfront contracts. We prefer a simple developer-friendly model.

  • 2 Credits per page processed.
  • Credits never expire.
  • No monthly minimums.

1 USD = 250 credits This means verifying a 50-page contract costs 100 credits (approx. 0.4 USD).

Frequently Asked Questions

Does this detect digital signatures (pki)?

This API is designed for **visual** signature detection—handwritten scribbles, wet ink signatures scanned into PDFs, and printed signature blocks. It does not validate cryptographic digital signatures (like those from DocuSign metadata), but it verifies the *visual presence* of a signature on the page, which is often verified manually.

What types of signatures does it detect?

It detects three main categories: **handwritten signatures** (cursive, ink), **printed signatures** (script fonts, stamped names), and **signature blocks** (the lines and text indicating where to sign).

Can I filter by confidence score?

Yes. Every detected signature comes with a confidence score (0.0 to 1.0). We recommend setting a threshold (e.g., 0.85) to filter out noise or uncertain marks, as shown in the verification logic example.

What happens if a document has multiple signatures?

The API returns an array of all detected signatures. You can iterate through them to check if all required parties have signed (e.g., ensuring there is a signature on the 'Tenant' line and another on the 'Landlord' line using coordinate checks).

Automate Your Document Verification

Stop manually reviewing every page. Use Vision AI to detect signatures with 99% availability and strict data privacy.

  • No Credit Card Required
  • Visual coordinate overlay for auditability

Start with free credits. No credit card required for testing.