Parse floating point numbers correctly in content streams e.g. .1 .1 .2 RG

This commit is contained in:
Peter Williams 2017-03-29 17:31:46 +11:00
parent 4db1306daf
commit 5e0baec137
2 changed files with 5 additions and 1 deletions

View File

@ -544,7 +544,7 @@ func (this *ContentStreamParser) parseObject() (PdfObject, error, bool) {
common.Log.Trace("->Array!")
arr, err := this.parseArray()
return &arr, err, false
} else if IsDecimalDigit(bb[0]) || (bb[0] == '-' && IsDecimalDigit(bb[1])) {
} else if IsFloatDigit(bb[0]) || (bb[0] == '-' && IsFloatDigit(bb[1])) {
common.Log.Trace("->Number!")
number, err := this.parseNumber()
return number, err, false

View File

@ -15,6 +15,10 @@ func IsWhiteSpace(ch byte) bool {
}
}
func IsFloatDigit(c byte) bool {
return ('0' <= c && c <= '9') || c == '.'
}
func IsDecimalDigit(c byte) bool {
if c >= '0' && c <= '9' {
return true