All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dynamicpdf.api.PdfXmp Maven / Gradle / Ivy

Go to download

A Java Client API that uses the DynamicPDF API to create, merge, split, form fill, stamp, secure/encrypt PDF documents.

There is a newer version: 1.10.1
Show newest version

package com.dynamicpdf.api;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import io.restassured.RestAssured;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;

/**
 * Represents the pdf xmp endpoint.
 */
public class PdfXmp extends Endpoint
{
	PdfResource resource;

	/**
	 * Initializes a new instance of the PdfXmp class.
	 * @param resource The image resource of type PdfResource
	 */
	public PdfXmp(PdfResource resource)
	{
		this.resource = resource;
	}

	String getEndpointName() { return "pdf-xmp";}


	/**
	 * Process the pdf resource to get pdf's xmp data.
	 * 

XmlResponse

* @return Xml Response */ public XmlResponse process() { CompletableFuture cf = processAsync(); try { return cf.get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } return null; } /** * Process the pdf resource to get pdf's xmp data. * * @return collection of XmlResponse as multithreading tasks CompletableFuture. */ public CompletableFuture processAsync() { return CompletableFuture.supplyAsync(() -> { XmlResponse xmlResponse = null; RequestSpecification requestSpec = super.createRequestSpecification(); Response response = RestAssured .given() .header("Accept", "application/pdf") .header("content-type", "application/pdf") .spec(requestSpec) .body(resource.getData()) .post(getDefaultBaseUrl() + "/"+ getEndpointVersion() + "/" + getEndpointName()); if (response.getStatusCode() == 200) { xmlResponse = new XmlResponse(response.asString()); xmlResponse.setIsSuccessful(true); xmlResponse.setStatusCode(response.getStatusCode()); } else { xmlResponse = new XmlResponse(); xmlResponse.setErrorJson(response.asString()); xmlResponse.setIsSuccessful(false); xmlResponse.setStatusCode(response.getStatusCode()); } return xmlResponse; }); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy