Developer quickstart

Generate PDFs in Java

Use the Java HTTP client to send JSON data and stream the binary PDF response.

Prerequisites

  • A PDFDesignAPI account and API token.
  • A template UUID with a schema and at least one data binding.
  • Trusted server-side code where the token remains secret.

Generate and save the PDF

var request = HttpRequest.newBuilder()
    .uri(URI.create("https://pdfdesignapi.com/api/v1/generate/single/" + templateUuid))
    .header("Authorization", "Bearer " + apiToken)
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(
        "{"data":{"customer":{"name":"Example BV"}}}"))
    .build();

var response = httpClient.send(
    request,
    HttpResponse.BodyHandlers.ofFile(Path.of("document.pdf")));

if (response.statusCode() < 200 || response.statusCode() >= 300) {
    throw new IOException("PDF generation failed: " + response.statusCode());
}

Production notes

  • Serialize production payloads with the JSON library already used by the application.
  • Configure connection and request timeouts on the shared HTTP client.
  • Use asynchronous jobs when the calling request should not wait for rendering.
Validate payloads →Use async jobs →Create a free account →