CreationDate for TextAnnotation always 01.01.0001

Dear support team,

we are on 19.5.0.0.

Creating a Aspose.Pdf.Annotations.TextAnnotation always sets its CreationDate property to Jan 1 0001.

This behaviour and the absence of a setter render the property useless, but we need it set properly.

Can you help?

@USuess

Thanks for contacting support.

Could you please share a sample code snippet along with generated output PDF and screenshot of the issue. We will test the scenario in our environment and address it accordingly.

Thanks for your fast response.

I have attached a base document and one with thee added comments (TextAnnotations), the latter two being responses to the first. Please note that the important issue here is that by not having set the correct CreationDate, the proper response order is not preserved. At least this is the most likely reason after having checked all other circumstances.

To check this wrong behaviour open the document with Acrobat Reader several times. You will see that sometimes “Response A” is shown as the first response, sometimes “Response B”. This is NOT standard behaviour and works fine when creating comments in Acrobat Reader. The CreationDate property for those comments is also set properly and can be read in code. Only those generated by Aspose.Pdf show the wrong dates.

Here is sample code you can use to verify the behaviour. You can pass the document’s byte[] to the method or, alternatively, have the base document I have provided in the necessary temp path location.

private void AsposeSupportTextAnnotationCreationDateIssue(byte[] docBytes)
{
        if (docBytes == null) docBytes = File.ReadAllBytes(Path.Combine(Path.GetTempPath(), "TextAnnotationCreationDateIssue_Base.pdf"));
        byte[] annoEnrichedDocBytes = new byte[0];
        // create document and add TextAnnotations
        using (var memDocStream = new MemoryStream(docBytes))
        {
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(memDocStream);
            Aspose.Pdf.Page page = doc.Pages.First();
            Aspose.Pdf.Rectangle bounds = new Aspose.Pdf.Rectangle(50.0, page.Rect.Height - 70.0, 70.0, page.Rect.Height - 50.0);
            Aspose.Pdf.Annotations.TextAnnotation asposeTextAnnotation_1 =
                new Aspose.Pdf.Annotations.TextAnnotation(page, bounds);

            asposeTextAnnotation_1.Contents = "Original";
            Debug.WriteLine(asposeTextAnnotation_1.CreationDate); // Output: 01.01.0001 00:00:00
            page.Annotations.Add(asposeTextAnnotation_1);

            // in a perfect world this should let creation date of the next anno be about 2 seconds younger
            System.Threading.Thread.Sleep(2000);

            // add response A
            Aspose.Pdf.Annotations.TextAnnotation asposeTextAnnotation_2 =
                new Aspose.Pdf.Annotations.TextAnnotation(page, bounds);
            asposeTextAnnotation_2.Contents = "Response A";
            Debug.WriteLine(asposeTextAnnotation_2.CreationDate); // Output: 01.01.0001 00:00:00
            asposeTextAnnotation_2.InReplyTo = asposeTextAnnotation_1;
            page.Annotations.Add(asposeTextAnnotation_2);

            // in a perfect world this should let creation date of the next anno be about 2 seconds younger
            System.Threading.Thread.Sleep(2000);

            // add response B
            Aspose.Pdf.Annotations.TextAnnotation asposeTextAnnotation_3 =
                new Aspose.Pdf.Annotations.TextAnnotation(page, bounds);
            asposeTextAnnotation_3.Contents = "Response B";
            Debug.WriteLine(asposeTextAnnotation_3.CreationDate); // Output: 01.01.0001 00:00:00
            asposeTextAnnotation_3.InReplyTo = asposeTextAnnotation_1;
            page.Annotations.Add(asposeTextAnnotation_3);

            annoEnrichedDocBytes = doc.ToBytes();
        }

        // read document and its annotations
        using (var memDocStream = new MemoryStream(annoEnrichedDocBytes))
        {
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(memDocStream);
            foreach (Page p in doc.Pages)
            {
                foreach (var anno in p.Annotations)
                {
                    Aspose.Pdf.Annotations.TextAnnotation textAnnotation = (anno as Aspose.Pdf.Annotations.TextAnnotation);
                    if (textAnnotation != null)
                    {
                        Debug.WriteLine(textAnnotation.CreationDate); // Output: 01.01.0001 00:00:00
                    }
                }
            }
            // write document
            File.WriteAllBytes(Path.Combine(Path.GetTempPath(), "TextAnnotationCreationDateIssue_WithAnnos.pdf"), annoEnrichedDocBytes);
        }
    }

TextAnnotationCreationDateIssue_WithAnnos.pdf (36.2 KB)
TextAnnotationCreationDateIssue_Base.pdf (37.1 KB)

@USuess

Thanks for sharing requested details.

We have noticed the issue in our environment while testing the scenario with Aspose.PDF for .NET 19.6 and logged an enhancement request as PDFNET-46566 in our issue tracking system. We will definitely investigate feasibility of the enhancement and keep you informed with the status of its implementation. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thanks a lot.

Hi Aspose Support Team,

Any news on this subject ? We have the same issue. Every TextAnnotation or HighlightAnnotation we create have their CreationDate set at 01.01.0001.

Thank you for your input!
Best Regards

@Pierre_Lasvigne

Regretfully, the earlier logged ticket is not yet resolved. We will surely post an update within this forum thread as soon as we have some regarding issue resolution. We highly appreciate your patience and comprehension in this regard.

We apologize for the inconvenience.

The issues you have found earlier (filed as PDFNET-46566) have been fixed in Aspose.PDF for .NET 23.9.