webPDF Toolbox Description
Technical Minimum Requirements
- Java version: 7
- webPDF version: 7
- wsclient version: 1
Edit Metadata with the webPDF wsclient Library
In this article, we introduce the Description operation of the webPDF toolboxWebService and show how to use it with the webPDF wsclient library.
Important Note
The following coding example is based on the webPDF wsclient library. To understand and apply the example, you should first review the related blog post.
Calling the Webservice
Before we go into the Description operation, you should already have created a REST or SOAP session. Then, using the WebserviceFactory, you create either a ToolboxWebService object for SOAP:
ToolboxWebService toolboxWebService =
WebServiceFactory.createInstance(
session, WebServiceType.TOOLBOX
);
Or a ToolboxRestWebService object for REST:
ToolboxRestWebService toolboxWebService =
WebServiceFactory.createInstance(
session, WebServiceType.TOOLBOX
);
Finally, pass either a RestDocument or a SoapDocument to the WebService object using the setDocument() method.
The Webservice Parameters
To get write access to a document, you usually need to provide the current open and/or permission password of the document to the webservice call.
You can do this directly on the created toolboxWebService object:
toolboxWebService.getPassword().setOpen("password");
toolboxWebService.getPassword().setPermission("password");
If the document is not password protected, you can skip this step.
The Toolbox Webservice
The Toolbox Webservice is an endpoint of your webPDF server that combines a range of operations for directly editing PDF documents. One of these operations is Description. The Description operation allows you to modify various metadata fields of your PDF document.
Add a Description operation to your WebService object like this:
DescriptionType description = new DescriptionType();
toolboxWebService.getOperation().add(description);
The following parameters can be set on the Description object:
allowEmptyValues (default: false)
If this boolean value is set to true, empty values are accepted for the other parameters.
If it is set to false, empty values are not accepted.
description.setAllowEmptyValues(true);
author (default: "")
Sets the document author to the selected value. Multiple authors can be specified by separating them with semicolons.
description.setAuthor("Author1;Author2");
creator (default: "")
Sets the document creator to the selected value.
description.setCreator("Creator");
keywords (default: "")
Sets the document keywords to the selected value. Multiple keywords can be specified by separating them with semicolons.
description.setKeywords("Keyword1;Keyword2;Keyword3");
producer (default: "")
Sets the application used to create the document to the selected value.
description.setProducer("Producer");
subject (default: "")
Sets the subject of the document to the selected value.
description.setSubject("Subject");
title (default: "")
Sets the document title to the selected value.
description.setTitle("Title");
Full Webservice Call
Here is a more detailed example of the full webservice call for the SOAP interface:
try (
// Set up a session with the webPDF server (SOAP in this example):
SoapSession session = SessionFactory.createInstance(
WebServiceProtocol.SOAP,
new URL("https://localhost:8080/webPDF/")
);
// Provide the document to be processed
// and the file to which the result should be written:
SoapDocument soapDocument = new SoapDocument(
new File("Path to the source document").toURI(),
new File("Path to the target document")
)
) catch (ResultException | MalformedURLException ex) {
// Error handling
}
Final Note
More information about the parameters can also be found in our documentation: Description parameter structure. Please also note that all parameters come with default values. If such a value already matches your desired result, it is not necessary to set the parameter explicitly.
More coding examples for webservices that can be used with the wsclient library can be found here.