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.
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");
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.
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.