Class: Pdf::Document::HeatLossReport
- Inherits:
-
BaseService
- Object
- BaseService
- Pdf::Document::HeatLossReport
- Includes:
- Base
- Defined in:
- app/services/pdf/document/heat_loss_report.rb
Overview
HexaPDF-based heat loss report PDF generator
Defined Under Namespace
Classes: Result
Constant Summary
Constants included from Base
Base::FONT, Base::NIMBUS_SANS_PATH, Base::NIMBUS_SANS_PATH_BOLD, Base::WY_LOGO_PATH
Instance Method Summary collapse
Instance Method Details
#call(room_configuration, **_options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/services/pdf/document/heat_loss_report.rb', line 10 def call(room_configuration, **) @room = room_configuration @heat_loss = room_configuration.last_heat_loss || room_configuration.calculate_heat_loss @store = room_configuration.customer&.store # Generate chart images @charts = generate_chart_images # Create PDF document composer = build_composer(margin: [80, 25, 50, 25]) # Build the PDF content add_title(composer) add_charts(composer) add_room_details(composer) add_heat_loss_summary(composer) add_recommendations(composer) # Add header/footer to all pages add_page_decorations(composer) # Write to buffer buffer = StringIO.new composer.write(buffer, optimize: true) Result.new( pdf: buffer.string, room_configuration: room_configuration, file_name: "heat_loss_report_#{room_configuration.id}_#{room_configuration.updated_at.to_i}.pdf" ) end |