Inkspan › Ruby on Rails

How to generate a PDF from a template in Ruby on Rails

Call the Inkspan /v1/generate/template endpoint from Ruby on Rails to generate a PDF from a template — no headless browser, fonts, or PDF infrastructure to maintain. Set your API key as an environment variable and POST.

Ruby on Rails example

# Ruby / Rails
require 'net/http'
res = Net::HTTP.post(URI('https://api.inkspan.dev/v1/generate/template'),
  {"template":"<h1>{{name}}</h1>","data":{"name":"Ada"}}.to_json,
  { 'X-API-Key' => ENV['INKSPAN_KEY'], 'Content-Type' => 'application/json' })
File.write('out.pdf', res.body)
Get a free API key →