lib/hexapdf/parser.rb in hexapdf-0.32.2 vs lib/hexapdf/parser.rb in hexapdf-0.33.0
- old
+ new
@@ -39,15 +39,15 @@
require 'hexapdf/stream'
require 'hexapdf/xref_section'
module HexaPDF
- # Parses an IO stream according to PDF1.7 to get at the contained objects.
+ # Parses an IO stream according to PDF2.0 to get at the contained objects.
#
# This class also contains higher-level methods for getting indirect objects and revisions.
#
- # See: PDF1.7 s7
+ # See: PDF2.0 s7
class Parser
# The IO stream which is parsed.
attr_reader :io
@@ -123,11 +123,11 @@
# This method is used by a PDF Document to load objects. It should **not** be used by any
# other object because invalid object positions lead to errors.
#
# Returns an array containing [object, oid, gen, stream].
#
- # See: PDF1.7 s7.3.10, s7.3.8
+ # See: PDF2.0 s7.3.10, s7.3.8
def parse_indirect_object(offset = nil)
@tokenizer.pos = offset + @header_offset if offset
oid = @tokenizer.next_token
gen = @tokenizer.next_token
tok = @tokenizer.next_token
@@ -265,11 +265,11 @@
# Parses the cross-reference section at the given position and the following trailer and
# returns them as an array consisting of an HexaPDF::XRefSection instance and a hash.
#
# This method can only parse cross-reference sections, not cross-reference streams!
#
- # See: PDF1.7 s7.5.4, s7.5.5; ADB1.7 sH.3-3.4.3
+ # See: PDF2.0 s7.5.4, s7.5.5; ADB1.7 sH.3-3.4.3
def parse_xref_section_and_trailer(offset)
@tokenizer.pos = offset + @header_offset
token = @tokenizer.next_token
unless token.kind_of?(Tokenizer::Token) && token == 'xref'
raise_malformed("Xref section doesn't start with keyword xref", pos: @tokenizer.pos)
@@ -344,11 +344,11 @@
# Implementation note: Normally, the %%EOF marker has to be on the last line, however, Adobe
# viewers relax this restriction and so do we.
#
# If strict parsing is disabled, the whole file is searched for the offset.
#
- # See: PDF1.7 s7.5.5, ADB1.7 sH.3-3.4.4
+ # See: PDF2.0 s7.5.5, ADB1.7 sH.3-3.4.4
def startxref_offset
return @startxref_offset if defined?(@startxref_offset)
@io.seek(0, IO::SEEK_END)
step_size = 1024
@@ -395,11 +395,11 @@
@reconstructed_revision ||= reconstruct_revision
end
# Returns the PDF version number that is stored in the file header.
#
- # See: PDF1.7 s7.5.2
+ # See: PDF2.0 s7.5.2
def file_header_version
unless @header_version
raise_malformed("PDF file header is missing or corrupt", pos: 0)
end
@header_version
@@ -411,10 +411,10 @@
#
# The PDF header should normally appear on the first line. However, Adobe relaxes this
# restriction so that the header may appear in the first 1024 bytes. We follow the Adobe
# convention.
#
- # See: PDF1.7 s7.5.2, ADB1.7 sH.3-3.4.1
+ # See: PDF2.0 s7.5.2, ADB1.7 sH.3-3.4.1
def retrieve_pdf_header_offset_and_version
@io.seek(0)
@header_offset = (@io.read(1024) || '').index(/%PDF-(\d\.\d)/) || 0
@header_version = $1
end