lib/pdf/reader/buffer.rb
def find_first_xref_offset
      check_size_is_non_zero
      @io.seek(-1024, IO::SEEK_END) rescue @io.seek(0)
      data = @io.read(1024)

      # the PDF 1.7 spec (section #3.4) says that EOL markers can be either \r, \n, or both.
      lines = data.split(/[\n\r]+/).reverse
      eof_index = lines.index { |l| l.strip[/^%%EOF/] }

      raise MalformedPDFError, "PDF does not contain EOF marker" if eof_index.nil?
      raise MalformedPDFError, "PDF EOF marker does not follow offset" if eof_index >= lines.size-1
      lines[eof_index+1].to_i
    end
# return the byte offset where the first XRef table in th source can be found.
#
return the byte offset where the first XRef table in th source can be found.
return the byte offset where the first XRef table in th source can be found .
def find_first_xref_offset
      check_size_is_non_zero
      @io.seek(-1024, IO::SEEK_END) rescue @io.seek(0)
      data = @io.read(1024)
      lines = data.split(/[\n\r]+/).reverse
      eof_index = lines.index { |l| l.strip[/^%%EOF/] }
      raise MalformedPDFError, "PDF does not contain EOF marker" if eof_index.nil?
      raise MalformedPDFError, "PDF EOF marker does not follow offset" if eof_index >= lines.size-1
      lines[eof_index+1].to_i
    end
def find_first_xref_offset check_size_is_non_zero @io . seek ( - 1024 , IO :: SEEK_END ) rescue @io . seek ( 0 ) data = @io . read ( 1024 ) lines = data . split ( / [ \n \r ]+ / ) . reverse eof_index = lines . index { | l | l . strip [ / ^%%EOF / ] } raise MalformedPDFError , "PDF does not contain EOF marker" if eof_index . nil? raise MalformedPDFError , "PDF EOF marker does not follow offset" if eof_index >= lines . size - 1 lines [ eof_index + 1 ] . to_i end
return the byte offset where the first XRef table in th source can be found.
return the byte offset where the first XRef table in th source can be found .
# the PDF 1.7 spec (section #3.4) says that EOL markers can be either \r, \n, or both.