Sha256: f3322add31a3c824128e3e6b03d5cd9b97478741a695d0efc8d007b67e77cafa

Contents?: true

Size: 704 Bytes

Versions: 18

Compression:

Stored size: 704 Bytes

Contents

require 'wicked_pdf'
require 'rqrcode'

module WithCertificateRender

  extend ActiveSupport::Concern

  included do
    helper_method :qr_for
  end

  def qr_for(certificate)
    qr = RQRCode::QRCode.new(verify_certificate_url certificate.code).as_svg(color: '0B465D')
    "data:image/svg+xml,#{URI.encode(qr)}"
  end

  def pdf_for(certificate)
    pdf_html = render_to_string(partial: 'certificates/download', locals: { certificate: certificate })
    WickedPdf.new.pdf_from_string pdf_html,
                                  orientation: 'Landscape',
                                  page_size: 'A5',
                                  margin: { top: 0.5, left: 1, bottom: 0.5, right: 1 }

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mumuki-laboratory-9.7.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.6.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.5.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.5.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.4.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.4.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.3.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.3.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.2.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.1.3 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.1.2 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.1.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.1.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.0.6 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.0.5 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.0.4 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.0.3 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.0.2 app/controllers/concerns/with_certificate_render.rb