Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Acrobat JavaScript is a language based on the core of JavaScript version 1.5 of ISO-16262, formerly known as ECMAScript, an object-oriented scripting language developed by Netscape Communications. JavaScript was created to offload Web page processing from a server onto a client in Web-based applications. Acrobat JavaScript implements extensions, in the form of new objects and their accompanying methods and properties, to the JavaScript language. These Acrobat-specific objects enable a developer to manage document security, communicate with a database, handle file attachments, manipulate a PDF file so that it behaves like an interactive, web-enabled form, and so on. Because the Acrobat-specific objects are added on top of core JavaScript, you still have access to its standard classes, including Math, String, Date, Array, and RegExp.
PDF documents have great versatility since they can be displayed both within the Acrobat software as well as a Web browser. Therefore, it is important to be aware of the differences between Acrobat JavaScript and JavaScript used in a Web browser, also known as HTML JavaScript:
You can add JavaScript at both the document and page levels using Aspose.PDF for .NET. To add JavaScript:
The example below applies the OpenAction to a specific document.
A new property named JavaScript is added in Document class which has JavaScript collection type and provides access to JavaScript scenarios by its key. This property is used to add Document level JavaScript. The JavaScript collection has the following properties and methods:
Aspose.PDF allows you to set an expiry date for a PDF document by embedding JavaScript Actions. This functionality ensures the PDF becomes inaccessible after a specified date and time, enhancing document security and control. By leveraging JavaScript Actions, you can define precise expiration conditions down to the second, ensuring the document’s accessibility is tightly regulated.
You can achieve this by following these steps
Below are code snippets demonstrating this functionality in both C# (.NET) and Java.
The following C# code snippet demonstrates how to set an expiry date and time for a PDF document using JavaScript Actions with Aspose.PDF:
JavaScript Date Object: In JavaScript, the month index starts at 0
for January and ends at 11
for December. Ensure that the month value is adjusted accordingly when setting the expiry date and time.
Security Considerations: While JavaScript actions can control the behavior of a PDF document, they rely on the PDF viewer’s support for JavaScript. Not all PDF viewers may honor these scripts, and users might have JavaScript execution disabled for security reasons.
Customization: Modify the JavaScript code to perform additional actions upon expiry, such as disabling certain features, redirecting to a specific page, or logging the event. Additionally, if necessary, you can check only the date of expiry without specifying the time.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.