Correção QRCODE holerite
This commit is contained in:
File diff suppressed because it is too large
Load Diff
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'
|
PRETO = '0A0A0A'
|
||||||
CINZA = '6B7280'
|
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
|
def initialize
|
||||||
# Margem inferior folgada (72) para o rodapé repetido (desenhado em y=20)
|
# Margem inferior folgada (72) para o rodapé repetido (desenhado em y=20)
|
||||||
# não sobrepor o conteúdo.
|
# não sobrepor o conteúdo.
|
||||||
@pdf = Prawn::Document.new(page_size: 'A4', margin: [40, 40, 72, 40])
|
@pdf = Prawn::Document.new(page_size: 'A4', margin: [40, 40, 72, 40])
|
||||||
|
registrar_fonte_utf8
|
||||||
end
|
end
|
||||||
|
|
||||||
def render
|
def render
|
||||||
@@ -24,6 +30,24 @@ module Pdf
|
|||||||
|
|
||||||
private
|
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
|
def cabecalho
|
||||||
@pdf.fill_color PRETO
|
@pdf.fill_color PRETO
|
||||||
@pdf.fill_rectangle [-40, @pdf.cursor + 40], @pdf.bounds.width + 80, 70
|
@pdf.fill_rectangle [-40, @pdf.cursor + 40], @pdf.bounds.width + 80, 70
|
||||||
|
|||||||
Reference in New Issue
Block a user