Add pandoc
All checks were successful
/ Run tests (push) Successful in 1m35s
/ Run system tests (push) Successful in 2m31s
/ Build, push and deploy image (push) Successful in 6m18s

This commit is contained in:
david 2024-07-26 03:14:07 +02:00
parent dec482bfba
commit 109dcd205c
11 changed files with 108 additions and 4 deletions

View file

@ -15,6 +15,21 @@ class ReportsController < ApplicationController
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
render
end
format.xml do
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'html')}")
render formats: [:odt], layout: false
end
format.rtf do
html = render_to_string(template: 'reports/show', formats: [:odt],
layout: false)
rtf = "{\\rtf1\n#{PandocRuby.html(html).to_rtf}}"
send_data rtf, filename: filename(@report, extension: 'rtf')
end
format.odt do
html = render_to_string(layout: false)
odt = PandocRuby.html(html).to_odt
send_data odt, filename: filename(@report, extension: 'odt')
end
format.docx do
template = Sablon.template(Rails.root.join('lib/templates/docx/report.docx'))
context = {