AdobeDocumentServicesClient 1.0.2
See the version list below for details.
dotnet add package AdobeDocumentServicesClient --version 1.0.2
NuGet\Install-Package AdobeDocumentServicesClient -Version 1.0.2
<PackageReference Include="AdobeDocumentServicesClient" Version="1.0.2" />
paket add AdobeDocumentServicesClient --version 1.0.2
#r "nuget: AdobeDocumentServicesClient, 1.0.2"
// Install AdobeDocumentServicesClient as a Cake Addin #addin nuget:?package=AdobeDocumentServicesClient&version=1.0.2 // Install AdobeDocumentServicesClient as a Cake Tool #tool nuget:?package=AdobeDocumentServicesClient&version=1.0.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.
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")); 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 | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.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.