Skip to main content

Overview


The DynamicPDF Cloud API has several client libraries designed to make integrating the REST endpoints into your application much easier.


The DynamicPDF Cloud API has several client libraries designed to make integrating the REST endpoints into your application much easier. Depending upon your development environment, rather than developing your client application from scratch, consider using one of our client libraries to simplify your organization's development.

info

All resources are contained in the samples/users-guide-samples in your Resource Explorer. Some of these files you may need to download to use. See Sample Resources for instructions on adding sample resources.

Languages#

  • C#
  • Java
  • Node.js
  • PHP

Libraries#

Access the libraries from the DynamicPDF Cloud API github project at https://github.com/dynamicpdf-api. The client library for each respective language is also available for incorporation into your project via Nuget, Maven, npm, or Composer.

APIGitHub LocationAPI DocumentationLibrary
C#https://github.com/dynamicpdf-api/dotnet-clientNuget: https://www.nuget.org/packages/DynamicPDF.API
Javahttps://github.com/dynamicpdf-api/java-clientJavaDoc Client API DocumentationMaven: https://repo1.maven.org/maven2/com/dynamicpdf/api/dynamicpdf-api/0.9.0/ Groovy etc: https://search.maven.org/artifact/com.dynamicpdf.api/dynamicpdf-api/0.9.0/jar
Node.jshttps://github.com/dynamicpdf-api/nodejs-clientnpm: https://www.npmjs.com/package/@dynamicpdf/api
PHPhttps://github.com/dynamicpdf-api/php-clientComposer: https://packagist.org/packages/dynamicpdf/api
tip

Refer to each client library's readme.md file on github for documentation on the library.

Underlying REST Client#

Each client library uses an underlying REST client library.

