Hi,
I am using the Aspose .NET libraries for an evaluation.
I need to know if its possible to be able to fill in my form and then apply some Javascript to the document. I tried the code below but it did not work:
var directory = Directory.GetCurrentDirectory();
formFile =
String.Format("{0}\\Employment Application.pdf", directory);
newFile =
String.Format("{0}\\Employment Application - {1} {2}.pdf", directory, firstName, lastName);
using (Document doc = new Document(formFile))
{
TextBoxField firstNameField = doc.Form["FirstName"] as TextBoxField;TextBoxField lastNameField = doc.Form["LastName"] as TextBoxField;firstNameField.Value = firstName;lastNameField.Value = lastName;doc.Save(newFile);
}
using (FileStream fs = new FileStream(newFile, FileMode.OpenOrCreate))
{
Pdf pdf = new Pdf(fs);pdf.JavaScripts = new JavaScripts();pdf.JavaScripts.Add(new JavaScript{
ID = "Alert",
ScriptContent = String.Format("app.alert(\"Hi {0} {1}\");", firstName, lastName)
});pdf.JavaScripts.Add(new JavaScript{
ID = "Print",
ScriptContent = "this.print(true);"
});pdf.Save(fs);
}
EDIT:
I should mention that the code does fill in the first and last names correctly, it just wont apply the Javascript to the document. The main issue I'm actually having is that the are no exceptions coming back when saving the file with Javascript on it.
Thanks,
Macklin.