REST API and Ruby Cloud SDK to assemble, merge, and mail‑merge documents from templates and data sources.
Start Free TrialGroupDocs.Assembly Cloud is a fully managed, REST‑based service that lets you create highly‑customized documents directly from your Ruby applications. The platform works on a template‑and‑data model: you design a template document (Word, Excel, PowerPoint, PDF, HTML, etc.) that contains special placeholder fields and programmable constructs. At runtime you supply a data source in XML or JSON format, bind the data to the template using a LINQ‑style expression syntax, and the cloud service assembles the final document in the format you need.
This approach removes the need for any local Office installations, third‑party libraries or complex rendering engines – all heavy lifting is performed in the secure GroupDocs data centre. You get built‑in support for mail‑merge, dynamic tables, conditional content, barcode generation, image and chart insertion, and a rich set of formatting options. The service also provides SSL/TLS encrypted communication, personal access keys for authentication, and role‑based permissions to keep your data safe.
gem install groupdocs_assembly_cloud
).app_sid
and api_key
.UploadFile
endpoint.AssembleOptions
object that references the uploaded template, specifies the desired output format, and supplies the XML/JSON data source (or a file containing it).assemble_document
– the API returns the assembled document, which you can download directly or store back to Cloud Storage.Using this straightforward sequence you can generate contracts, invoices, proposals, shipping reports, personalized letters, or any other business‑critical document on demand, scaling from a single request to large batch‑processing scenarios with mail‑merge.
The Ruby SDK also offers helper classes for working with storage, handling errors, and customizing request time‑outs, making integration into Rails, Sinatra or any Ruby‑based service seamless.
The snippet below shows how to generate a document using the Assembly Cloud Ruby SDK. Steps performed:
AssembleOptions
– template, output format and data source.assemble_document
to get the assembled file.require_relative '../lib/groupdocs_assembly_cloud'
GroupDocsAssemblyCloud.configure do |config|
config.client_data['app_sid'] = '####-####-####-####-####'
config.client_data['api_key'] = '##################'
end
@assembly_api = AssemblyApi.new
file_name = 'Input1.docx'
data_file = 'Input2.docx'
request_file_content = File.open(file_name)
upload_document_request = UploadFileRequest.new(
file_content: request_file_content, path: file_name)
@assembly_api.upload_file(upload_document_request)
template_file_info = TemplateFileInfo.new(:FilePath => file_name)
assemble_options = AssembleOptions.new(
:TemplateFileInfo => template_file_info,
:SaveFormat => "docx",
:ReportData => File.open(data_file, 'rb') { |f| f.read })
request = AssembleDocumentRequest.new assemble_options
@assembly_api.assemble_document request