Inkspan › Ruby on Rails

How to generate a PDF from HTML in Ruby on Rails

Call the Inkspan /v1/generate/html endpoint from Ruby on Rails to generate a PDF from HTML — 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/html'),
  {"html":"<h1>Invoice</h1>"}.to_json,
  { 'X-API-Key' => ENV['INKSPAN_KEY'], 'Content-Type' => 'application/json' })
File.write('out.pdf', res.body)
Get a free API key →