AdobeDocumentServicesClient 9.1.2
dotnet add package AdobeDocumentServicesClient --version 9.1.2
NuGet\Install-Package AdobeDocumentServicesClient -Version 9.1.2
<PackageReference Include="AdobeDocumentServicesClient" Version="9.1.2" />
paket add AdobeDocumentServicesClient --version 9.1.2
#r "nuget: AdobeDocumentServicesClient, 9.1.2"
// 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
- Installation
- Configuration
- Usage
- Dependency Injection
- Set Adobe Region URL
- Merge Document
- API Reference
- Error Handling
- 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 | Versions 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. |
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.