Class: Redmine::Export::PDF::RDMPdfEncoding

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/export/pdf.rb

Class Method Summary collapse

Class Method Details

.attach(attachments, filename, encoding) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/redmine/export/pdf.rb', line 141

def self.attach(attachments, filename, encoding)
  filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
  atta = nil
  if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
    atta = Attachment.latest_attach(attachments, filename_utf8)
  end
  if atta && atta.readable? && atta.visible?
    return atta
  else
    return nil
  end
end

.rdm_from_utf8(txt, encoding) ⇒ Object



134
135
136
137
138
139
# File 'lib/redmine/export/pdf.rb', line 134

def self.rdm_from_utf8(txt, encoding)
  txt ||= ''
  txt = Redmine::CodesetUtil.from_utf8(txt, encoding)
  txt.force_encoding('ASCII-8BIT')
  txt
end