Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.
Sun Jul 08, 2018 7:34 am
// Create a PDF Document
ceTe.DynamicPDF.Merger.PdfDocument pdf = new ceTe.DynamicPDF.Merger.PdfDocument("Abhishek.pdf");
MergeDocument document = new MergeDocument(pdf);
//add the java script to the string
string expiryDate = "var LastDay = 07; var LastMonth = 07; var LastYear = 2017; " +
" 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("Output.pdf");
This code does not work
-
abhiseky93
-
- Posts: 1
- Joined: Sun Jul 08, 2018 7:31 am
Mon Jul 09, 2018 3:59 am
Dear abhiseky93,
Thanks for your inquiry.
From your code, I thought you were not using our
Spire.PDF. I am afraid we are unable to help you.
Below is the code provided by Spire.PDF to set the expiry date.
- Code: Select all
//create a document
PdfDocument document = new PdfDocument();
//add a page
PdfPageBase pageone = document.Pages.Add();
//add the java script to the string
string expiryDate = "var LastDay = 07; var LastMonth = 07; var LastYear = 2017; " +
" 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);} ";
PdfJavaScriptAction action = new PdfJavaScriptAction(expiryDate);
document.AfterOpenAction = action;
document.SaveToFile("14337.pdf");
System.Diagnostics.Process.Start("14337.pdf");
Sincerely,
Betsy
E-iceblue support team
-
Betsy.jiang
-
- Posts: 3099
- Joined: Tue Sep 06, 2016 8:30 am
Fri Jul 13, 2018 3:11 am
Dear abhiseky93,
Greetings from E-iceblue.
How is your issue going now ? Could you please give us some feedback at your convenience ?
Sincerely,
Betsy
E-iceblue support team
-
Betsy.jiang
-
- Posts: 3099
- Joined: Tue Sep 06, 2016 8:30 am