REST Web Service API
The webPDF server provides its functions as REST web services.
All REST web services can be accessed via the base URL
http://localhost:8080/webPDF/rest.
Replace the host name (including the protocol and port if applicable) with the address of your installed webPDF server.
The Hypertext Transfer Protocol (HTTP) is used to call the functions, the structure and functionality of which is considered the basis for the use of REST web services.
The REST web services can be categorized into four groups based on the base URL.
Administration
Retrieve the server settings and customize the configuration: /administration/...
Access to this web service API requires authorization with administrative rights.
Authentication
Login to the server and create a authorized session: /authentication/...
Document storage
Manage documents in the session: /documents/...
Operations
Perform PDF operations on the documents in the session.
Currently there are seven operations for executing the server's PDF operations.
-
/converter/...- Conversion of documents into PDF format ( API {REST} ) -
/signature/...- Digitally sign PDF documents ( API {REST} ) -
/pdfa/...- Convert PDF documents to PDF/A and validate existing PDF/A documents ( API {REST} ) -
/toolbox/...- Processing of existing PDF documents with operations such as splitting, encryption, graphics export or printing ( API {REST} ) -
/urlconverter/...- Conversion of HTML content retrieved via a URL into PDF documents ( API {REST} ) -
/ocr/...- Optical character recognition (OCR) of documents that are available as graphics and conversion into resolved PDF documents ( API {REST} ) -
/barcode/...- Recognition and generation of barcodes in PDF documents ( API {REST} )
In summary, all web services form the REST API of the webPDF server.
The technical documentation and listing of the REST API as OpenAPI can be found online on our server at https://portal.webpdf.de/webPDF/help/restful/ or the (local) installed webPDF server at http://localhost:8080/webPDF/help/restful/.
The endpoints (resources) of the webPDF server are addressed via Uniform Resource Identifier (URI) in the REST API. The various URIs of the web services can contain parameters such as {documentId} to address a specific document and perform an operation on that document.
Depending on the endpoint, various HTTP methods, such as GET or POST, are available to trigger an action at the endpoint.
Example: Action (GET) "Read the document information" at the /documents/{documentId}/info endpoint for the document with the {documentId} = 26fe0636b6044c2aa0cbfeb1fd5a795e.
GET http://localhost:8080/webPDF/rest/documents/26fe0636b6044c2aa0cbfeb1fd5a795e/info
The endpoint responds with a JSON structure, which can look like this, for example:
{
"documentId": "26fe0636b6044c2aa0cbfeb1fd5a795e",
"parentDocumentId": "",
"fileSize": 12703,
"mimeType": "image/jpg",
"fileName": "sample",
"fileExtension": "jpg",
"fileTypeId": 1535,
"fileTypeGroups": "IMAGE",
"fileLastModified": "Tue, 04 Aug 2020 07:33:34 GMT",
"isFileLocked": false,
"metadata": {},
"error": {
"errorMessage": "No error",
"errorCode": 0,
"stackTrace": ""
}
}
Responses and passing parameters
The data exchange of the REST web services with the client application, i.e. the control of the web services with parameters or the return of information (see previous GET example) in response to a REST web service, is done via JSON (JavaScript Object Notation) data structures.
In the JSON data structures (objects), the execution and behavior of the web services can be controlled or information can be retrieved by the individual elements and parameters with values.
Calling clients should therefore set the HTTP headers
- "Content-Type" and
- "Accept"
to application/json in the requests.
Content-Type: application/json
Accept: application/json
For POST /documents (document upload) Content-Type: multipart/form-data must be set.
The corresponding JSON structure is passed in the "request body" as the “payload” of the HTTP method (e.g. POST). If a corresponding HTTP method (e.g. GET) returns a response as a JSON structure, this is included in the response body.
Example of calling the converter web service with POST and...
POST http://localhost:8080/webPDF/rest/converter/26fe0636b6044c2aa0cbfeb1fd5a795e
...the corresponding parameters in the payload.
{
"converter": {
"pages": "*",
"accessPassword": "xyz",
"compression": true,
"dpi": 300,
"embedFonts": true,
"jpegQuality": 90,
"reduceResolution": true
}
}
The best way to track the usage of the REST API is in the webPDF portal, using the appropriate browser debugger (can be accessed in most browsers using the F12 hotkey) to track the calls.
All operations and related parameters are described in the REST API.