DEV Community

Mohammad Rahmeh
Mohammad Rahmeh

Posted on

How to Extract PDF Coordinates for Signature Placement in C# (Without Uploading Your Files)

If you've ever tried to programmatically place a signature box on a PDF using iText7, you know the pain: you need exact llx, lly, urx, ury coordinates β€” and getting them right is a tedious, trial-and-error nightmare.

You either hardcode guesses, write throwaway debug code, or upload your document to some random online tool (and hope it's not storing your sensitive contracts).

There's a better way.


The Problem

iText7 uses a coordinate system with the origin at the bottom-left of the page. That means Y increases upward β€” the opposite of what you see visually on screen.

So when you write something like:

PdfFormField signatureField = PdfFormField.CreateSignature(pdfDoc, new Rectangle(llx, lly, width, height));
Enter fullscreen mode Exit fullscreen mode

...you're flying blind unless you know exactly where those coordinates map to visually on the page.

Eyeballing it? You'll redeploy 10 times before it lands right.


The Workflow That Actually Works

Instead of guessing, here's the approach:

  1. Load your PDF locally in a visual tool
  2. Draw a box exactly where you want the signature
  3. Export the coordinates as llx, lly, urx, ury in PDF point units
  4. Paste them directly into your iText7 code

That's it. One pass. No uploads. No sensitive documents leaving your machine.


The Tool I Built for This

I ran into this problem while building a digital contracts platform at work. I couldn't find a tool that was:

  • Visual and precise
  • Client-side only (no file uploads)
  • Outputting the exact coordinate format iText7 expects

So I built DocCoords β€” a browser-based PDF coordinate extractor.

You load your PDF locally, draw boxes over where signatures or fields should go, and it exports clean JSON:

{
  "pages": [
    {
      "pageNumber": 1,
      "boxes": [
        {
          "llx": 50,
          "lly": 716,
          "urx": 166,
          "ury": 762
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Plug those values directly into your iText7 Rectangle constructor. Done.


Plugging It Into iText7

// Coordinates exported from DocCoords
float llx = 50f;
float lly = 716f;
float urx = 166f;
float ury = 762f;
float width = urx - llx;
float height = ury - lly;

using var pdfDoc = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter("output.pdf"));
var acroForm = PdfAcroForm.GetAcroForm(pdfDoc, true);

var signatureField = PdfFormField.CreateSignature(
    pdfDoc,
    new Rectangle(llx, lly, width, height)
);

signatureField.SetFieldName("client_signature");
acroForm.AddField(signatureField);
Enter fullscreen mode Exit fullscreen mode

No guessing. No redeployments. First try.


Why Client-Side Matters

If you're working with contracts, NDAs, or any legal documents β€” uploading them to a third-party server to get coordinates is a real risk. DocCoords processes everything in your browser. Your PDF never leaves your device.


Try It

πŸ‘‰ doccoords.com β€” free to use, no account needed.

If you're integrating PDF signing in .NET and this saves you time, I'd love to hear how you're using it. Drop a comment or reach out.


Built by a .NET developer, for .NET developers.

Top comments (0)