New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
write invalid local Date #320
Comments
The PDF Date string as shown here is invalid - it should have just one of the " |
@petervwyatt thanks for the information. To add more context, I have no idea where that date is being generated, or how to manually override it. I Set a breakpoint on Here is the code where the error occurs: wm := pdfcpu.DefaultWatermarkConfig()
wm.Mode = pdfcpu.WMImage
wm.OnTop = true
wm.Diagonal = 0
wm.InpUnit = pdfcpu.POINTS
wm.FileName = editImgPath
wm.Pos = pdfcpu.TopLeft
wm.Scale = scale(refW, pageW)
wm.ScaleEff = float64(refW)
wm.ScaleAbs = true
wm.Dx = int(math.Round(calcPos(x, refW, pageW)))
wm.Dy = int(math.Round(-calcPos(y, refH, pageH)))
err = api.AddWatermarks(inFile, outFile, []string{strconv.Itoa(page)}, wm, nil) |
Sorry but I'm not a real Gopher (yet)... the error is likely to be in one of the input PDFs (the watermark or the PDF being watermarked) - can you share/check? e.g. your wm.FileName and inFile files. AFAICT pkg/pdfcpu/date.go parses and validates PDF Date literal ASCII strings correctly. My only very minor gripe for @hhrutter would be that PDF Date strings don't have to be literal ASCII strings - they can be hex strings, have escape sequences, etc. The "date-ness" processing needs to happen after the PDF string object (of any kind) is parsed and then normalized. But that has precisely zero to do with this error and is only FYI for @hhrutter... |
We have Thank you for using pdfcpu 💚 @petervwyatt Duly noted. |
@hhrutter Thank you for the awesome library ❤️ I don't believe its related to the PDF's we are using since changing the timezone in Windows settings seems to be the difference between working or erroring, but I could be entirely wrong. Unfortunately I cannot share the PDF's since they contain confidential patient medical information and require HIPPA compliance. However, I do believe I can create a working minimal example and share all the necessary resources for testing and debugging. I will report back once I have those materials ready. Thanks for all your help. |
@hhrutter I have created an example repo with everything need to simulate a failure case. Running the example in my local time (US mountain time) yields no error, but running it with my time zone set to I learned more while creating this: it seems like @petervwyatt was correct in his suspicion that the issue was an invalid date object from an input file. This issue doesn't seem to arise from the original input file, as I was unable to trigger the error when adding watermarks directly to an unmodified PDF. In our case, we are first merging several files into a single "work file" using Please view this example repo for the code, materials, and information to reproduce. |
Thanks @codydbentley - I can now repro when I I'm guessing the line at fault is line 29 of date.go as it hardcodes "
I think it needs to be " |
Fixed with latest commit. Thanks for uncovering this 💚 |
I have created a tool which uses the pdfcpu api to apply watermarks to PDF pages, but there seems to be an issue with the validateDateObject returning this error:
pdfcpu: validateDateObject: <D:20210408134302+-10'00'> invalid date
This is compiled and run on a Windows 10 x64 machine, and it seems to be related to Date & Time Settings in Windows.. I tested with a number of other timezones and it works flawlessly, but for some reason changing the time zone to
(UTC -10:00) Hawaii
will always result in this invalid date error.If you need more context, please let me know what would help and I will send it to you. Thanks!
The text was updated successfully, but these errors were encountered: