Method: Pdfmdedit#write_tags

Defined in:
lib/pdfmd/pdfmdedit.rb

#write_tags(filename) ⇒ Object

Write tags from the @@metadata back into the file



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/pdfmd/pdfmdedit.rb', line 201

def write_tags(filename)

  filename.empty? ? filename = @filename : ''

  commandparameter = '-overwrite_original'
  @@metadata.each do |key,value|
    commandparameter = commandparameter + " -#{key}=\"#{value}\""
  end

  if !@@documentPassword.to_s.empty?
    commandparameter = commandparameter + " -password '#{@@documentPassword}'"
  end

  command = "exiftool #{commandparameter} '#{filename}'"
  `#{command}`
  self.log('info',"Updating '#{filename}' with " + commandparameter.gsub(/\s\-password\s\'.*\'/,'').gsub(/\-overwrite\_original\s/,'').gsub(/\'\s\-/,"', ").gsub(/\-/,' ') )

end