Developer Guide

How to Sign PDFs with Java

3 steps to sign a PDF with Java: Add the TurboDocx SDK to pom.xml or build.gradle, build a TurboDocxClient with the Builder pattern using your API key, org ID, and sender email, then call client.turboSign().sendSignature() with a request built from recipients and signature fields. TurboDocx emails each recipient a signing link and returns the new document ID.

This guide shows you how to integrate e-signatures into your Spring Boot or Maven project in under 5 minutes.

Last updated: September 23, 2026

5 min

Setup time

Java 11+

LTS support

Builder

Pattern API

1

Installation

Add the TurboDocx SDK to your project using Maven or Gradle.

pom.xml (Maven)
<dependency>
    <groupId>com.turbodocx</groupId>
    <artifactId>turbodocx-sdk</artifactId>
    <version>0.7.0</version>
</dependency>
build.gradle (Gradle)
implementation 'com.turbodocx:turbodocx-sdk:0.7.0'

Requirements: Java 11+. Compatible with Spring Boot, Quarkus, and other frameworks.

2

Obtaining an API Key

Before you begin, you'll need your API credentials from the TurboDocx dashboard.

  1. Sign up for a free account at TurboDocx
  2. Navigate to Settings → API Keys
  3. Copy your API Key and Organization ID
.env or environment
TURBODOCX_API_KEY=your_api_key_here
TURBODOCX_ORG_ID=your_org_id_here
TURBODOCX_SENDER_EMAIL=you@company.com
TURBODOCX_SENDER_NAME=Your Company Name

Spring Boot: The Builder below reads these with System.getenv(). To source them from application.properties instead, bind them with @Value and pass the resolved strings to the Builder.

3

Sending a Signing Request

Use the SDK to send a document for signature. The recipient will receive an email with a link to sign.

Main.java
import com.turbodocx.TurboDocxClient;
import com.turbodocx.models.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Create client with sender configuration
        TurboDocxClient client = new TurboDocxClient.Builder()
            .apiKey(System.getenv("TURBODOCX_API_KEY"))       // REQUIRED
            .orgId(System.getenv("TURBODOCX_ORG_ID"))         // REQUIRED
            .senderEmail(System.getenv("TURBODOCX_SENDER_EMAIL"))  // REQUIRED
            .senderName(System.getenv("TURBODOCX_SENDER_NAME"))    // Recommended
            .build();

        // Read PDF file
        byte[] pdfFile = Files.readAllBytes(Paths.get("contract.pdf"));

        // Send document for signature
        SendSignatureResponse result = client.turboSign().sendSignature(
            new SendSignatureRequest.Builder()
                .file(pdfFile)
                .fileName("contract.pdf")
                .documentName("Partnership Agreement")
                .recipients(Arrays.asList(
                    new Recipient("John Doe", "john@example.com", 1)
                )))
                .fields(Arrays.asList(
                    new Field.Builder()
                        .type("signature")
                        .recipientEmail("john@example.com")
                        .template(new Field.TemplateAnchor.Builder()
                            .anchor("{signature1}")
                            .placement("replace")
                            .size(new Field.Size(100, 30))
                            .build())
                        .build()
                )))
                .build()
        );

        System.out.println("Document ID: " + result.getDocumentId());
    }
}

Builder Pattern: The SDK uses fluent builders like new Field.Builder()...build() for type-safe request construction.

4

Processing Results with Webhooks

Configure webhooks to receive real-time notifications when documents are signed. Verify the X-TurboDocx-Signature header with WebhookSignatureVerifier.verify() against the raw request bytes before trusting a payload.

WebhookController.java (Spring Boot)
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.turbodocx.WebhookSignatureVerifier;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;

@RestController
@RequestMapping("/webhooks")
public class WebhookController {

    private final TurboDocxClient client;
    private final ObjectMapper mapper = new ObjectMapper();

    @PostMapping("/turbosign")
    public ResponseEntity<Map<String, Boolean>> handleWebhook(
            @RequestBody byte[] rawBody,
            @RequestHeader("X-TurboDocx-Signature") String signature,
            @RequestHeader("X-TurboDocx-Timestamp") String timestamp
    ) throws Exception {
        if (!WebhookSignatureVerifier.verify(rawBody, signature, timestamp, System.getenv("TURBODOCX_WEBHOOK_SECRET"))) {
            return ResponseEntity.status(401).body(Map.of("error", true));
        }

        Map<String, Object> payload = mapper.readValue(rawBody, Map.class);
        String event = (String) payload.get("event");
        Map<String, Object> data = (Map<String, Object>) payload.get("data");

        if ("signature.document.completed".equals(event)) {
            String documentId = (String) data.get("document_id");

            // Download the signed PDF
            byte[] signedPdf = client.turboSign().download(documentId);

            // Save to file
            Files.write(
                Paths.get("signed-" + documentId + ".pdf"),
                signedPdf
            );
        }

        return ResponseEntity.ok(Map.of("received", true));
    }
}
5

Conclusion

You now have everything you need to integrate document signing into your Java application using the TurboDocx e-signature API. The Builder-style SDK handles authentication, document delivery, signature collection, and legally-binding audit trails behind a typed client.

What you can do next:

  • Add multiple recipients with sequential signing order
  • Use different field types: initials, dates, text, checkboxes
  • Integrate with Spring Security for authentication
  • Get audit trails and compliance certificates

Related Guides

Resources

Frequently Asked Questions

How do I sign a PDF with Java?

Add the TurboDocx SDK to your Maven/Gradle project, create a client with your API key using the Builder pattern, then use client.turboSign().sendSignature() to send the document for e-signature.

Is there a Java digital signature SDK on Maven Central?

Yes. com.turbodocx:turbodocx-sdk is published on Maven Central and built with fluent Builders, so Spring Boot and Quarkus services get type-safe recipients and signature fields instead of writing raw HTTP or multipart upload code.

Does the Java SDK work with Spring Boot?

Yes, the TurboDocx Java SDK works with Spring Boot, Quarkus, and any Java 11+ application. It uses fluent Builder pattern for type-safe request construction.

What Java version is required?

The TurboDocx Java SDK requires Java 11 or higher (LTS versions recommended).

Ready to Get Started?

Create a free account and get your API key. Start sending documents for signature in minutes.