Skip to content

Latest commit

 

History

History

README.md

pdf-sdk-java8-okhttp-gson

Requirements

Building the API client library requires Maven to be installed.

Installation

To install the API client library to your local Maven repository, simply execute:

mvn install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn deploy

Refer to the official documentation for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.sphereon.sdk</groupId>
    <artifactId>pdf-sdk-java8-okhttp-gson</artifactId>
    <version>1.1.1</version>
    <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.sphereon.sdk:pdf-sdk-java8-okhttp-gson:1.1.0"

Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

  • target/pdf-sdk-java8-okhttp-gson-1.1.1.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import com.sphereon.sdk.pdf.handler.*;
import com.sphereon.sdk.pdf.handler.auth.*;
import com.sphereon.sdk.pdf.model.*;
import com.sphereon.sdk.pdf.api.Conversion2PDFApi;

import java.io.File;
import java.util.*;

public class Conversion2PDFApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure OAuth2 access token for authorization: oauth2schema
        OAuth oauth2schema = (OAuth) defaultClient.getAuthentication("oauth2schema");
        oauth2schema.setAccessToken("YOUR ACCESS TOKEN");

        Conversion2PDFApi apiInstance = new Conversion2PDFApi();
        String jobid = "jobid_example"; // String | jobid
        File stream = new File("/path/to/file.txt"); // File | The (additional) binary image or PDF (file/inputstream) to convert to PDF
        String fileName = "fileName_example"; // String | Optional input file name.
        try {
            ConversionJobResponse result = apiInstance.addInputFile(jobid, stream, fileName);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling Conversion2PDFApi#addInputFile");
            e.printStackTrace();
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://gw.api.cloud.sphereon.com/pdf/1.1

Class Method HTTP request Description
Conversion2PDFApi addInputFile POST /conversion2pdf/jobs/{jobid}/streams/multipart Upload a file
Conversion2PDFApi addInputStreamLocations POST /conversion2pdf/jobs/{jobid}/streams/location Add Input Stream Location(s)
Conversion2PDFApi createJob POST /conversion2pdf/jobs Create a PDF conversion job
Conversion2PDFApi deleteJob DELETE /conversion2pdf/jobs/{jobid} Delete a job manually
Conversion2PDFApi getJob GET /conversion2pdf/jobs/{jobid} Job definition and state
Conversion2PDFApi getJobs GET /conversion2pdf/jobs Get all jobs
Conversion2PDFApi getStream GET /conversion2pdf/jobs/{jobid}/streams/result Get the current result stream
Conversion2PDFApi submitJob PUT /conversion2pdf/jobs/{jobid} Submit PDF job for processing

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

oauth2schema

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
    • global: accessEverything

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

dev@sphereon.com