The Java SDK provides a client for integrating PDFGate API endpoints into your applications.
Source code: github.com/pdfgate/pdfgate-sdk-java
Package: central.sonatype.com/artifact/com.pdfgate/pdfgate
The SDK is published to Maven Central under com.pdfgate:pdfgate. Add the dependency to Gradle or Maven, then initialize the client with your API key.
1implementation "com.pdfgate:pdfgate:0.1.0"1<dependency>2 <groupId>com.pdfgate</groupId>3 <artifactId>pdfgate</artifactId>4 <version>0.1.0</version>5</dependency>The example below generates a PDF from HTML, retrieves the stored file bytes, and writes the output to disk.
1import com.pdfgate.GeneratePdfParams;2import com.pdfgate.GetFileParams;3import com.pdfgate.PdfGate;4import com.pdfgate.PdfGateDocument;5import java.io.IOException;6import java.nio.file.Files;7import java.nio.file.Path;8import java.nio.file.Paths;910public class PdfGateExample {11 static void main(String[] args) {12 String apiKey = "test_123";13 PdfGate client = new PdfGate(apiKey);1415 try {16 GeneratePdfParams params = GeneratePdfParams.builder()17 .html("<html><body><h1>Hello, PDFGate!</h1></body></html>")18 .build();1920 PdfGateDocument document = client.generatePdf(params);2122 Path filePath = Paths.get("output.pdf");23 byte[] fileBytes = client.getFile(GetFileParams.builder()24 .documentId(document.getId())25 .build());26 Files.write(filePath, fileBytes);27 } catch (IOException e) {28 System.err.println("Error writing to file: " + e.getMessage());29 }30 }31}The SDK exposes synchronous methods, Async variants based on CompletableFuture, and callback-style methods with a Call suffix.
1PdfGateDocument document = client.generatePdf(params);23CompletableFuture<PdfGateDocument> pdfFileFuture = client.generatePdfAsync(params);45CallJson call = client.generatePdfCall(params);| Method | Purpose |
|---|---|
generatePdf | Generate a PDF from HTML or a URL. |
getDocument | Retrieve document metadata and processing details. |
getFile | Download the stored PDF bytes for a document id. |
uploadFile | Upload a PDF from bytes or by public URL. |
flattenPdf | Flatten form fields into a non-editable document. |
compressPdf | Compress a PDF and return the resulting document record. |
watermarkPdf | Apply an image or text watermark to a PDF. |
protectPdf | Encrypt a PDF and apply access restrictions. |
extractPdfFormData | Read submitted values from fillable PDF forms. |
Use the SDK together with the main API documentation for endpoint behavior, request parameters, and workflow guides such as webhooks and PDF form fields.