lib/combine_pdf/parser.rb in combine_pdf-0.2.12 vs lib/combine_pdf/parser.rb in combine_pdf-0.2.13
- old
+ new
@@ -201,14 +201,14 @@
# raise error if the stream doesn't end.
raise "Parsing Error: PDF file error - a stream object wasn't properly colsed using 'endstream'!" unless str
# need to remove end of stream
if out.last.is_a? Hash
# out.last[:raw_stream_content] = str[0...-10] #cuts only one EON char (\n or \r)
- out.last[:raw_stream_content] = unify_string str.sub(/[\n\r]?[\n\r]endstream\z/, "").force_encoding(Encoding::ASCII_8BIT)
+ out.last[:raw_stream_content] = unify_string str.sub(/(\r\n|\n|\r)?endstream\z/, "").force_encoding(Encoding::ASCII_8BIT)
else
warn "Stream not attached to dictionary!"
- out << str.sub(/[\n\r]?[\n\r]endstream\z/, "").force_encoding(Encoding::ASCII_8BIT)
+ out << str.sub(/(\r\n|\n|\r)?endstream\z/, "").force_encoding(Encoding::ASCII_8BIT)
end
##########################################
## parse an Object after finished
##########################################
when str = @scanner.scan(/endobj/)
@@ -314,10 +314,10 @@
##########################################
when str = @scanner.scan(/\%/)
#is a comment, skip until new line
loop do
break unless @scanner.scan(/[^\d\r\n]+/)
- break if @scanner.check(/([\d]+ [\d]+ obj)?[\n\r]+/)
+ break if @scanner.check(/([\d]+[\s]+[\d]+[\s]+obj[\n\r\s]+\<\<)|([\n\r]+)/)
break if @scanner.eos?
@scanner.pos += 1
end
# puts "AFTER COMMENT: #{@scanner.peek 8}"
##########################################
\ No newline at end of file