PDF Annotation Dates

Hi,

I’m having trouble getting Date/Time values for Annotations that correspond to values reported by other products (Adobe/Nuance etc). For the First example, check the following test PDF

PDFFileAttachmentAnnotations.Yes.pdf (343.6 KB)

Acrobat shows the “Adobe Acrobat 5.0” as being modified at 12/06/2001 10:41:19 AM

image.png (12.2 KB)

Nuance similarly shows the same value

image.png (4.2 KB)

However, if I read the value in Aspose.PDF I see the raw value as 11/06/2001 6:41:19 PM

image.png (5.0 KB)

Now obviously there’s some issue with the time zone, however the the “kind” is Unspecified. I have noticed that for the Document Created/Modified Date there’s a CreationTimeZone and ModTimeZone property which I use for the Created/Modified like so:

aspPdfDocument.Info.ModDate.ToLocalTime().Subtract(aspPdfDocument.Info.ModTimeZone)

This seems to be reliable for those dates.

How to do this for Annotations (and Signatures). There is no TimeZone info I can see. If I use the ModTimeZine value above with

aspPdfAnnotation.Modified.ToLocalTime().Subtract(aspPdfDocument.Info.ModTimeZone)

Then I get 12/06/2001 8:41:19 AM, which is closer but still not right. To get it right I need to use

aspPdfAnnotation.Modified.Subtract(aspPdfDocument.Info.ModTimeZone)

But this seems to vary document by document. Can you give me an idea how to get the correct displayed date/time for all annotations?

@GaryO

To accurately retrieve the date and time values for annotations in a PDF using Aspose.PDF, you need to consider the time zone discrepancies that may arise. While you have successfully managed the document’s creation and modification dates by using the ModTimeZone property, annotations do not provide explicit time zone information.

Here’s a suggested approach to handle the date and time for annotations:

  1. Retrieve the Modified Date: Use the Modified property of the annotation to get the date and time.
  2. Adjust for Time Zone: Since annotations do not have a specific time zone, you can apply the document’s modification time zone to the annotation’s modified date. However, as you’ve noted, this may not yield consistent results across different documents.

Here’s a code snippet that demonstrates how to adjust the annotation’s modified date:

// Assuming 'aspPdfAnnotation' is your annotation object
DateTime annotationModifiedDate = aspPdfAnnotation.Modified;

// Adjust for the document's modification time zone
DateTime adjustedDate = annotationModifiedDate.Subtract(aspPdfDocument.Info.ModTimeZone);

// Output the adjusted date
Console.WriteLine("Adjusted Annotation Modified Date: " + adjustedDate);

If you find that this adjustment varies from document to document, it may be necessary to implement additional logic to handle specific cases or discrepancies. Unfortunately, without explicit time zone information for annotations, achieving a universally accurate result may require some trial and error.

If you continue to experience issues, consider checking the documentation or exploring similar forum posts for additional insights or solutions that other users may have discovered.

Sources:
[1]: AddDateTimeStamp.cs

How is the time stored in the PDF itself, isnt it a TimeStamp like epoch?

@GaryO

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-58966

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.