Posted by a ceTe Software moderator
Hello,
Yes, you can set the Expiry date to the already existing PDF document using our DynamicPDF Merger for .NET product. You will need to use the JavaScript and add the JavaScript to the MergeDocument object using Add method of the JavaScripts class . Below is the sample code for it.
// Create a PDF Document
PdfDocument pdf = new PdfDocument(@"C:\Input.pdf");
MergeDocument document = new MergeDocument(pdf);
//add the java script to the string
string expiryDate = "var LastDay = 22; var LastMonth = 05; var LastYear = 2013; " +
" var today = new Date(); " +
" var myDate=new Date(); " +
" LastMonth = LastMonth - 1; " +
" myDate.setFullYear(LastYear,LastMonth,LastDay); " +
" if (myDate<today) " +
" {app.alert(\"This file is expired\"); this.closeDoc(1);} ";
document.JavaScripts.Add(new DocumentJavaScript("js", expiryDate));
document.Draw(@"C:\Output.pdf");
Thanks,
ceTe Software Support Team.