Adobe Acrobat Services SDKs Updated and Revised | by Raymond Camden | Aug, 2024


Over the past few months, we’ve been working to improve and expand the power of our SDKs and with the most recent update to our .NET SDK, we’ve now completed the overhaul of all our supported platforms. These 4.x versions offer improved support for our REST APIs and will be much more flexible than earlier versions. Let’s cover the updates.

At a high level, the new SDKs offer better support for the asynchronous nature of our APIs. Previously, SDK methods ‘hid’ the async nature behind the scenes, which while perhaps simpler, meant that developers had less control over the process. Now SDK users can choose how they want to handle this aspect of their development.

Next, our Python SDK now has full support for all our released APIs. Previously, Python only supported a subset of the features.

Finally, asset deletion is now supported via the SDK. When your code uploads a document, for example, a Word doc that will be converted to PDF, Adobe keeps this file in a secure temporary storage system. While no one had access to this asset, it’s understandable that you may wish to remove this asset as soon as the conversion is done. The REST API has supported this for some time, but now the SDKs do as well.

Let’s take a look at how these new SDKs work. If you want to try these examples yourself, be sure to grab your own free credentials.

We’ll start with the simplest example, converting a Word document to PDF. For this demo, we’ll make use of the Node SDK which can be installed via npm:

Ok, now let’s look at the code. First, our imports:

The SDK has specific types based on the operation being used and you can see that above with CreatePDFJob and CreatePDFResult. FYI, the SDKs have full documentation as well of course. You can find the Node SDK docs here: https://opensource.adobe.com/pdfservices-node-sdk-samples/apidocs/latest/index.html

Next, we set up our credentials by reading our values from the environment. These credentials are then passed to an instance of the PDFServices object.

Now we define our operation. In this simple case, we don’t have to tweak any of the parameters, just supply the input. This is done using fs streams and defining our mime type. If you’ve ever found yourself Googling for the precise mime type of Office docs, you’ll appreciate having them baked into the SDK itself. We create the job and use submit to get it running.

Finally, you can poll for the result, and if successful, stream down the bits:

All in all, fairly short and sweet for a simple use case. Here’s the entire script, with a bit more logging in that provides additional feedback while it runs:

One of the largest benefits of the SDKs is that they enable greater performance by enabling you to chain one command after another. Imagine you wanted to convert the Word doc into a PDF and add a password. Previously this would have required the SDK to:

  • Upload the Word doc
  • Download the PDF
  • Upload the PDF
  • Download the protected PDF

Now the SDKs can simply refer to the output of a previous action by using the resulting asset as input for the next operation. Let’s look at what’s necessary for that.

First, we add in the required support for our password-protect action. This (and the following updates) all came from our docs which include updated instructions for the new SDKs: Protect PDF

In the code snippet above, we’ve added: ProtectPDFParams, EncryptionAlgorithm, ProtectPDFJob, ProtectPDFResult.

Now, let’s begin our modification. The line that waited for the result of the Create PDF operation was:

Everything that follows is after that line. First, we’ll specify the params for the operation, in this case, a hard coded password:

Next, we make our job, using the result asset from the CreatePDF job:

The remainder of the code is as before — poll the job, and when done, get the asset and stream it (note that we’ve modified the file name):

And that’s it. In theory, there is no limit to what you could chain. You could:

  • Convert to PDF
  • Prepend a title page for the document
  • Add a watermark
  • Seal the document
  • Password protect it
  • And then download it.

Here’s the complete version of this script:

To get started, sign up for free credentials and give the SDKs a try. If you’re using a language not supported by the SDKs, or simply would rather use the APIs, peruse the API docs for more information.



Source link