Class: PDFResponse
- Inherits:
-
Object
- Object
- PDFResponse
- Defined in:
- backend/app/lib/reports/pdf_response.rb
Overview
java_import org.xhtmlrenderer.pdf.ITextRenderer
Instance Method Summary (collapse)
-
- (Object) generate
-
- (PDFResponse) initialize(report, params)
constructor
A new instance of PDFResponse.
Constructor Details
- (PDFResponse) initialize(report, params)
Returns a new instance of PDFResponse
7 8 9 10 11 |
# File 'backend/app/lib/reports/pdf_response.rb', line 7 def initialize(report, params ) @report = report @html_report = params[:html_report].call @base_url = params[:base_url] || "/" end |
Instance Method Details
- (Object) generate
13 14 15 16 17 18 19 20 21 22 23 |
# File 'backend/app/lib/reports/pdf_response.rb', line 13 def generate estimated_pdf_length = @html_report.length output = java.io.ByteArrayOutputStream.new(estimated_pdf_length) begin dom = java_dom(@html_report) render_pdf(dom, output) ensure output.close end end |