Correção QRCODE holerite
This commit is contained in:
BIN
app/assets/fonts/DejaVuSans-Bold.ttf
Normal file
BIN
app/assets/fonts/DejaVuSans-Bold.ttf
Normal file
Binary file not shown.
BIN
app/assets/fonts/DejaVuSans.ttf
Normal file
BIN
app/assets/fonts/DejaVuSans.ttf
Normal file
Binary file not shown.
@@ -9,10 +9,16 @@ module Pdf
|
||||
PRETO = '0A0A0A'
|
||||
CINZA = '6B7280'
|
||||
|
||||
# Fonte TrueType com suporte total a UTF-8. As fontes embutidas do Prawn
|
||||
# (AFM/Helvetica) só aceitam o charset Windows-1252 e estouram
|
||||
# Prawn::Errors::IncompatibleStringEncoding em caracteres como "✓".
|
||||
FONTS_DIR = Rails.root.join('app', 'assets', 'fonts')
|
||||
|
||||
def initialize
|
||||
# Margem inferior folgada (72) para o rodapé repetido (desenhado em y=20)
|
||||
# não sobrepor o conteúdo.
|
||||
@pdf = Prawn::Document.new(page_size: 'A4', margin: [40, 40, 72, 40])
|
||||
registrar_fonte_utf8
|
||||
end
|
||||
|
||||
def render
|
||||
@@ -24,6 +30,24 @@ module Pdf
|
||||
|
||||
private
|
||||
|
||||
# Registra a família DejaVu Sans (TTF) e a define como fonte padrão.
|
||||
# Como os PDFs só usam normal e :bold, mapeamos italic/bold_italic para
|
||||
# as variantes existentes, evitando erro caso :italic seja solicitado.
|
||||
def registrar_fonte_utf8
|
||||
normal = FONTS_DIR.join('DejaVuSans.ttf').to_s
|
||||
bold = FONTS_DIR.join('DejaVuSans-Bold.ttf').to_s
|
||||
|
||||
@pdf.font_families.update(
|
||||
'DejaVu' => {
|
||||
normal: normal,
|
||||
bold: bold,
|
||||
italic: normal,
|
||||
bold_italic: bold
|
||||
}
|
||||
)
|
||||
@pdf.font 'DejaVu'
|
||||
end
|
||||
|
||||
def cabecalho
|
||||
@pdf.fill_color PRETO
|
||||
@pdf.fill_rectangle [-40, @pdf.cursor + 40], @pdf.bounds.width + 80, 70
|
||||
|
||||
Reference in New Issue
Block a user