AdobeDocumentServicesClient 9.1.2

dotnet add package AdobeDocumentServicesClient --version 9.1.2                
NuGet\Install-Package AdobeDocumentServicesClient -Version 9.1.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AdobeDocumentServicesClient" Version="9.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AdobeDocumentServicesClient --version 9.1.2                
#r "nuget: AdobeDocumentServicesClient, 9.1.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AdobeDocumentServicesClient as a Cake Addin
#addin nuget:?package=AdobeDocumentServicesClient&version=9.1.2

// Install AdobeDocumentServicesClient as a Cake Tool
#tool nuget:?package=AdobeDocumentServicesClient&version=9.1.2                

Adobe Document Services Client

Reference: https://developer.adobe.com/document-services/docs/overview/document-generation-api/
Github: https://github.com/williameduardo79/AdobeDocumentServicesClient

The AdobeClientConnector library provides an interface for integrating with Adobe Document Services API to perform tasks such as token management, document merging, and file uploads. This particular service focuses on the Document merge which takes a word document and a Json file and generates a PDF. The client test project shows this feature in action. You may need to authenticate with Adobe and might need an Adobe account.

Features

  • Authenticate with Adobe APIs using OAuth2.
  • Upload documents to Adobe services.
  • Merge Word templates with JSON data to generate PDFs.
  • Monitor file processing status.
  • Download processed files from Adobe servers.

Table of Contents

  1. Installation
  2. Configuration
  3. Usage
  4. Dependency Injection
  5. Set Adobe Region URL
  6. Merge Document
  7. API Reference
  8. Error Handling
  9. Logging

Installation

Add the library to your project via a NuGet package (if applicable):

Install-Package AdobeClientConnector

Configuration

To use the AdobeClientConnector service, ensure the following configurations are present in your appsettings.json:

"AdobeCredentials": { "ClientId": "your-client-id", "ClientSecret": "your-client-secret", "Region": "UnitedStates" // Options: UnitedStates, Europe, Custom }

Usage

Dependency Injection

The library integrates with .NET dependency injection. Register it in your Startup.cs or Program.cs:

services.Configure<AdobeCredentials>(configuration.GetSection(AdobeCredentials.Name)); services.AddHttpClient(); services.AddTransient<IAdobeClientConnector, AdobeClientConnector>();

Override Region if not set up in Config:

adobeClientConnector.SetAdobeURLRegion(RegionOptions.UnitedStates);

Override Adobe's API URL with custom URL:

adobeClientConnector.SetAdobeURLRegion("https://custom-adobe-api-url.com");

Merge Document

To merge a Word template with JSON data and generate a PDF:

var wordTemplateStream = File.OpenRead("template.docx"); var jsonData = JObject.Parse(@"{ 'Name': 'John Doe', 'Age': 30 }"); var resultStream = await adobeClientConnector.MergeDocumentAsync(wordTemplateStream, jsonData); using var fileStream = File.Create("output.pdf"); await resultStream.CopyToAsync(fileStream);

API Reference

Public Methods

SetAdobeURLRegion(RegionOptions regionOptions)

Sets the API base URL based on the specified region.

SetAdobeURLRegion(string customUrl)

Sets a custom API base URL.

MergeDocumentAsync(Stream wordTemplate, JObject jsonObject)

Merges a Word document with JSON data to generate a PDF.

GetTokenAsync()

Retrieves an OAuth2 token from Adobe API.

GetUploadPreSignedUriAsync(AdobeToken adobeToken)

Generates a pre-signed URL for uploading documents.

UploadDocumentAsync(string uploadUri, Stream wordTemplate)

Uploads a document to the specified Adobe pre-signed URL.

DocumentGenerationAsync(JObject jsonObject, AdobeToken adobeToken, string assetId)

Generates a document based on the provided JSON data and asset ID.

CheckFileStatusAsync(AdobeToken adobeToken, MergeDocumentResponse documentResponse)

Checks the status of a file processing request.

GetFileStreamAsync(string fileUrl)

Downloads a file from Adobe services as a stream.

Error Handling

Exceptions are logged using the provided ILogger instance. Key exception types include:

  • ValidationException: Raised for invalid constructor parameters.
  • UnauthorizedAccessException: Raised when token retrieval fails.
  • ArgumentNullException: Raised for null input streams or parameters.
  • HttpRequestException: Raised for failed HTTP requests.

Logging

The library logs requests, responses, and errors using the ILogger interface. Example:

_logger.LogInformation("Request URL: {Url}", uploadUri); _logger.LogError(ex, "An error occurred while merging documents.");

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.1.2 101 12/26/2024
1.0.9 88 12/26/2024
1.0.3 87 12/20/2024
1.0.2 89 12/20/2024
1.0.1 87 12/20/2024