Sha256: e7eef4df6586976c606179e821aa009ebde7d341afbd7891f1f5e17a92a8a2ac
Contents?: true
Size: 1.4 KB
Versions: 45
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require "wicked_pdf" module Decidim module Exporters # Exports a PDF using the provided hash, given a collection and a # Serializer. This is an abstract class that should be inherited # to create PDF exporters, with each PDF exporter class setting # the desired template, layout and orientation. # class PDF < Exporter # Public: Exports a PDF version of the collection by rendering # the template into html and then converting it to PDF. # # Returns an ExportData instance. def export html = controller.render_to_string( template: template, layout: layout, locals: locals ) document = WickedPdf.new.pdf_from_string(html, orientation: orientation) ExportData.new(document, "pdf") end # may be overwritten if needed def orientation "Portrait" end # implementing classes should return a valid ERB path here def template raise NotImplementedError end # implementing classes should return a valid ERB path here def layout raise NotImplementedError end # This method may be overwritten if the template needs more local variables def locals { collection: collection } end protected def controller raise NotImplementedError end end end end
Version data entries
45 entries across 45 versions & 1 rubygems