def delinearize!
            raise LinearizationError, 'Not a linearized document' unless self.linearized?

            #
            # Saves the first trailer.
            #
            prev_trailer = @revisions.first.trailer

            linear_dict = @revisions.first.objects.min_by{|obj| obj.file_offset}

            #
            # Removes hint streams used by linearization.
            #
            delete_hint_streams(linear_dict)

            #
            # Update the trailer.
            #
            last_trailer = (@revisions.last.trailer ||= Trailer.new)
            last_trailer.dictionary ||= Dictionary.new

            if prev_trailer.dictionary?
                last_trailer.dictionary =
                    last_trailer.dictionary.merge(prev_trailer.dictionary)
            else
                xrefstm = @revisions.last.xrefstm
                raise LinearizationError,
                        'Cannot find trailer info while delinearizing document' unless xrefstm.is_a?(XRefStream)

                last_trailer.dictionary[:Root] = xrefstm[:Root]
                last_trailer.dictionary[:Encrypt] = xrefstm[:Encrypt]
                last_trailer.dictionary[:Info] = xrefstm[:Info]
                last_trailer.dictionary[:ID] = xrefstm[:ID]
            end

            #
            # Remove all xrefs.
            # Fix: Should be merged instead.
            #
            remove_xrefs

            #
            # Remove the linearization revision.
            #
            @revisions.first.body.delete(linear_dict.reference)
            @revisions.last.body.merge! @revisions.first.body

            remove_revision(0)

            self
        end
def delinearize!
            raise LinearizationError, 'Not a linearized document' unless self.linearized?

            #
            # Saves the first trailer.
            #
            prev_trailer = @revisions.first.trailer

            linear_dict = @revisions.first.objects.min_by{|obj| obj.file_offset}

            #
            # Removes hint streams used by linearization.
            #
            delete_hint_streams(linear_dict)

            #
            # Update the trailer.
            #
            last_trailer = (@revisions.last.trailer ||= Trailer.new)
            last_trailer.dictionary ||= Dictionary.new

            if prev_trailer.dictionary?
                last_trailer.dictionary =
                    last_trailer.dictionary.merge(prev_trailer.dictionary)
            else
                xrefstm = @revisions.last.xrefstm
                raise LinearizationError,
                        'Cannot find trailer info while delinearizing document' unless xrefstm.is_a?(XRefStream)

                last_trailer.dictionary[:Root] = xrefstm[:Root]
                last_trailer.dictionary[:Encrypt] = xrefstm[:Encrypt]
                last_trailer.dictionary[:Info] = xrefstm[:Info]
                last_trailer.dictionary[:ID] = xrefstm[:ID]
            end

            #
            # Remove all xrefs.
            # Fix: Should be merged instead.
            #
            remove_xrefs

            #
            # Remove the linearization revision.
            #
            @revisions.first.body.delete(linear_dict.reference)
            @revisions.last.body.merge! @revisions.first.body

            remove_revision(0)

            self
        end
Tries to delinearize the document if it has been linearized.
 This operation is xrefs destructive, should be fixed in the future to merge tables.