class BrDanfe::MdfeLib::Header
Public Class Methods
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 4 def initialize(pdf, xml, logo, logo_dimensions) @pdf = pdf @xml = xml @logo = logo @logo_dimensions = logo_dimensions end
Public Instance Methods
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 11 def generate generate_emit generate_title generate_qr_code if @xml['qrCodMDFe'].present? end
Private Instance Methods
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 36 def address "#{@xml['enderEmit/xLgr']}, nº #{@xml['enderEmit/nro']}\n" \ "#{@xml['enderEmit/xMun']} - #{@xml['enderEmit/UF']} CEP #{cep}\n" end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 41 def cep Helper.format_cep(@xml['enderEmit/CEP']) end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 28 def company(x:) @pdf.bounding_box([x, @pdf.cursor], width: 280, height: 80) do @pdf.text(@xml['emit/xNome'], size: 12, style: :bold, align: :left) @pdf.text(address, align: :left, size: 9) @pdf.text(company_informations, size: 9, align: :left, inline_format: true) end end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 45 def company_informations "<b>CNPJ: </b>#{@xml['emit/CNPJ']} <b>IE: </b>#{@xml['emit/IE']}" end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 19 def generate_emit if @logo.present? company(x: 90) logo else company(x: 0) end end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 67 def generate_qr_code box_size = 40.mm security_margin = box_size + (box_size / 10.0) @pdf.bounding_box([414, 780], width: security_margin, height: security_margin) do BrDanfe::QrCode.new(pdf: @pdf, qr_code_tag: @xml['qrCodMDFe'], box_size: box_size).render end end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 58 def generate_title title = '<b>DAMDFE</b> - Documento Auxiliar de Manifesto Eletrônico de Documentos Fiscais' @pdf.move_down 15 @pdf.bounding_box([0, @pdf.cursor], width: 500, height: 20) do @pdf.text(title, size: 12, align: :left, inline_format: true) end end
Source
# File lib/br_danfe/mdfe_lib/header.rb, line 49 def logo bounding_box_size = 80 logo_options = BrDanfe::Logo::Options.new(bounding_box_size, @logo_dimensions).options @pdf.bounding_box([0, 770], width: bounding_box_size, height: bounding_box_size) do @pdf.image @logo, logo_options end end