class BrDanfe::DanfeLib::Nfce

Constants

PAGE_HEIGHT
PAGE_WIDTH

Private Instance Methods

create_watermark() click to toggle source
# File lib/br_danfe/danfe_lib/nfce.rb, line 13
def create_watermark
  @document.create_stamp('has_no_fiscal_value') do
    @document.fill_color '7d7d7d'
    @document.text_box(
      I18n.t('danfe.others.has_no_fiscal_value'),
      size: 0.8.cm,
      width: 10.cm,
      height: 1.2.cm,
      at: [0, PAGE_HEIGHT - 3.8.cm],
      rotate: 45,
      rotate_around: :center
    )
  end
end
document() click to toggle source
# File lib/br_danfe/danfe_lib/nfce.rb, line 9
def document
  NfceLib::Document.new(PAGE_WIDTH, PAGE_HEIGHT)
end
generate(footer_info) click to toggle source
# File lib/br_danfe/danfe_lib/nfce.rb, line 28
def generate(footer_info)
  @xmls.each do |xml|
    NfceLib::Header.new(@document, xml, @options.logo, @options.logo_dimensions).render
    NfceLib::ProductList.new(@document, xml).render
    NfceLib::TotalList.new(@document, xml).render
    NfceLib::Key.new(@document, xml).render
    NfceLib::Recipient.new(@document, xml).render
    NfceLib::NfceIdentification.new(@document, xml).render
    BrDanfe::QrCode.new(pdf: @document, qr_code_tag: xml['qrCode'], box_size: 4.5.cm).render
    NfceLib::Footer.new(@document, xml).render(footer_info)

    render_no_fiscal_value(xml)
    resize_page_height
  end
end
render_no_fiscal_value(xml) click to toggle source
# File lib/br_danfe/danfe_lib/nfce.rb, line 44
def render_no_fiscal_value(xml)
  @document.stamp('has_no_fiscal_value') if BrDanfe::Helper.unauthorized?(xml)
end
resize_page_height() click to toggle source
# File lib/br_danfe/danfe_lib/nfce.rb, line 48
def resize_page_height
  @document.page.dictionary.data[:MediaBox] = [0, @document.y - 10, PAGE_WIDTH, PAGE_HEIGHT]
end