← SDKs
Ruby SDK

majorsilence_reporting

Render RDL reports to PDF, Excel, CSV, and more from Ruby — via subprocess, an AOT binary, or in-process Fiddle FFI. Ruby 3.0+. No runtime gem dependencies.


Installation

No gem is published to RubyGems yet. Load from source using $LOAD_PATH or require_relative:

# Add the lib directory to the load path
$LOAD_PATH.unshift '/path/to/reporting-ruby/lib'

# Load all three classes at once
require 'majorsilence_reporting'

# Or load individual classes
require 'majorsilence_reporting/report'
require 'majorsilence_reporting/report_aot'
require 'majorsilence_reporting/report_native'

No runtime gem dependencies. The native FFI mode uses Ruby's built-in Fiddle standard library.


Integration modes

ClassMechanismRequirement
ReportSpawns dotnet RdlCmd.dll via system()..NET runtime on the server.
ReportAotSpawns a self-contained AOT-compiled RdlCmd binary via system().AOT binary deployed alongside the app. No .NET runtime needed.
ReportNativeLoads librdlnative.so in-process via Fiddle. Use RdlLibrary.load() to obtain the bound function table.Native library + sibling .so files on LD_LIBRARY_PATH before Ruby starts.

Report — subprocess (dotnet)

require 'majorsilence_reporting/report'

rpt = Report.new('/path/to/report.rdl', '/path/to/RdlCmd.dll')
rpt.set_connection_string('Data Source=/path/to/data.db')
rpt.set_parameter('StartDate', '2026-01-01')

# Save to disk
rpt.export('pdf', '/tmp/output.pdf')

# Or get bytes in memory (e.g. for a Rails controller)
data = rpt.export_to_memory('pdf')
send_data data, type: 'application/pdf', disposition: 'inline'

ReportAot — AOT binary

Same API as Report but targets a self-contained binary. No .NET runtime required. Unlocks additional export formats (xlsx_table, tifb, mht).

require 'majorsilence_reporting/report_aot'

rpt = ReportAot.new('/path/to/report.rdl', '/path/to/RdlCmd')
rpt.set_connection_string('Data Source=/path/to/data.db')

data = rpt.export_to_memory('xlsx_table')

# In a Rack/Sinatra response:
[200, { 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }, [data]]

ReportNative — Fiddle FFI

Load librdlnative.so directly into the Ruby process via the built-in Fiddle library. No child process is spawned.

require 'majorsilence_reporting/report_native'

# Load once at startup. Pre-loads sibling .so/.dylib files and sets RDLNATIVE_LIB_DIR.
lib = RdlLibrary.load('/path/to/librdlnative.so')

rpt = ReportNative.new(lib, '/path/to/report.rdl')
rpt.set_connection_string('Data Source=/path/to/data.db')

data = rpt.export_to_memory('pdf')   # returns binary String
LD_LIBRARY_PATH must include the native library directory before Ruby starts. RdlLibrary.load() sets ENV['RDLNATIVE_LIB_DIR'] and pre-loads sibling libraries with Fiddle.dlopen, but cannot retroactively update LD_LIBRARY_PATH for the running process.

Core API

All three classes share the same interface:

MethodDescription
set_connection_string(cs)Set the database connection string. Call before export.
set_parameter(name, value)Set a named report parameter. Both arguments are strings. Call as many times as needed.
export(type, path)Render the report and write the output to path on disk.
export_to_memory(type)Render and return the output as a binary String (binary formats) or UTF-8 String (text formats such as CSV, XML, HTML).

In-memory datasets

ReportNative supports supplying data entirely in memory via add_data() — no database connection required. Pass a dataset name and an array of hashes where every value is a string.

rpt.add_data('SalesData', [
  { 'Product' => 'PDF Library Pro',  'Revenue' => '1200.00', 'Units' => '3' },
  { 'Product' => 'Report Designer',   'Revenue' => '250.00',  'Units' => '1' },
  { 'Product' => 'Support (12 mo.)',  'Revenue' => '500.00',  'Units' => '1' },
])

data = rpt.export_to_memory('pdf')
add_data() is only available on ReportNative, not on Report or ReportAot. All field values must be strings. The dataset name must match a dataset defined in the .rdl file.

Export formats

Format stringOutputAvailable in
pdfPDFAll modes
csvCSV textAll modes
xlsxExcel workbookAll modes
xmlXML dataAll modes
rtfRich Text FormatAll modes
tifTIFF image (colour)All modes
htmlHTMLAll modes
xlsx_tableExcel (table style)ReportAot + ReportNative only
tifbTIFF image (black & white)ReportAot + ReportNative only
mhtMHTML web archiveReportAot + ReportNative only