webPDF Toolbox Description

Minimum technical requirements

  • Java version: 7
  • webPDF version: 7
  • wsclient version: 1

Edit Metadata with the webPDF wsclient Library

In this article we would like to introduce the Description Operation of the webPDF toolboxWebService. Here we show you how to use our webPDF wsclient library.

Important note:

The following coding example is based on the use of the webPDF wsclient library. In order to understand and apply the example, the following blog post should be considered first:

webPDF and Java: very easy with the “wsclient” library

Webservice Call

Before we go into the Description operation, you should have already created a REST or SOAP session. After that, either a ToolboxWebService object (for a SOAP session) is created by calling the WebserviceFactory..

ToolboxWebService toolboxWebService =
    WebServiceFactory.createInstance(
        session, WebServiceType.TOOLBOX
    );

..or a ToolboxRestWebService object (for a REST session):

ToolboxRestWebService toolboxWebService =
    WebServiceFactory.createInstance(
        session, WebServiceType.TOOLBOX
    );

Finally, either a RestDocument or a SoapDocument object is passed to the WebService object by calling the method setDocument().

The webservice parameters

Just to get changing access to a document, you usually have to give the current open and/or permission password of the document to the webservice call.

You can do this directly at the created toolboxWebService object:

toolboxWebService.getPassword().setOpen("password");
toolboxWebService.getPassword().setPermission("password");

(Note: If the document does not have the appropriate password protection, you can skip this point.)

The Toolbox Webservice

The Toolbox Webservice is an endpoint of your webPDF server that summarizes a number of operations with which you can directly customize your PDF document. One of these operations is the Description operation. The Description operation allows you to modify various meta-informations of your PDF document.

You add a Description operation to your WebService object as follows:

DescriptionType description = new DescriptionType();
toolboxWebService.getOperation().add(description);

The following parameters can be set on the Description object:

allowEmptyValues (default value: 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 value: „“)

Sets the author of the document to the selected value. Multiple authors can be specified by separating with a semicolon.

description.setAuthor("Author1;Author2");

creator (default value: „“)

Sets the creator of the document to the selected value.

description.setCreator("Creator");

keywords (default value: „“)

Sets the keywords of the document to the selected value. You can specify several keywords by separating them with a semicolon.

description.setKeywords("Keyword1;Keyword2;Keyword3");

producer (default value: „“)

Sets the application used to create the document to the selected value.

description.setProducer("Producer");

subject (default value: „“)

Sets the theme of the document to the selected value.

description.setSubject("Subject");

title (default value: „“)

Sets the title of the document to the selected value.

description.setTitle("Title");

Entire Webservice Call

We want to give you a more detailed example for the entire webservice call (for addressing the SOAP interface):

try (
    // Setup of a session with the webPDF server (here SOAP):
    SoapSession session = SessionFactory.createInstance(
        WebServiceProtocol.SOAP,
        new URL("https://localhost:8080/webPDF/")
    );
    // Make available the document to be processed 
   // and the file to which the result is to be written:
    SoapDocument soapDocument = new SoapDocument(
        new File("Pfad des Quelldokuments").toURI(),
        new File("Pfad des Zieldokuments")
    )
) {
    // Selection of the webservice via a factory:
    ToolboxWebService toolboxWebService =
        WebServiceFactory.createInstance(
            session, WebServiceType.TOOLBOX
        );
    toolboxWebService.setDocument(soapDocument);
    toolboxWebService.getPassword().setOpen("password");
    toolboxWebService.getPassword().setPermission("password");

    // Object-oriented parameterization of the call:
    DescriptionType description = new DescriptionType();
    toolboxWebService.getOperation().add(description);

    description.setAllowEmptyValues(true);
    description.setAuthor("Author1;Author2");
    description.setCreator("Creator");
    description.setKeywords("Keyword1;Keyword2;Keyword3");
    description.setProducer("Producer");
    description.setSubject("Subject");
    description.setTitle("Title");

    // execution.
    toolboxWebService.process();
} catch (ResultException | MalformedURLException ex) {
    // For the evaluation of possible errors
    // the wsclient library provides corresponding methods:
}

Final note:

You can also find more information about the parameters in our user manual: description parameter structure. Please also note: All parameters are preset with certain default values. If such a value is specified and does not deviate from your desired value, then it is not necessary to set this parameter.

More coding examples for webservices that you can use with the ws-client library can be found here.