2026-03-19 00:42:27 -04:00
|
|
|
module IdCard
|
|
|
|
|
class PrintDataController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def generate_sample
|
|
|
|
|
@employer = Employer.find_by(slug: params[:employer_slug])
|
2026-03-20 10:46:53 -04:00
|
|
|
sample_cards_pdf = IdCardPrinterService::SampleCardsGenerator.new(@employer).call
|
2026-03-19 00:42:27 -04:00
|
|
|
|
|
|
|
|
send_data sample_cards_pdf.to_pdf,
|
|
|
|
|
filename: "#{@employer.name.parameterize(separator: "_")}_sample_cards_#{Date.today}.pdf",
|
|
|
|
|
type: "application/pdf",
|
|
|
|
|
disposition: 'attachment'
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def generate_print
|
|
|
|
|
@employer = Employer.find_by(slug: params[:employer_slug])
|
2026-03-20 10:46:53 -04:00
|
|
|
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "PrintCard").call
|
2026-03-19 00:42:27 -04:00
|
|
|
|
|
|
|
|
send_data cards_pdf.to_pdf,
|
|
|
|
|
filename: "#{@employer.name.parameterize(separator: "_")}_print_cards_#{Date.today}.pdf",
|
|
|
|
|
type: "application/pdf",
|
|
|
|
|
disposition: 'attachment'
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def generate_mobile_display
|
|
|
|
|
@employer = Employer.find_by(slug: params[:employer_slug])
|
2026-03-20 10:46:53 -04:00
|
|
|
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "MobileDisplayCard").call
|
2026-03-19 00:42:27 -04:00
|
|
|
|
|
|
|
|
send_data cards_pdf.to_pdf,
|
|
|
|
|
filename: "#{@employer.name.parameterize(separator: "_")}_mobile_display_cards_#{Date.today}.pdf",
|
|
|
|
|
type: "application/pdf",
|
|
|
|
|
disposition: 'attachment'
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def generate_full_page
|
|
|
|
|
@employer = Employer.find_by(slug: params[:employer_slug])
|
2026-03-20 10:46:53 -04:00
|
|
|
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "FullPageCard", true).call
|
2026-03-19 00:42:27 -04:00
|
|
|
|
|
|
|
|
cards_pdf.rewind
|
|
|
|
|
send_data cards_pdf.sysread,
|
|
|
|
|
filename: "#{@employer.name.parameterize(separator: "_")}_full_page_cards_#{Date.today}.zip",
|
|
|
|
|
type: 'application/zip',
|
|
|
|
|
disposition: 'attachment'
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|