From 9fe59134ad81184193d2d832a18eb9e0b87760f8 Mon Sep 17 00:00:00 2001 From: Horst Rutter Date: Sun, 27 Jun 2021 18:04:16 +0200 Subject: [PATCH] Fix #341 --- pkg/pdfcpu/date.go | 19 ++++++++++--------- pkg/pdfcpu/date_test.go | 11 +++++++---- pkg/pdfcpu/extract.go | 5 ----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pkg/pdfcpu/date.go b/pkg/pdfcpu/date.go index 9c951acc3..9da7db3ff 100644 --- a/pkg/pdfcpu/date.go +++ b/pkg/pdfcpu/date.go @@ -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 { @@ -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 == '-' @@ -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 } diff --git a/pkg/pdfcpu/date_test.go b/pkg/pdfcpu/date_test.go index ca8631045..dcfd56810 100644 --- a/pkg/pdfcpu/date_test.go +++ b/pkg/pdfcpu/date_test.go @@ -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) diff --git a/pkg/pdfcpu/extract.go b/pkg/pdfcpu/extract.go index 4cd9928d6..da017b6ad 100644 --- a/pkg/pdfcpu/extract.go +++ b/pkg/pdfcpu/extract.go @@ -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 } @@ -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) }