lib/origami/pdf.rb in origami-1.2.4 vs lib/origami/pdf.rb in origami-1.2.5
- old
+ new
@@ -2,10 +2,14 @@
= File
pdf.rb
= Info
+ This file is part of Origami, PDF manipulation framework for Ruby
+ Copyright (C) 2010 Guillaume Delugré <guillaume AT security-labs DOT org>
+ All right reserved.
+
Origami is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@@ -59,12 +63,12 @@
require 'origami/parsers/pdf'
module Origami
- VERSION = "1.2.4"
- REVISION = "$Revision$" #:nodoc:
+ VERSION = "1.2.5"
+ REVISION = "$Revision: rev 167/, 2013/01/28 11:59:28 $" #:nodoc:
#
# Global options for Origami.
#
OPTIONS =
@@ -509,13 +513,32 @@
# If this object has no version number, then a new one will be automatically computed and assignated to him.
# It returns a Reference to this Object.
# _object_:: The object to add.
#
def <<(object)
- add_to_revision(object, @revisions.last)
+ owner = object.pdf
+
+ #
+ # Does object belongs to another PDF ?
+ #
+ if owner and not owner.equal?(self)
+ import object
+ else
+ add_to_revision(object, @revisions.last)
+ end
end
alias :insert :<<
+ #
+ # Similar to PDF#insert or PDF#<<, but for an object belonging to another document.
+ # Object will be recursively copied and new version numbers will be assigned.
+ # Returns the new reference to the imported object.
+ # _object_:: The object to import.
+ #
+ def import(object)
+ self.insert(object.export)
+ end
+
#
# Adds a new object to a specific revision.
# If this object has no version number, then a new one will be automatically computed and assignated to him.
# It returns a Reference to this Object.
# _object_:: The object to add.