Package com.pdfgate

Class PdfGate

java.lang.Object
com.pdfgate.PdfGate

public final class PdfGate extends Object
Client for the PDFGate HTTP API.

Provides synchronous and asynchronous helpers for each endpoint, plus call builders for custom execution. Non-2xx responses are surfaced as PdfGateException with status code and response body details.

  • Constructor Details

    • PdfGate

      public PdfGate(String apiKey)
      Creates a client with the default configuration.
      Parameters:
      apiKey - API key used for authentication.
    • PdfGate

      public PdfGate(String apiKey, PdfGateConfig config)
      Creates a client with a custom configuration.
      Parameters:
      apiKey - API key used for authentication.
      config - configuration for API domains and timeouts.
  • Method Details

    • generatePdf

      public PdfGateDocument generatePdf(GeneratePdfParams params) throws IOException
      Generates a PDF from HTML or a URL and returns a JSON document response.
      Parameters:
      params - parameters for the generate PDF request.
      Returns:
      the generated document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • generatePdfAsync

      public CompletableFuture<PdfGateDocument> generatePdfAsync(GeneratePdfParams params)
      Generates a PDF from HTML or a URL asynchronously and returns a JSON document response.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the generate PDF request.
      Returns:
      a future that completes with the generated document metadata.
    • generatePdfCall

      public CallJson generatePdfCall(GeneratePdfParams params)
      Builds a call that expects a JSON document response.
      Parameters:
      params - parameters for the generate PDF request.
      Returns:
      a call that yields a PdfGateDocument response.
    • flattenPdf

      public PdfGateDocument flattenPdf(FlattenPdfParams params) throws IOException
      Flattens a PDF and returns a JSON document response.

      This SDK currently supports flattening by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the flatten PDF request.
      Returns:
      the flattened document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • flattenPdfAsync

      public CompletableFuture<PdfGateDocument> flattenPdfAsync(FlattenPdfParams params)
      Flattens a PDF asynchronously and returns a JSON document response.

      This SDK currently supports flattening by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the flatten PDF request.
      Returns:
      a future that completes with the flattened document metadata.
    • flattenPdfCall

      public CallJson flattenPdfCall(FlattenPdfParams params)
      Builds a call that expects a JSON document response.

      This SDK currently supports flattening by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the flatten PDF request.
      Returns:
      a call that yields a PdfGateDocument response.
    • protectPdf

      public PdfGateDocument protectPdf(ProtectPdfParams params) throws IOException
      Protects a PDF and returns a JSON document response.

      This SDK currently supports protecting by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the protect PDF request.
      Returns:
      the protected document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • protectPdfAsync

      public CompletableFuture<PdfGateDocument> protectPdfAsync(ProtectPdfParams params)
      Protects a PDF asynchronously and returns a JSON document response.

      This SDK currently supports protecting by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the protect PDF request.
      Returns:
      a future that completes with the protected document metadata.
    • protectPdfCall

      public CallJson protectPdfCall(ProtectPdfParams params)
      Builds a call that expects a JSON document response.

      This SDK currently supports protecting by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the protect PDF request.
      Returns:
      a call that yields a PdfGateDocument response.
    • compressPdf

      public PdfGateDocument compressPdf(CompressPdfParams params) throws IOException
      Compresses a PDF and returns a JSON document response.

      This SDK currently supports compressing by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the compress PDF request.
      Returns:
      the compressed document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • compressPdfAsync

      public CompletableFuture<PdfGateDocument> compressPdfAsync(CompressPdfParams params)
      Compresses a PDF asynchronously and returns a JSON document response.

      This SDK currently supports compressing by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the compress PDF request.
      Returns:
      a future that completes with the compressed document metadata.
    • compressPdfCall

      public CallJson compressPdfCall(CompressPdfParams params)
      Builds a call that expects a JSON document response.

      This SDK currently supports compressing by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the compress PDF request.
      Returns:
      a call that yields a PdfGateDocument response.
    • watermarkPdf

      public PdfGateDocument watermarkPdf(WatermarkPdfParams params) throws IOException
      Applies a watermark to a PDF and returns a JSON document response.

      This SDK currently supports watermarking by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the watermark PDF request.
      Returns:
      the watermarked document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • watermarkPdfAsync

      public CompletableFuture<PdfGateDocument> watermarkPdfAsync(WatermarkPdfParams params)
      Applies a watermark to a PDF asynchronously and returns a JSON document response.

      This SDK currently supports watermarking by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the watermark PDF request.
      Returns:
      a future that completes with the watermarked document metadata.
    • watermarkPdfCall

      public CallJson watermarkPdfCall(WatermarkPdfParams params)
      Builds a call that expects a JSON document response.

      This SDK currently supports watermarking by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the watermark PDF request.
      Returns:
      a call that yields a PdfGateDocument response.
    • createEnvelope

      public PDFGateEnvelope createEnvelope(CreateEnvelopeParams params) throws IOException
      Creates an envelope and returns the envelope metadata response.
      Parameters:
      params - parameters for the create envelope request.
      Returns:
      the created envelope metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • createEnvelopeAsync

      public CompletableFuture<PDFGateEnvelope> createEnvelopeAsync(CreateEnvelopeParams params)
      Creates an envelope asynchronously and returns the envelope metadata response.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the create envelope request.
      Returns:
      a future that completes with the created envelope metadata.
    • createEnvelopeCall

      public CallEnvelope createEnvelopeCall(CreateEnvelopeParams params)
      Builds a call that expects an envelope JSON response.
      Parameters:
      params - parameters for the create envelope request.
      Returns:
      a call that yields a PDFGateEnvelope response.
    • sendEnvelope

      public PDFGateEnvelope sendEnvelope(SendEnvelopeParams params) throws IOException
      Sends an envelope and returns the updated envelope metadata response.
      Parameters:
      params - parameters for the send envelope request.
      Returns:
      the updated envelope metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • sendEnvelopeAsync

      public CompletableFuture<PDFGateEnvelope> sendEnvelopeAsync(SendEnvelopeParams params)
      Sends an envelope asynchronously and returns the updated envelope metadata response.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the send envelope request.
      Returns:
      a future that completes with the updated envelope metadata.
    • sendEnvelopeCall

      public CallEnvelope sendEnvelopeCall(SendEnvelopeParams params)
      Builds a call that expects an envelope JSON response.
      Parameters:
      params - parameters for the send envelope request.
      Returns:
      a call that yields a PDFGateEnvelope response.
    • getEnvelope

      public PDFGateEnvelope getEnvelope(GetEnvelopeParams params) throws IOException
      Retrieves an envelope and returns the envelope metadata response.
      Parameters:
      params - parameters for the get envelope request.
      Returns:
      the envelope metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • getEnvelopeAsync

      public CompletableFuture<PDFGateEnvelope> getEnvelopeAsync(GetEnvelopeParams params)
      Retrieves an envelope asynchronously and returns the envelope metadata response.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the get envelope request.
      Returns:
      a future that completes with the envelope metadata.
    • getEnvelopeCall

      public CallEnvelope getEnvelopeCall(GetEnvelopeParams params)
      Builds a call that expects an envelope JSON response.
      Parameters:
      params - parameters for the get envelope request.
      Returns:
      a call that yields a PDFGateEnvelope response.
    • extractPdfFormData

      public com.google.gson.JsonObject extractPdfFormData(ExtractPdfFormDataParams params) throws IOException
      Extracts PDF form field data and returns the JSON response.

      This SDK currently supports extraction by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the extract form data request.
      Returns:
      the JSON response containing form field data.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • extractPdfFormDataAsync

      public CompletableFuture<com.google.gson.JsonObject> extractPdfFormDataAsync(ExtractPdfFormDataParams params)
      Extracts PDF form field data asynchronously and returns the JSON response.

      This SDK currently supports extraction by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the extract form data request.
      Returns:
      a future that completes with the JSON form data response.
    • extractPdfFormDataCall

      public CallJsonObject extractPdfFormDataCall(ExtractPdfFormDataParams params)
      Builds a call that expects a JSON response containing form field data.

      This SDK currently supports extraction by documentId only. To upload a file directly, use uploadFile(UploadFileParams) first and pass the resulting document ID.

      Parameters:
      params - parameters for the extract form data request.
      Returns:
      a call that yields JSON form field data.
    • getDocument

      public PdfGateDocument getDocument(GetDocumentParams params) throws IOException
      Retrieves document metadata (and optionally a fresh pre-signed URL).
      Parameters:
      params - parameters for the get document request.
      Returns:
      the document metadata response.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • getDocumentAsync

      public CompletableFuture<PdfGateDocument> getDocumentAsync(GetDocumentParams params)
      Retrieves document metadata asynchronously.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the get document request.
      Returns:
      a future that completes with the document metadata.
    • getDocumentCall

      public CallJson getDocumentCall(GetDocumentParams params)
      Builds a call that expects a JSON document response.
      Parameters:
      params - parameters for the get document request.
      Returns:
      a call that yields a PdfGateDocument response.
    • getFile

      public byte[] getFile(GetFileParams params) throws IOException
      Retrieves a stored document file.

      Accessing stored files requires enabling "Save files" in the PDFGate Dashboard settings.

      Parameters:
      params - parameters for the get file request.
      Returns:
      the stored PDF bytes.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • getFileAsync

      public CompletableFuture<byte[]> getFileAsync(GetFileParams params)
      Retrieves a stored document file asynchronously.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the get file request.
      Returns:
      a future that completes with the stored PDF bytes.
    • getFileCall

      public CallFile getFileCall(GetFileParams params)
      Builds a call that expects a raw bytes response.
      Parameters:
      params - parameters for the get file request.
      Returns:
      a call that yields raw PDF bytes.
    • uploadFile

      public PdfGateDocument uploadFile(UploadFileParams params) throws IOException
      Uploads a PDF file passing the file or through a URL pointing to the file and returns a JSON document response.
      Parameters:
      params - parameters for the upload file request.
      Returns:
      the uploaded document metadata.
      Throws:
      PdfGateException - when the request fails or the API returns a non-2xx response.
      IOException
    • uploadFileAsync

      public CompletableFuture<PdfGateDocument> uploadFileAsync(UploadFileParams params)
      Uploads a PDF file passing the file or through a URL pointing to the file and returns a JSON document response.

      The returned future completes exceptionally with PdfGateException on errors.

      Parameters:
      params - parameters for the upload file request.
      Returns:
      a future that completes with the uploaded document metadata.
    • uploadFileCall

      public CallJson uploadFileCall(UploadFileParams params)
      Builds a call that expects a JSON document response.
      Parameters:
      params - parameters for the upload file request.
      Returns:
      a call that yields a PdfGateDocument response.
    • enqueue

      public void enqueue(CallJson call, PdfGateCallback<PdfGateDocument> callback)
      Enqueues a JSON response call and maps the response to PdfGateDocument.
      Parameters:
      call - the call to enqueue.
      callback - the callback for the response.
    • enqueue

      public void enqueue(CallFile call, PdfGateCallback<byte[]> callback)
      Enqueues a bytes response call and returns the raw response bytes.
      Parameters:
      call - the call to enqueue.
      callback - the callback for the response.
    • enqueue

      public void enqueue(CallJsonObject call, PdfGateCallback<com.google.gson.JsonObject> callback)
      Enqueues a JSON response call and maps the response to JsonObject.
      Parameters:
      call - the call to enqueue.
      callback - the callback for the response.
    • enqueue

      public void enqueue(CallEnvelope call, PdfGateCallback<PDFGateEnvelope> callback)
      Enqueues a JSON response call and maps the response to PDFGateEnvelope.
      Parameters:
      call - the call to enqueue.
      callback - the callback for the response.