Generate Documents with Ruby SDK

REST API and Ruby Cloud SDK to assemble, merge, and mail‑merge documents from templates and data sources.

  • GroupDocs.Assembly Cloud for cURL
  • GroupDocs.Assembly Cloud SDK for .NET
  • GroupDocs.Assembly Cloud SDK for Java
  • GroupDocs.Assembly Cloud SDK for PHP
  • GroupDocs.Assembly Cloud SDK for Python
  • GroupDocs.Assembly Cloud SDK for Node.js
  • GroupDocs.Assembly Cloud SDK for Go
  • GroupDocs.Assembly Cloud SDK for C++
  • GroupDocs.Assembly Cloud SDK for Swift
Start Free Trial

GroupDocs.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.

Ruby workflow with the SDK

  1. Install the Ruby gem (gem install groupdocs_assembly_cloud).
  2. Configure the SDK with your app_sid and api_key.
  3. Upload the template file to GroupDocs Cloud Storage via the UploadFile endpoint.
  4. Prepare an AssembleOptions object that references the uploaded template, specifies the desired output format, and supplies the XML/JSON data source (or a file containing it).
  5. Call 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.

Document Assembly REST API Features

Generate documents from templates with placeholders

LINQ‑style data binding for XML and JSON sources

Insert images, charts and graphics into output

Create dynamic tables from array data

Conditional content blocks using expressions

Secure API access via personal access keys

Mail‑merge support for batch personalized letters

Generate and embed barcodes (QR, Code128, …)

Set background colors for HTML output

SSL/TLS encrypted data transfer

Generate a document in Ruby

The snippet below shows how to generate a document using the Assembly Cloud Ruby SDK. Steps performed:

  1. Configure the SDK with your App SID and API Key.
  2. Upload the template file to Cloud Storage.
  3. Define AssembleOptions – template, output format and data source.
  4. Call 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

Support and Learning Resources

GroupDocs.Assembly Cloud also offers SDKs for other languages:

  English
5f5c5ef