Docgen.io is a document generating API
With a few API calls you can streamline the generation of high quality PDFs
Docgen.io uses latex to generate the PDFs and Mustache for templating
Refer to the API documentation here
add the following to your Gemfile
gem 'docgen_io_client', git:'https://github.com/nicholasjstock/docgen_io_client.git', branch: 'master'
in the terminal run
bundle
Set DOCGEN_API_KEY env variable with a docgen.io api key
document = DocgenIoClient::Document.create(
texfile:"contents <% field_name %> of a tex file"
)
render = DocgenIoClient::TemplateRender.create(
document: document,
params: {
"field_name":"asdfasdfasdfadsf"
}
)
if the generation of the file happened successfully
it will be stored in render.pdf
Sinatra example
get '/pdf' do
id = params['template_render_id']
template_render = DocgenIoClient::TemplateRender.find(id)
content_type 'application/pdf'
response.write(template_render.pdf.read)
end