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

com.dynamicpdf.api.Pdf 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.HashSet;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import com.dynamicpdf.api.elements.Element;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

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

/**
 * Represents a pdf endpoint.
 */

public class Pdf extends Endpoint
{
	PdfInstructions instructions;
	private HashSet resources = new HashSet();

	/**
	 * Initializes a new instance of the Pdf class.
	 */

	public Pdf() { 
		super();        
		this.instructions = new PdfInstructions();
	}

	/**
	 * Gets the collection of resource.
	 * @return The collection of resource.
	 */
	String getEndpointName() { return "pdf";}

	/**
	 * Sets the collection of resource.
	 * @return The collection of resource.
	 */
	public HashSet getResources() { return resources; }

	/**
	 * Gets the author.
	 * @return The author.
	 */
	public String getAuthor()
	{
		return this.instructions.getAuthor();            
	}

	/**
	 * Sets the author.
	 * @param value The author.
	 */
	public void setAuthor(String value)
	{
		this.instructions.setAuthor(value);
	}

	/**
	 * Gets the title.
	 * @return The title.
	 */
	public String getTitle()
	{
		return this.instructions.getTitle();
	}

	/**
	 * Sets the title.
	 * @param value The title.
	 */
	public void setTitle(String value) 
	{
		this.instructions.setTitle(value);
	}

	/**
	 * Gets the subject.
	 * @return The subject.
	 */
	public String getSubject()
	{ 
		return this.instructions.getSubject();
	}

	/**
	 * Sets the subject.
	 * @param value The subject.
	 */
	public void setSubject(String value) 
	{ 
		this.instructions.setSubject(value);
	}

	/**
	 * Gets the creator.
	 * @return The creator.
	 */
	public String getCreator()
	{ 
		return this.instructions.getCreator();
	}

	/**
	 * Sets the creator.
	 * @param value The creator.
	 */
	public void setCreator(String value) 
	{ 
		this.instructions.setCreator(value);
	}

	/**
	 * Gets the keywords.
	 * @return The keywords.
	 */
	public String getKeywords() 
	{
		return this.instructions.getKeywords();
	}

	/**
	 * Sets the keywords.
	 * @param value The keywords.
	 */
	public void setKeywords(String value) 
	{ 

		this.instructions.setKeywords(value);
	}

	/**
	 * Gets the security.
	 * @return The security.
	 */
	public Security getSecurity() 
	{
		return this.instructions.getSecurity();
	}

	/**
	 * Sets the security.
	 * @param value The security.
	 */
	public void setSecurity(Security value) 
	{ 
		this.instructions.setSecurity(value);
	}

	/**
	 * Gets the value indicating whether to flatten all form fields.
	 * @return The value indicating whether to flatten all form fields.
	 */
	public boolean getFlattenAllFormFields()
	{
		return this.instructions.getFlattenAllFormFields();
	}

	/**
	 * Sets the value indicating whether to flatten all form fields.
	 * @param value The value indicating whether to flatten all form fields.
	 */
	public void setFlattenAllFormFields(boolean value)
	{ 
		this.instructions.setFlattenAllFormFields(value);
	}

	/**
	 * Gets the value indicating whether to retain signature form field.
	 * @return The value indicating whether to retain signature form field.
	 */
	public boolean getRetainSignatureFormFields() 
	{
		return this.instructions.getRetainSignatureFormFields();            
	}

	/**
	 * Sets the value indicating whether to retain signature form field.
	 * @param value The value indicating whether to retain signature form field.
	 */
	public void setRetainSignatureFormFields(boolean value) 
	{
		this.instructions.setRetainSignatureFormFields(value);
	}

	/**
	 * Returns a PdfInput object containing the input pdf.
	 * @param resource The resource of type PdfResource.
	 * @param options The merge options for the pdf.
	 * @return Added pdf pages
	 */

	public PdfInput addPdf(PdfResource resource, MergeOptions options)
	{
		PdfInput input = new PdfInput(resource, options);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * 
	 * @param resource The resource of type PdfResource.
	 * @return Added pdf pages
	 */
	public PdfInput addPdf(PdfResource resource)
	{
		return addPdf(resource, null);
	}

	/**
	 * Returns a PdfInput object containing the input pdf.
	 * @param cloudResourcePath The resource path in cloud resource manager.
	 * @param options The merge options for the pdf.
	 * @return Added pdf pages
	 */
	public PdfInput addPdf(String cloudResourcePath, MergeOptions options)
	{
		PdfInput input = new PdfInput(cloudResourcePath, options);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * 
	 * @param cloudResourcePath The resource path in cloud resource manager.
	 * @return Added pdf pages
	 */
	public PdfInput addPdf(String cloudResourcePath)
	{            
		return addPdf(cloudResourcePath, null);
	}

	/**
	 * Returns an ImageInput object containing the input pdf.
	 * @param resource The resource of type ImageResource.
	 * @return Added pdf pages
	 */

	public ImageInput addImage(ImageResource resource)
	{
		ImageInput input = new ImageInput(resource);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns an ImageInput object containing the input pdf.
	 * @param cloudResourcePath The resource path in cloud resource manager.
	 * @return Added pdf pages
	 */

	public ImageInput addImage(String cloudResourcePath)
	{
		ImageInput input = new ImageInput(cloudResourcePath);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns a DlexInput object containing the input pdf.
	 * @param dlexResource The dlex resource of type DlexResource.
	 * @param layoutData The layout data resource of type LayoutDataResource.
	 * @return Added pdf pages
	 */

	public DlexInput addDlex(DlexResource dlexResource, LayoutDataResource layoutData)
	{
		DlexInput input = new DlexInput(dlexResource, layoutData);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns a DlexInput object containing the input pdf.
	 * @param cloudResourcePath The resource path in cloud resource manager.
	 * @param layoutData The layout data resource of type LayoutDataResource.
	 * @return Added pdf pages
	 */

	public DlexInput addDlex(String cloudResourcePath, LayoutDataResource layoutData)
	{
		DlexInput input = new DlexInput(cloudResourcePath, layoutData);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns a DlexInput object containing the input pdf.
	 * @param cloudResourcePath The resource path in cloud resource manager.
	 * @param layoutData The json data string used to create the PDF report.
	 * @return Added pdf pages
	 */

	public DlexInput addDlex(String cloudResourcePath, String layoutData)
	{
		DlexInput input = new DlexInput(cloudResourcePath, layoutData);
		this.getInputs().add(input);
		return input;
	}
	
	/**
	 * Returns a DlexInput object containing the input pdf.
	 * @param dlexResource The resource path in cloud resource manager.
	 * @param layoutData The json data string used to create the PDF report.
	 * @return Added pdf pages
	 */
	public DlexInput addDlex(DlexResource dlexResource, String layoutData) {
		DlexInput input = new DlexInput(dlexResource, layoutData);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns a PageInput object containing the input pdf.
	 * @param pageWidth The width of the page.
	 * @param pageHeight The height of the page.
	 * @return Added pdf pages
	 */

	public PageInput addPage(float pageWidth, float pageHeight)
	{
		PageInput input = new PageInput(pageWidth, pageHeight);
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Returns a PageInput object containing the input pdf.
	 * @return A PageInput object containing the input pdf.
	 */
	public PageInput addPage()
	{
		PageInput input = new PageInput();
		this.getInputs().add(input);
		return input;
	}

	/**
	 * Gets the inputs.
	 * @return The inputs.
	 */
	public List getInputs()
	{
		return this.instructions.getInputs();
	}

	/**
	 * Gets the templates.
	 * @return The templates.
	 */
	public HashSet