AdobeDocApi
A Ruby client for the Adobe Document Generation API. It wraps the HTTP calls required to send a Word template and JSON data to Adobe and download the generated document.
How it works
-
OAuth authentication – the client exchanges your
client_id
,client_secret
andscopes
for an access token using Adobe's OAuth server-to-server flow. - Upload template – the SDK requests a presigned upload URL, then uploads your Word template to that URL.
- Generate document – it submits the Document Generation job with your JSON payload and polls Adobe for completion.
- Download output – once the job is complete, the generated file (DOCX) is downloaded to the path you specify.
The gem hides these steps behind a small API so you can focus on supplying the template and data.
Installation
Add to your application's Gemfile
and run bundle install
:
gem 'adobe_doc_api'
Or install it directly with:
gem install adobe_doc_api
Configuration
Set your Adobe credentials before using the client:
AdobeDocApi.configure do |config|
config.client_id = YOUR_CLIENT_ID
config.client_secret = YOUR_CLIENT_SECRET
config.scopes = "your\:scopes" # e.g. 'openid,AdobeID,read_organizations'
end
If you are on Rails, you may want to load these values from encrypted credentials:
AdobeDocApi.configure do |config|
config.client_id = Rails.application.credentials.dig(:adobe_doc, :client_id)
config.client_secret = Rails.application.credentials.dig(:adobe_doc, :client_secret)
config.scopes = Rails.application.credentials.dig(:adobe_doc, :scopes)
end
Usage
template_path = "/full/path/to/template.docx"
output_path = "/full/path/to/output.docx"
json_data = { DocTag: "Value", DocTag2: "Value2" }
client = AdobeDocApi::Client.new
client.submit(json: json_data, template: template_path, output: output_path)
# => true when the file is saved to `output_path`
You can also pass credentials directly when creating the client:
client = AdobeDocApi::Client.new(client_id: "id", client_secret: "secret", scopes: "scopes")
For information on the API responses and parameters see the official Adobe Services API documentation.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.