Docs

Java SDK

Use com.relaypdf:relaypdf on Java 17+ when you want the official client instead of raw HttpClient. Request JSON field names match REST; methods are camelCase. The README is the full method and error reference.

The official Java SDK uses java.net.http.HttpClient and Jackson. Field names in request bodies match REST. Methods are camelCase.

Installation

Requires Java 17+. Until Maven Central publish, mvn -f sdks/java/pom.xml install.

Maven
<dependency>
  <groupId>com.relaypdf</groupId>
  <artifactId>relaypdf</artifactId>
  <version>0.1.0</version>
</dependency>

Quick start

apiKey is required. Load RELAYPDF_API_KEY from the environment.

App.java
import com.relaypdf.RelayPDF;
import com.relaypdf.BinaryResult;

RelayPDF client = new RelayPDF(System.getenv("RELAYPDF_API_KEY"));
BinaryResult pdf = (BinaryResult) client.pdf.fromHtml(
    "<h1>Invoice #1042</h1><p>Total: $1,200.00</p>",
    Map.of("filename", "invoice.pdf")
);
pdf.save("invoice.pdf");

Errors and webhooks

Failures throw RelayPDFException. Webhook.verify checks RelayPDF-Signature against the raw body.

errors / webhooks
try {
    client.pdf.fromUrl("https://example.com");
} catch (RelayPDFException err) {
    System.out.println(err.getStatus() + " " + err.getCode() + " " + err.getMessage());
}

boolean ok = Webhook.verify(
    System.getenv("RELAYPDF_WEBHOOK_SECRET"),
    rawBody,
    signatureHeader
);

SDK reference

Pass Map extra arguments for REST camelCase fields. file values may be byte[] or a data: URL.

MethodHTTPDescription
health() / account()GET /health · /v1/accountLiveness and wallet
pdf.fromHtml / fromUrl / fromMarkdown / fromTemplatePOST /v1/pdfGenerate PDF
pdf.mergePdfs / extract / protect / … / formFillPOST /v1/pdf/*PDF tools
images / convert / templates / barcodes / zip / jobs / files / webhooksmatching RESTSame surface as Node
Webhook.verifyRelayPDF-SignatureHMAC-SHA256