Free Support Forum - aspose.com

DateTime format for Date Created and Date Modified

Hi

Is there any way in aspose that we can get file properties like "Date Created" or "Date Modified" in particular date time format by following code

string dateCreation = PdfFileInfo.DateCreated;

Right now aspose returns it in a string which can not be directly converted to DateTime format?

Please help me out ?

Hi,

Please try the following codes:

string date = fileInfo.CreationDate;
date=date.Substring(0,date.Length-4);//simplify time format
string timeFormat = "D:yyyyMMddHHmmsszz";

CultureInfo myCulture = new CultureInfo("en-US");
DateTime dateTime=DateTime.ParseExact(date,timeFormat ,myCulture);
//Console.WriteLine(dateTime);

Thanks,

Hi,

Thanks for code

but I don't want to split the string and I don't want to specify culture info

I want last date time result comes in to local date time depending on local environment

1 more question -

I have attached 1 pdf file which is result of file mapped with name and gender and stored at other place

now when I tried for getting creation date - for that file, it should give me the date of when the file is populated

but it is giving me the date same as of input file not the new date

Dear Hardik,

Sorry for that setting for creation&modification date of pdfs is not supported in Aspose.Pdf.Kit.

As for the local datetime issue, I think you could find the solution in MSDN.

Thanks,

Hi

Thanks for quick reply

Now There is one question

Let me first give you inputs: - I have one encrypted file which has owner password

and I want to get the CreationDate property value so I used the code which gives me the value

but here the output value is not the original date as of input file, instead it gives us the current system date time?

Why it is changes to current system date time?

Thanks,

Hi,

Can you please provide us with that pdf so that we can test it.

Thanks.

Hi

The pdf document is attached with zip file and owner password is - "Per"

I first decrypted the file with the owner password and then I tried to get file properties

at that time it shows me the creation date as current system date-time

Thanks

Hi,

I have tested your file and was not able to reproduce the error. I got the same date which was available in the pdf files properties. Please see the screen shot. Also you can get the date with out having to decrypt this file first.

Thanks.

Hi

Ok, Could you just let me know how we could programmatically access the file creation date in case the target PDF file has a document open password? I'm asking this question because post decryption with the password the creation date is observed to change to current date rather than the original document creation date. So, is there a way, as you seem to suggest above, of getting the creation date of a PDF file having a document open password without having to decrypt the file? If so, please let me know how to do the same.

Thanks.

Hi,

When we decrypt a file then a new one is created to the creation date shows up aa current date and it is not possible to get creation date of encrypted file. So I will check with the developers to see if we can support the preservation of creation date.

Thanks.

Hi thanks fro quick reply,

If support can be provided to get creation date before decrypt the file which has document open password, It would be great helpful for me.

Thanks.

Hi,

We are still considering our options with this, but it is highly unlikely that this can be supported in very short time.

Thanks.

Our developer points out that the orignal date could be fetched as following:
PdfFileInfo pFileInfo = new PdfFileInfo(TestPath + “student-per.pdf”,“Per”);
string date = pFileInfo.CreationDate;