Sha256: 0ec5202262971ef8ed14910a18ef8d02272c7a8e8f2f18d50d95bc99f9345ee7

Contents?: true

Size: 730 Bytes

Versions: 26

Compression:

Stored size: 730 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.organization, 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

26 entries across 26 versions & 1 rubygems

Version Path
mumuki-laboratory-9.23.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.22.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.21.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.20.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.20.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.19.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.18.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.18.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.17.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.16.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.15.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.14.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.14.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.13.2 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.13.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.13.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.12.1 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.12.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.11.0 app/controllers/concerns/with_certificate_render.rb
mumuki-laboratory-9.10.0 app/controllers/concerns/with_certificate_render.rb