Skip to content

Commit

Permalink
Fix #341
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Jun 27, 2021
1 parent b4ed6bb commit 9fe5913
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
19 changes: 10 additions & 9 deletions pkg/pdfcpu/date.go
Expand Up @@ -81,14 +81,15 @@ func parseTimezoneHours(s string, o byte) (int, bool) {
return 0, false
}

if s[17] != '\'' {
return 0, false
}

return tzh, true
}

func parseTimezoneMinutes(s string, o byte) (int, bool) {

if s[17] != '\'' {
return 0, false
}

tzmin := s[18:20]
tzm, err := strconv.Atoi(tzmin)
if err != nil {
Expand Down Expand Up @@ -130,9 +131,9 @@ func parseTimezone(s string, relaxed bool) (h, m int, ok bool) {
return 0, 0, true
}

if len(s) < 18 {
return 0, 0, false
}
// if len(s) < 18 {
// return 0, 0, false
// }

neg := o == '-'

Expand All @@ -145,8 +146,8 @@ func parseTimezone(s string, relaxed bool) (h, m int, ok bool) {
tzh *= -1
}

// "YYYYMMDDHHmmSSZHH'"
if len(s) == 18 {
// "YYYYMMDDHHmmSSZHH"
if len(s) == 17 {
return tzh, 0, true
}

Expand Down
11 changes: 7 additions & 4 deletions pkg/pdfcpu/date_test.go
Expand Up @@ -80,18 +80,21 @@ func TestParseDateTime(t *testing.T) {
s = "D:20170430155901"
doParseDateTimeOK(s, t)

s = "D:20170430155901+06'"
doParseDateTimeOK(s, t)

s = "D:20170430155901+06'59'"
doParseDateTimeOK(s, t)

s = "D:20170430155901Z00'"
s = "D:20170430155901Z00"
doParseDateTimeOK(s, t)

s = "D:20170430155901Z00'00'"
doParseDateTimeOK(s, t)

s = "D:20210602180254-06"
doParseDateTimeOK(s, t)

s = "D:20170430155901+06'"
doParseDateTimeFail(s, t)

s = "D:20170430155901+06'59"
doParseDateTimeFail(s, t)

Expand Down
5 changes: 0 additions & 5 deletions pkg/pdfcpu/extract.go
Expand Up @@ -51,11 +51,7 @@ func (ctx *Context) ImageObjNrs(pageNr int) []int {
// ExtractImage extracts an image from sd.
// Supported imgTypes: FlateDecode, DCTDecode, JPXDecode
func (ctx *Context) ExtractImage(sd *StreamDict, thumb bool, resourceId string, objNr int) (*Image, error) {
//imageObj := ctx.Optimize.ImageObjects[objNr]

// Get also imageDict for Thumb.

//imageDict := imageObj.ImageDict
if sd == nil {
return nil, nil
}
Expand Down Expand Up @@ -119,7 +115,6 @@ func (ctx *Context) ExtractImage(sd *StreamDict, thumb bool, resourceId string,
return nil, nil
}

//resourceName := imageObj.ResourceNames[0]
return RenderImage(ctx.XRefTable, sd, thumb, resourceId, objNr)
}

Expand Down

0 comments on commit 9fe5913

Please sign in to comment.