lib/hexapdf/parser.rb in hexapdf-0.27.0 vs lib/hexapdf/parser.rb in hexapdf-0.28.0
- old
+ new
@@ -68,9 +68,22 @@
# Returns +true+ if the PDF file was damaged and could be reconstructed.
def reconstructed?
!@reconstructed_revision.nil?
end
+ # Returns +true+ if the PDF file is a linearized file.
+ def linearized?
+ @linearized ||=
+ begin
+ @tokenizer.pos = @header_offset
+ 3.times { @tokenizer.next_token } # parse: oid gen obj
+ obj = @tokenizer.next_object
+ obj.kind_of?(Hash) && obj.key?(:Linearized)
+ rescue MalformedPDFError
+ false
+ end
+ end
+
# Loads the indirect (potentially compressed) object specified by the given cross-reference
# entry.
#
# For information about the +xref_entry+ argument, have a look at HexaPDF::XRefSection and
# HexaPDF::XRefSection::Entry.