Question about pdf expiration date

I have a question from one of our customers, can you please check below and let us know if this can be done and provide us with an example?

Customer request is to add an expiration date to the PDF so that even if downloaded, it would not be able to be opened after the date of expiry.

Thanks

@aabuhijleh

We believe a similar requirement has already been discussed in the other thread where a solution was also given. Please check below forum thread and feel free to let us know in case you need further assistance.

Can this be done using your API and Java.

Can you share an example please?

Thanks

@aabuhijleh

The code sample given in the referenced thread is already using Aspose.PDF for Java. Are you not able to use it?

Ir does not work there is an issue with the imports. I try but without luck.

Can you help please?
Thanks

@aabuhijleh

Please use below complete code snippet and let us know in case you still notice any issues:

Document doc = new Document();
doc.getPages().add();

java.time.LocalDate date1 = java.time.LocalDate.now().minusDays(10);
int year = date1.getYear();
int mon = date1.getMonthValue();
int dated = date1.getDayOfMonth();

JavascriptAction javaScript = new JavascriptAction(
        "// Get the current date and time\n" +
                "var rightNow = new Date();\n" +
                "// Set End Date to 2021/04/01 for instance\n" +
                "var endDate = new Date(2021, 03, 01);\n" +
                "if(rightNow > endDate)\n" +
                "{\n" +
                "app.alert(\"This Document has Expired.\");\n" +
                "this.closeDoc();\n" +
                "}");

doc.setOpenAction(javaScript);
doc.save(dataDir + "PDFExpiry.pdf");

I try it and it is worked but it easily can he hacked, I opened the file as text and changed the expired date.

You do not have other options throw Aspose API that cannot be changed like above?

@aabuhijleh

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): PDFJAVA-43549

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.

Can you pleas give more details about this bug and what should it fixed?

Also you do not reply to my question do you have other options/ways throw Aspose API to set expiration date for PDF?

@aabuhijleh

It is not a bug in the API. In fact, it is a limitation of the functionality itself that you can achieve at the moment using Aspose.PDF.

Sadly, there is no other way at the moment in order to achieve this requirement except the one that we already had shared with you.

The logged ticket is about implementing this new feature in the API for the usage in such scenarios. The ticket is linked with this forum thread so that you will receive a notification as soon as it is resolved and feature is available to use. We will also keep you posted with the status of ticket resolution in this forum thread. Please spare us some time.