Method: Origami::PDF#save

Defined in:
lib/origami/pdf.rb

#save(path, params = {}) ⇒ Object Also known as: write

Saves the current document.

filename

The path where to save this PDF.



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/origami/pdf.rb', line 221

def save(path, params = {})
    options =
    {
        delinearize: true,
        recompile: true,
        decrypt: false
    }
    options.update(params)

    if self.frozen? # incompatible flags with frozen doc (signed)
        options[:recompile] =
        options[:rebuild_xrefs] =
        options[:noindent] =
        options[:obfuscate] = false
    end

    if path.respond_to?(:write)
        fd = path
    else
        path = File.expand_path(path)
        fd = File.open(path, 'w').binmode
        close = true
    end

    load_all_objects unless @loaded

    intents_as_pdfa1 if options[:intent] =~ /pdf[\/-]?A1?/i
    self.delinearize! if options[:delinearize] and self.linearized?
    compile(options) if options[:recompile]

    fd.write output(options)
    fd.close if close

    self
end