Package com.pdftools

Class Sdk


public class Sdk extends NativeObject

SDK initialization and product information

  • Method Details

    • initialize

      public static void initialize(String license) throws LicenseException, UnknownFormatException, CorruptException, HttpException

      Initialize the product and the license key.

      Before calling any of the other functions of the SDK, a license key must be set by calling this method. For licensing questions, contact pdfsales@pdftools.com.
      Parameters:
      license - The license key. The format of the license key is "<PDFSDK,V1,...>"
      Throws:
      UnknownFormatException - The format (version) of the license argument is unknown.
      CorruptException - The license argument is not a correct license key.
      LicenseException - The license argument can be read but the license check failed.
      HttpException - A network error occurred.
      IllegalArgumentException - if license is null
    • initialize

      public static void initialize(String license, String producerSuffix) throws LicenseException, UnknownFormatException, CorruptException, HttpException

      Initialize the product and the license key.

      Before calling any of the other functions of the SDK, a license key must be set by calling this method. For licensing questions, contact pdfsales@pdftools.com.
      Parameters:
      license - The license key. The format of the license key is "<PDFSDK,V1,...>"
      producerSuffix - If neither null nor empty, this string is appended to the producer string within metadata of PDF output documents (see getProducerFullName()).
      Throws:
      UnknownFormatException - The format (version) of the license argument is unknown.
      CorruptException - The license argument is not a correct license key.
      LicenseException - The license argument can be read but the license check failed.
      HttpException - A network error occurred.
      IllegalArgumentException - if license is null
    • addFontDirectory

      public static void addFontDirectory(String directory) throws NotFoundException

      Add custom font directory

      Parameters:
      directory - The path of the directory which contains additional font files to be considered during processing.
      Throws:
      NotFoundException - The given directory path does not exist.
      IllegalArgumentException - if directory is null
    • getVersion

      public static String getVersion()

      The version of the SDK (Getter)

    • setProducerSuffix

      public static void setProducerSuffix(String value)

      The suffix for the producer (Setter)

      Suffix that is appended to the producer string within metadata of PDF output documents (see getProducerFullName()).
    • getProducerFullName

      public static String getProducerFullName()

      The producer string that is set within the metadata of PDF output documents (Getter)

      The producer string depends on the license key and producer suffix set in initialize(java.lang.String).
    • getProxy

      public static URI getProxy()

      Proxy to use for all communication to remote servers (Getter)

      The SDK can use a proxy for all HTTP and HTTPS communication.

      The default is null, i.e. no proxy is used. Otherwise the property’s value must be a URI with the following elements:

      http[s]://[‹user›[:‹password›]@]‹host›[:‹port›]

      Where:

      • http/https: Protocol for connection to proxy.
      • ‹user›:‹password› (optional): Credentials for connection to proxy (basic authorization).
      • ‹host›: Hostname of proxy.
      • ‹port›: Port for connection to proxy.

      Example: "http://myproxy:8080"

      For SSL/TLS connections, e.g. to a signature service, the proxy must allow the HTTP CONNECT request to the remote server.

    • setProxy

      public static void setProxy(URI value)

      Proxy to use for all communication to remote servers (Setter)

      The SDK can use a proxy for all HTTP and HTTPS communication.

      The default is null, i.e. no proxy is used. Otherwise the property’s value must be a URI with the following elements:

      http[s]://[‹user›[:‹password›]@]‹host›[:‹port›]

      Where:

      • http/https: Protocol for connection to proxy.
      • ‹user›:‹password› (optional): Credentials for connection to proxy (basic authorization).
      • ‹host›: Hostname of proxy.
      • ‹port›: Port for connection to proxy.

      Example: "http://myproxy:8080"

      For SSL/TLS connections, e.g. to a signature service, the proxy must allow the HTTP CONNECT request to the remote server.

    • getHttpClientHandler

      public static HttpClientHandler getHttpClientHandler()

      The default handler for communication to remote servers (Getter)

      This instance is used wherever there is no dedicated HTTP client handler parameter.
    • getUsageTracking

      public static boolean getUsageTracking()

      Property denoting whether the usage tracking is enabled or disabled (Getter)

      The SDK is allowed to track usage when this property is set to true. The collected data includes only non-sensitive information, such as the features used, the document type, the number of pages, etc.

      The default is true, i.e. usage tracking is enabled.

    • setUsageTracking

      public static void setUsageTracking(boolean value)

      Property denoting whether the usage tracking is enabled or disabled (Setter)

      The SDK is allowed to track usage when this property is set to true. The collected data includes only non-sensitive information, such as the features used, the document type, the number of pages, etc.

      The default is true, i.e. usage tracking is enabled.

    • getLicensingService

      public static URI getLicensingService()

      Licensing service to use for all licensing requests (Getter)

      This property is relevant only for page-based licenses and is used to set the Licensing Gateway Service.

      The default is "https://licensing.pdf-tools.com/api/v1/licenses/" for the online Pdftools Licensing Service. If you plan to use the Licensing Gateway Service instead of the Pdftools Licensing Service, the property’s value must be a URI with the following elements:

      http[s]://[‹user›[:‹password›]@]‹host›[:‹port›]

      Where:

      • http/https: Protocol for connection to the Licensing Gateway Service.
      • ‹user›:‹password› (optional): Credentials for connection to the Licensing Gateway Service (basic authorization).
      • ‹host›: Hostname of the Licensing Gateway Service.
      • ‹port›: Port for connection to the Licensing Gateway Service.

      Example: "http://localhost:9999"

    • setLicensingService

      public static void setLicensingService(URI value)

      Licensing service to use for all licensing requests (Setter)

      This property is relevant only for page-based licenses and is used to set the Licensing Gateway Service.

      The default is "https://licensing.pdf-tools.com/api/v1/licenses/" for the online Pdftools Licensing Service. If you plan to use the Licensing Gateway Service instead of the Pdftools Licensing Service, the property’s value must be a URI with the following elements:

      http[s]://[‹user›[:‹password›]@]‹host›[:‹port›]

      Where:

      • http/https: Protocol for connection to the Licensing Gateway Service.
      • ‹user›:‹password› (optional): Credentials for connection to the Licensing Gateway Service (basic authorization).
      • ‹host›: Hostname of the Licensing Gateway Service.
      • ‹port›: Port for connection to the Licensing Gateway Service.

      Example: "http://localhost:9999"

      Throws:
      IllegalArgumentException - The URI is invalid.
      IllegalArgumentException - if value is null
    • getLicenseInfoSnapshot

      public static LicenseInfo getLicenseInfoSnapshot()

      A new snapshot is created whenever this property is accessed.

      Note: initialize(java.lang.String) />must be called before accessing license information. Otherwise, the license is considered invalid.