The PDF conversion API 'conversion2pdf' converts image, office and PDF files to (searcheable) PDF files. The flow is generally as follows: 1. First create a job using the /conversion2pdf/jobs POST endpoint. You will get back a job response that contains a job with its associated settings. 2. Upload one or more images/files using the /conversion2pdf/jobs/{jobId}/streams/multipart POST endpoint. You can also add stream locations from the storage API . You will get back the update job response that contains a job with its associated settings. Currently you can only merge spreadsheets with spreadsheet, documents with documents and images/pdfs with images/pdfs 3. Start the job from a PUT request to the /conversion2pdf/jobs/{jobid} endpoint, with the Job and Settings JSON as request body. The conversion to PDF will now start. The OCR setting is only applicable to images, since other files will always be searchable. 4. Check the job status from the /conversion2pdf/jobs/{jobid} GET endpoint until the status has changed to DONE or ERROR. Messaging using a websocket will be available as an alternative in a future version 5. Retrieve the PDF file using the /conversion2pdf/jobs/{jobid}/streams/result GET endpoint. This will return the PDF file only when the status is DONE. In other cases it will return the Job Response JSON (with http code 202 instead of 200) Interactive testing: A web based test console is available in the <a href="https://store.sphereon.com\">Sphereon API Store
This C# SDK is automatically generated by the Swagger Codegen project:
- API version: 1.1
- SDK version: 1.1.1
- Build package: io.swagger.codegen.languages.CSharpClientCodegen For more information, please visit https://sphereon.com
- .NET 4.0 or later
- Windows Phone 7.1 (Mango)
The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742
Run the following command to generate the DLL
- [Mac/Linux]
/bin/sh build.sh - [Windows]
build.bat
Then include the DLL (under the bin folder) in the C# project, and use the namespaces:
using Sphereon.SDK.Pdf.Api;
using Sphereon.SDK.Pdf.Client;
using Sphereon.SDK.Pdf.Model;A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.
This .nuspec uses placeholders from the .csproj, so build the .csproj directly:
nuget pack -Build -OutputDirectory out Sphereon.SDK.Pdf.csproj
Then, publish to a local feed or other host and consume the new package via Nuget as usual.
using System;
using System.Diagnostics;
using Sphereon.SDK.Pdf.Api;
using Sphereon.SDK.Pdf.Client;
using Sphereon.SDK.Pdf.Model;
namespace Example
{
public class Example
{
public void main()
{
// Configure OAuth2 access token for authorization: oauth2schema
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new Conversion2PDFApi();
var jobid = jobid_example; // string | jobid
var stream = new System.IO.Stream(); // System.IO.Stream | The (additional) binary image or PDF (file/inputstream) to convert to PDF
var fileName = fileName_example; // string | Optional input file name. (optional)
try
{
// Upload a file
ConversionJobResponse result = apiInstance.AddInputFile(jobid, stream, fileName);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling Conversion2PDFApi.AddInputFile: " + e.Message );
}
}
}
}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 |
- Model.CSVSettings
- Model.Compression
- Model.ConversionJob
- Model.ConversionJobResponse
- Model.ConversionSettings
- Model.ConversionTask
- Model.ConversionTaskInput
- Model.Error
- Model.ErrorResponse
- Model.InputResponse
- Model.InputSettings
- Model.Lifecycle
- Model.ResultResponse
- Model.ResultSettings
- Model.StorageLocation
- Model.StreamLocation
- Type: OAuth
- Flow: application
- Authorization URL:
- Scopes:
- global: accessEverything