Client LibraryUnderlying REST ClientVendor URL
C#RestSharphttps://restsharp.dev/
JavaREST-assuredREST-assured https://rest-assured.io/
Node.jsHTTP Modulenode.js built-in HTTP module (https://nodejs.dev/learn/the-nodejs-http-module)
PHPcURLhttps://curl.se/
info

The Endpoint class is the parent to all other endpoint related classes. If you need to use a different REST client, you can modify the Endpoint class. However, the REST clients chosen by DynamicPDF Cloud API are all industry standard and robust.

General Processing Steps#

When calling an endpoint using one of the client libraries, follow these steps to integrate the library with your application.

  • First, create an instance of the resource from your local system.
  • Next, create a new endpoint instance where you pass the resource from your local system.
  • Set the instance's base URL and API key.
  • After creating the endpoint instance, call its process method which calls the REST endpoint and returns the JSON response (or XML if the endpoint is PdfXmp).

Refer to the following Users Guide topic (Users Guide - Workflow) for more explanation describing the general workflow for using one of the DynamicPDF Cloud API Endpoints.

Endpoints#

The following table lists the endpoint's associated class and constructor arguments. Note that the class names are consistent between client libraries. Also note that all endpoints, with the exception of DlexLayout, use a resource from your local system.

EndpointEndpoint's Class NameConstructor ArgumentsReturnsDescription
image-infoImageInfoImageResourceJSONUploads an image from local system and returns JSON document describing image.
dlex-layoutDlexLayoutString cloudDlexPath, LayoutDataResource resourcePDFUses a dlex file on cloud and local layout data (JSON dataset) and constructs a PDF.
pdf-infoPdfInfoPdfResourceJSONUpload a PDF from local system and return the PDF's metadata as JSON document.
pdf-textPdfTextPdfResourceJSONUpload a PDF from local system and return the PDF's text as a JSON document.
pdf-xmpPdfXmpPdfResourceXMLUpload a PDF from local system and return the PDF's XMP data as XML document.
pdfPdf---PDFReturns a PDF. Refer to the Users Guide page on Instructions.
info

Only the dlex-layout endpoint takes a resource from the cloud (the DLEX file). All other endpoints use resources from local system. Also be certain any embedded resources for the DLEX is also on the cloud. The pdf endpoint is discussed in instructions Users Guide page (Instructions).

Client Library#

Complete documentation for each of the endpoints using the available client libraries is available via one of the following Users Guide pages.

EndpointUsers Guide Page
dlex-layoutdlex-layout
image-infoimage-info
pdfpdf
pdf-infopdf-info
pdf-textpdf-text
pdf-xmppdf-xmp

Client Library Classes#

The following summarizes the classes used in one of the client libraries. Note that each library's syntax is remarkably similar; the biggest difference being in method capitalization and whether you use a method. The following sections list the constructors you use with the DynamicPDF Cloud API client libraries.

Constructors#

Each class's constructor takes a string path to the resource, the resource as a byte array, or the resource as a stream. Note that all constructors (with the exception of dlex-layout) use a resource that exists on your local system. The following lists each client library's endpoint class constructors.

ImageInfo#

The image-info endpoint is used to obtain an image's metadata. When using one of the client libraries you create a new ImageInfo instance and it abstracts calling the REST endpoint.

DlexLayout#

The dlex-layout endpoint is used to create a PDF from a DLEX file and its associated JSON data. When using one of the client libraries you create a new DlexLayout instance and it abstracts calling the REST endpoint.

info

The DlexLayout constructor takes a string path to the dlex file in the DynamicPDF Cloud API's Resource Manager while the LayoutDataResource is the JSON data on your local system

PdfInfo#

The pdf-info endpoint is used to get a PDF's metadata and return it as a JSON document. When using one of the client libraries you create a new pdf-info instance and it abstracts calling the REST endpoint.

PdfText#

The pdf-text endpoint is used to extract text from a PDF document. When using one of the client libraries you create a new PdfText instance and it abstracts calling the REST endpoint.

PdfXmp#

The pdf-xmp endpoint is used to extract XMP metadata and return the XMP data as an XML document. When using one of the client libraries you create a new pdf-xmp instance and it abstracts calling the REST endpoint for you.

Pdf#

The pdf endpoint is used to create a PDF from a variety of inputs. When using one of the client libraries you create a new pdf instance and it abstracts calling the REST endpoint for you.

info

The pdf endpoint is discussed in much greater detail on the Users Guide page on the pdf endpoint's instructions JSON (Instructions).

Resources#

The Resource class and its associated child classes represent local resources on your filesystem. You use one of the following child classes to represent a local resource of the appropriate resource type.

  • A resource resides on your local system, not in the Resource Manager. When using a resource, you create a new resource by passing the local system path and then passing the PdfResource instance to one of the respective endpoint instances listed in the previous section.
tip

If using a resource locally, you create an instance of a resource and then pass it to one of the endpoint classes listed above. If using a resource on the cloud, you use an "add" method with a path to the resource in the Resource Manager.

Resource ClassDescription
PdfResourceLoads a PDF from your local system.
ImageResourceLoads an image from your local system.
DlexResourceLoads a dlex file from your local system.
LayoutDataResourceLoads a JSON data file from your local system.

Each child class inherits the following constructors for adding a resource from the local system. You can construct a resource from the local path to the resource, a byte array, or as a Stream.

info

There is also a FontResource class, but is excluded here as it is part of an instructions document and is not used with one of the endpoints listed above.

Constructors#

A resource can be constructed using a string path, a byte array, or a stream. Child classes of Resource, are resources on a local system and not in the DynamicPDF Cloud API. The following lists the signatures for each resource's constructor.

DlexResource#

The DlexResource class is specifically for loading a DLEX file from you local system. Although more commonly, a DLEX would reside in the Resource Manager on the cloud, you can also use a DLEX that resides on your local system.

caution

Remember, if using a DLEX locally, and you include embedded DLEX resources, such as images, be certain the paths are local and not to the cloud.

ImageResource#

The ImageResource class is for loading an image from you local system.

LayoutDataResource#

The LayoutDataResource class is for a DLEX file's JSON data. Typically it will reside on your local system, as you probably wish to keep your proprietary data local and not on the cloud.

PdfResource#

The PdfResource class is for loading PDFs that reside on your local system.

More on the Resource Class#

It is important to emphasize that the resource classes are for loading resources from you local system. If loading a resource from the cloud on the Resource Manager, you add the resource directly by referring to the path in the Resource Manager.

// add pdf from local systempdf.AddPdf(new PdfResource(basePath + "DocumentB.pdf"));//compared topdf.AddPdf("my-resource-manager-path/DocumentB.pdf")

This distinction, although seemingly trivial, is important when making design decisions for your client applications that use the DynamicPDF Cloud API.

Code Examples#

The following illustrates several examples using each of the provided client libraries. Refer to the GitHub project for the particular language you require or one of the online tutorials. Here are some examples of the endpoints. Although the example is provided below for convenience, the complete example is also provided on the endpoint's Users Guide documentation page (see above for complete listing).

  • For each example, for more information, including complete source code, refer to the endpoint's Users Guide page.
info

In the examples that follow, note that although there is consistency between the client libraries syntax, some classes and methods may have slightly different signatures depending upon the language. For example, in Java the method to process is process while in .NET the method is Process.

dlex-layout#

In this first example, the following code illustrates using the dlex-layout endpoint. It combines a pre-existing dlex file that exists in the cloud and a JSON data file that exists on your local system. The dlex file is wrapped in the DlexLayout class and the data is wrapped in the LayoutData class. These two classes programmatically sends the underlying resources to the endpoint via the process/Process method.

tip

See dlex-layout for complete example.

image-info#

The image-info endpoint examines a provided image and returns a JSON document describing the image's metadata.

tip

See image-info for complete example.

pdf#

The pdf endpoint handles creating PDF documents from images, dlex files, and other PDFs. It also handles creating PDFs from scratch. Of course, the pdf endpoint's real strength is through merging the previously mentioned tasks to create a combined PDF. The following simple example illustrates using the pdf endpoint to create a new single page PDF document. The pdf endpoint uses an instructions document with significantly more complexity than the other endpoints; refer to Instructions for examples illustrating using the instructions schema with the client libraries.

tip

See pdf for complete example.

pdf-info#

The pdf-info endpoint takes a PDF document and returns a JSON document containing the PDF's metadata. The following example illustrates.

tip

See pdf-info for complete example.

pdf-text#

The pdf-text endpoint takes a PDF and extracts the text data from the document. It allows extracting all or a portion of the PDF's text. The following example illustrates.

tip

See pdf-text for complete example.

pdf-xmp#

The pdf-xmp endpoint takes a PDF and returns the PDF's XMP metadata as an XML document. The following example illustrates the endpoint.

tip

See pdf-xmp for complete example.